Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
4fad16beb9
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
34 lines (28 sloc) 1.1 KB
import sys
class Node:
def __init__(self, identifier):
self.id = identifier # size is between 28 and 32 bytes
self.seq = ""
self.seq_len = 0 # mostly 28 bytes
self.start = [] # 96 bytes for 4 neighbors
self.end = [] # 96 bytes
self.visited = False # 28 bytes (used for bubble and superbubble detection)
self.which_chain = 0
self.which_sb = 0
self.which_b = 0
self.which_allele = -1
# Function to calculate the size of node recursively
# using sys.getsizeof() function doesn't calculate object's size recursively
def __sizeof__(self):
size = self.id.__sizeof__() + self.seq_len.__sizeof__() + self.visited.__sizeof__()
if len(self.start) == 0:
size += self.start.__sizeof__()
else:
for i in range(len(self.start)):
size += sys.getsizeof(self.start[i])
if len(self.end) == 0:
size += self.end.__sizeof__()
else:
for i in range(len(self.end)):
size += sys.getsizeof(self.end[i])
return size