Skip to content
This repository
Browse code

Storing complete ancestry in RDF requires a lot of time and space for…

… large trees. This is now optional but disabled by default. Queries to find common ancestors can use has_Parent as a transitive property instead.
  • Loading branch information...
commit 45fec141c852dee975d81dd484409e50d6543829 1 parent ca5930c
Ben Morris bendmorris authored etal committed

Showing 1 changed file with 4 additions and 16 deletions. Show diff stats Hide diff stats

  1. +4 16 Bio/Phylo/CDAOIO.py
20 Bio/Phylo/CDAOIO.py
@@ -279,7 +279,8 @@ def __init__(self, trees):
279 279 self.tu_counter = 0
280 280 self.tree_counter = 0
281 281
282   - def write(self, handle, **kwargs):
  282 + def write(self, handle, mime_type='text/turtle', tree_uri='tree', context=None,
  283 + storage=None, record_complete_ancestry=False):
283 284 """Write this instance's trees to a file handle.
284 285
285 286 Keywords:
@@ -288,17 +289,7 @@ def write(self, handle, **kwargs):
288 289 """
289 290 RDF = import_rdf()
290 291
291   - try: mime_type = kwargs['mime_type']
292   - except KeyError: mime_type = 'text/turtle'
293   -
294   - try: tree_uri = kwargs['tree_uri']
295   - except KeyError: tree_uri = 'tree'
296   -
297   - try: context = kwargs['context']
298   - except KeyError: context=None
299   -
300   - try: storage = kwargs['storage']
301   - except KeyError: storage = None
  292 + self.record_complete_ancestry = record_complete_ancestry
302 293
303 294 self.add_trees_to_model(storage=storage, tree_uri=tree_uri, context=context)
304 295 if storage is None: self.serialize_model(handle, mime_type=mime_type)
@@ -430,10 +421,7 @@ def process_clade(self, clade, parent=None, root=False):
430 421 statements += [(nUri(clade.uri), qUri('cdao:has_Support_Value'), confidence)]
431 422
432 423
433   - if len(clade.ancestors) > 0:
434   - #ancestors = RDF.Node(literal=str(len(clade.ancestors)),
435   - # datatype=RDF.Uri('http://www.w3.org/2001/XMLSchema#integer'))
436   - #statements += [(nUri(clade.uri), qUri('cdao:has_Ancestor'), ancestors)]
  424 + if self.record_complete_ancestry and len(clade.ancestors) > 0:
437 425 statements += [(nUri(clade.uri), qUri('cdao:has_Ancestor'), nUri(ancestor))
438 426 for ancestor in clade.ancestors]
439 427

0 comments on commit 45fec14

Please sign in to comment.
Something went wrong with that request. Please try again.