Skip to content

Commit

Permalink
catered for parent(s)' identity to be recorded in offspring(s)' statu…
Browse files Browse the repository at this point in the history
…s as status['parents']
  • Loading branch information
mauriceling committed Oct 19, 2013
1 parent 58038c8 commit 96092be
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions dose/database_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ def db_reconstruct_organisms(cur, start_time, population_name, generation):
exec("org.status['alive'] = %s" % str(value))
elif key == 'vitality':
org.status['vitality'] = float(value)
elif key == 'parents':
if value == '': value = '[]'
else: value = value.split('|')
exec("org.status['parents'] = %s" % str(value))
elif key == 'age':
org.status['age'] = float(value)
elif key == 'gender':
Expand Down
5 changes: 4 additions & 1 deletion dose/dose.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def mating(self, Populations, pop_name):
- to manage mating scheme and progeny (offspring) generation
for the entire population
- add or replace offsprings into the respective population(s)
- (optional) store identity of parent(s) as list; for example,
[parentA identity, parentB identity], in offspring's
status['parents'] for ancestral tracing.
@param Populations: A dictionary containing one or more populations
where the value is a genetic.Population object.
Expand Down Expand Up @@ -375,7 +378,7 @@ def database_report_populations(con, cur, start_time,
# log each item in Organism.status dictionary
for key in [key for key in org.status.keys()
if key != 'identity']:
if key in ('blood', 'location'):
if key in ('blood', 'location', 'parents'):
try:
# TypeError will occur when genome/chromosomes are
# not interpreted
Expand Down
1 change: 1 addition & 0 deletions dose/genetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def __init__(self, genome='dummy', mutation_type='point',
"""
self.status = {'alive': True, # is the organism alive?
'vitality': 100.0, # % of vitality
'parents': None, # identity of parent(s)
'age': 0.0, # age of the organism
'gender': None, # gender of organism
'lifespan': 100.0, # maximum lifespan
Expand Down

0 comments on commit 96092be

Please sign in to comment.