Permalink
Browse files

Better tree URIs; avoid duplicating the tree ID.

  • Loading branch information...
1 parent 96e9f2f commit 8a2ae755169457fd1882b66adcf8a812ebac794f @bendmorris bendmorris committed with etal Feb 19, 2013
Showing with 5 additions and 4 deletions.
  1. +5 −4 Bio/Phylo/CDAOIO.py
View
9 Bio/Phylo/CDAOIO.py
@@ -357,6 +357,7 @@ def process_clade(self, clade, parent=None, root=False):
else: clade.ancestors = []
nUri = lambda s: node_uri(self.tree_uri, s)
+ tree_id = nUri('')
Uri = RDF.Uri
statements = []
@@ -366,8 +367,8 @@ def process_clade(self, clade, parent=None, root=False):
tree_type = qUri('cdao:RootedTree') if self.rooted else qUri('cdao:UnrootedTree')
statements += [
- (nUri(self.tree_uri), qUri('rdf:type'), tree_type),
- (nUri(self.tree_uri), qUri('cdao:has_Root'), nUri(clade.uri)),
+ (tree_id, qUri('rdf:type'), tree_type),
+ (tree_id, qUri('cdao:has_Root'), nUri(clade.uri)),
]
if clade.name:
@@ -388,7 +389,7 @@ def process_clade(self, clade, parent=None, root=False):
node_type = 'cdao:TerminalNode' if clade.is_terminal() else 'cdao:AncestralNode'
statements += [
(nUri(clade.uri), qUri('rdf:type'), qUri(node_type)),
- (nUri(clade.uri), qUri('cdao:belongs_to_Tree'), nUri(self.tree_uri)),
+ (nUri(clade.uri), qUri('cdao:belongs_to_Tree'), tree_id),
]
if not parent is None:
@@ -398,7 +399,7 @@ def process_clade(self, clade, parent=None, root=False):
statements += [
(nUri(edge_uri), qUri('rdf:type'), qUri('cdao:DirectedEdge')),
- (nUri(edge_uri), qUri('cdao:belongs_to_Tree'), nUri(self.tree_uri)),
+ (nUri(edge_uri), qUri('cdao:belongs_to_Tree'), tree_id),
(nUri(edge_uri), qUri('cdao:has_Parent_Node'), nUri(parent.uri)),
(nUri(edge_uri), qUri('cdao:has_Child_Node'), nUri(clade.uri)),
(nUri(clade.uri), qUri('cdao:belongs_to_Edge_as_Child'), nUri(edge_uri)),

0 comments on commit 8a2ae75

Please sign in to comment.