[Biopython-dev] [Bug 3046] New: PhyloXML, please define get/set methods
bugzilla-daemon at portal.open-bio.org
bugzilla-daemon at portal.open-bio.org
Tue Apr 6 21:46:17 UTC 2010
http://bugzilla.open-bio.org/show_bug.cgi?id=3046
Summary: PhyloXML, please define get/set methods
Product: Biopython
Version: Not Applicable
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P4
Component: Main Distribution
AssignedTo: biopython-dev at biopython.org
ReportedBy: joelb at lanl.gov
It would be nice if there were get/set properties for phyloXML objects that
were easier and more concise to use. Right now, to set, say, a phyloXML
property, one has to read the code to learn the names and arguments of the
Property class and also to learn that properties are added by appending to a
list.
Besides the matter of convenience, there is also a question about how the
properties and taxonomies objects behave. I will take the matter up with the
phyloXML mailing list, but I believe that these objects should be
dictionary-like rather than list-like. That is, duplicate ref values should
not be allowed because the question of how to handle duplicates would have to
get pushed down to the user level and will be inconsistent.
The following convenience methods make a start at these problems, but don't
fully solve them because the current PhyloXML code would have to be reworked to
deliver dictionaries of dictionaries. However, it's better than nothing:
def set_property(self, *propArgs, **propkwArgs):
for property in self.properties:
if property.ref == propArgs[1]:
property = PhyloXML.Property(propArgs)
return
self.properties.append(PhyloXML.Property(*propArgs, **propkwArgs))
def get_property(self, key):
for property in self.properties:
if property.ref == key:
return property.value
raise KeyError
def set_ID(self, *idArgs, **idkwArgs):
self.node_id = PhyloXML.Id(*idArgs, **idkwArgs)
def add_taxonomy(self, *taxArgs, **taxkwArgs):
self.taxonomies.append(PhyloXML.Taxonomy(*taxArgs, **taxkwArgs))
def set_color(node, red, green, blue):
node.color = PhyloXML.BranchColor(red, green, blue)
def get_taxonomy(self, rank):
for taxonomy in self.taxonomies:
if taxonomy.rank == rank:
return taxonomy.scientific_name
raise KeyError
--
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the Biopython-dev
mailing list