Changeset 627


Ignore:
Timestamp:
10/26/16 19:13:26 (8 years ago)
Author:
konrad
Message:

tree-genealogy.py is now supporting multiple virtual parents (they are merged into one virtual parent)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mds-and-trees/tree-genealogy.py

    r626 r627  
    6464                'width': {
    6565                    'meaning': 'adepth',
    66                     'start': 1,
     66                    'start': 0.1,
    6767                    'end': 4,
    6868                    'bias': 3
     
    585585        ids = {}
    586586        def get_id(id):
    587             if not id in ids:
     587            if id not in ids:
    588588                ids[id] = len(ids)
    589589            return ids[id]
     
    624624                        # make sure that ID's of parents are lower than that of their children
    625625                        for i in range(0, len(creature["FromIDs"])):
    626                             get_id(creature["FromIDs"][i])
     626                            if creature["FromIDs"][i] not in ids:
     627                                get_id("virtual_parent")
    627628
    628629                        creature_id = get_id(creature["ID"])
     
    635636                        # we assign to each parent its contribution to the genotype of the child
    636637                        for i in range(0, len(creature["FromIDs"])):
    637                             parent_id = get_id(creature["FromIDs"][i])
     638                            if creature["FromIDs"][i] in ids:
     639                                parent_id = get_id(creature["FromIDs"][i])
     640                            else:
     641                                parent_id = get_id("virtual_parent")
    638642                            inherited = 1 #(creature["Inherited"][i] if 'Inherited' in creature else 1) #ONLY FOR NOW
    639643                            self.parents[creature_id][parent_id] = inherited
Note: See TracChangeset for help on using the changeset viewer.