This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
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?
thesis_tm/Node.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34 lines (28 sloc)
1.1 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |