Commit 2e8a3cdf authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

SystemInfo is now mutable

replace namedtuple SystemInfo by an object
as we need to mutate it
some information (system_status, and predicted_system are
known after the creation of new system occurrence
when the parser encounter a gene belonging a system not neighbor genes
parent 2d02f2dd
......@@ -63,7 +63,17 @@ def system_parser(system_data):
system_db = {}
System_info = namedtuple('System_info', 'code, predicted_system, system_status, replicon, genes')
class System_info(object):
def __init__(self, code, predicted_system, system_status, replicon, genes):
self.code = code
self.predicted_system = predicted_system
self.system_status = system_status
self.replicon = replicon
self.genes = genes
#System_info = namedtuple('System_info', 'code, predicted_system, system_status, replicon, genes')
Gene = namedtuple('Gene',
('code', 'id', 'protein_length', 'strand', 'begin', 'end', 'match',
'score', 'i_evalue', 'coverage', 'match_begin', 'match_end', 'name', 'description')
......@@ -123,8 +133,13 @@ def system_parser(system_data):
# append this gene to System_info genes
system_db[system_id].genes[gene.code] = gene
if predicted_system is not None and system_db[system_id].predicted_system is None:
system_db[system_id].predicted_system = predicted_system
if system_status is not None and system_db[system_id].system_status is None:
system_db[system_id].system_status = system_status
# create a new System_info entry
print("@@@ create new System_info",system_id, predicted_system, system_status, replicon_id)
system_db[system_id] = System_info(system_id, predicted_system, system_status,
replicon_id, genes={gene.code: gene})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment