Permalink
Browse files

Only add an edge annotation/branch length if the clade specifies a br…

…anch length.
  • Loading branch information...
1 parent dce183e commit b8b630b3e827235a776a41ac27537be021243593 @bendmorris bendmorris committed Jun 15, 2013
Showing with 11 additions and 10 deletions.
  1. +11 −10 Bio/Phylo/CDAOIO.py
View
@@ -379,16 +379,17 @@ def process_clade(self, clade, parent=None, root=False):
statements += [(nUri(clade.uri), pUri('cdao:has_Ancestor'), nUri(ancestor))
for ancestor in clade.ancestors]
- # add branch length
- edge_ann_uri = 'edge_annotation%s' % str(self.edge_counter).zfill(ZEROES)
-
- branch_length = rdflib.Literal(clade.branch_length, datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#decimal'))
- statements += [
- (nUri(edge_ann_uri), qUri('rdf:type'), qUri('cdao:EdgeLength')),
- (nUri(edge_uri), qUri('cdao:has_Annotation'), nUri(edge_ann_uri)),
- (nUri(edge_ann_uri), qUri('cdao:has_Value'), branch_length),
- ]
-
+ if not clade.branch_length is None:
+ # add branch length
+ edge_ann_uri = 'edge_annotation%s' % str(self.edge_counter).zfill(ZEROES)
+
+ branch_length = rdflib.Literal(clade.branch_length, datatype=rdflib.URIRef('http://www.w3.org/2001/XMLSchema#decimal'))
+ statements += [
+ (nUri(edge_ann_uri), pUri('rdf:type'), pUri('cdao:EdgeLength')),
+ (nUri(edge_uri), pUri('cdao:has_Annotation'), nUri(edge_ann_uri)),
+ (nUri(edge_ann_uri), pUri('cdao:has_Value'), branch_length),
+ ]
+
try: edge_attributes = clade.edge_attributes
except AttributeError: edge_attributes = []

0 comments on commit b8b630b

Please sign in to comment.