|
@@ 233-251 (lines=19) @@
|
| 230 |
|
self._traverse_relationship_rev_objs(rel2dst2srcs, goobj_src, goids_seen) |
| 231 |
|
return rel2dst2srcs |
| 232 |
|
|
| 233 |
|
def _traverse_relationship_rev_objs(self, rel2dst2srcs, goobj_parent, goids_seen): |
| 234 |
|
"""Traverse from source GO down children.""" |
| 235 |
|
parent_id = goobj_parent.id |
| 236 |
|
goids_seen.add(parent_id) |
| 237 |
|
##A self.go2obj[parent_id] = goobj_parent |
| 238 |
|
# Update goids_seen and go2obj with parent alt_ids |
| 239 |
|
for goid_altid in goobj_parent.alt_ids: |
| 240 |
|
goids_seen.add(goid_altid) |
| 241 |
|
##A self.go2obj[goid_altid] = goobj_parent |
| 242 |
|
# Loop through children |
| 243 |
|
for reltype, recs in goobj_parent.relationship.items(): |
| 244 |
|
if reltype in self.relationships: |
| 245 |
|
for relrev_obj in recs: |
| 246 |
|
relrev_id = relrev_obj.id |
| 247 |
|
rel2dst2srcs[relrev_id].add(parent_id) |
| 248 |
|
# If child has not been seen, traverse |
| 249 |
|
if relrev_id not in goids_seen: |
| 250 |
|
##F self._traverse_relrev_objs(rel2dst2srcs, relrev_obj, go2obj, goids_seen) |
| 251 |
|
self._traverse_relationship_rev_objs(rel2dst2srcs, relrev_obj, goids_seen) |
| 252 |
|
|
| 253 |
|
# ------------------------------------------------------------------- |
| 254 |
|
def _init_p2cs(self, go_sources, traverse_parent): |
|
@@ 200-217 (lines=18) @@
|
| 197 |
|
self._traverse_relationship_objs(rel2src2dsts, goobj_src, goids_seen) |
| 198 |
|
return rel2src2dsts |
| 199 |
|
|
| 200 |
|
def _traverse_relationship_objs(self, rel2src2dsts, goobj_child, goids_seen): |
| 201 |
|
"""Traverse from source GO up relationships.""" |
| 202 |
|
child_id = goobj_child.id |
| 203 |
|
goids_seen.add(child_id) |
| 204 |
|
##A self.go2obj[child_id] = goobj_child |
| 205 |
|
# Update goids_seen and go2obj with child alt_ids |
| 206 |
|
for goid_altid in goobj_child.alt_ids: |
| 207 |
|
goids_seen.add(goid_altid) |
| 208 |
|
##A self.go2obj[goid_altid] = goobj_child |
| 209 |
|
# Loop through relationships of child object |
| 210 |
|
for reltype, recs in goobj_child.relationship.items(): |
| 211 |
|
if reltype in self.relationships: |
| 212 |
|
for relationship_obj in recs: |
| 213 |
|
relationship_id = relationship_obj.id |
| 214 |
|
rel2src2dsts[reltype][relationship_id].add(child_id) |
| 215 |
|
# If relationship has not been seen, traverse |
| 216 |
|
if relationship_id not in goids_seen: |
| 217 |
|
self._traverse_relationship_objs(rel2src2dsts, relationship_obj, goids_seen) |
| 218 |
|
|
| 219 |
|
# ------------------------------------------------------------------- |
| 220 |
|
def _init_rel2dst2srcs(self, go_sources, traverse_child): |