[Biopython-dev] Search/get method preference for Bio.KEGG.KGML.KGML_pathway.py

Leighton Pritchard leightonpritchard at mac.com
Tue Dec 23 22:31:46 UTC 2014


Hi all,

In putting together introductory notes for using the KGML Pathway class, I really noticed the lack of a method to identify/select an Element from the Pathway. To fill the glaring gap, I’d like to implement a method, along the following lines:

pathway = KGML_parser.read(filehandle)

# Elements are identified in KGML files by unique integers; overload to accept string or list
e = pathway.get_element(element_id)
e_mult = pathway.get_element([id1, id2])

# Restrict returned type of element to, say, compound by type argument
c1 = pathway.get_element(element_id, type=‘compound')
c_mult1 = pathway.get_element([id1, id2], type=‘compound')

# Also, specific methods such as get_compound fetch ‘compound’ elements, e.g. by calling get_element internally
c2 = pathway.get_compound(element_id)
c_mult2 = pathway.get_compound([id1, id2])

# Names are more natural ways to represent elements, and are retrievable via KEGG.REST module functions
# Elements are identified in KGML files by unique integers; overload to accept string or list
e = pathway.get_element_by_name(’name')
e_mult = pathway.get_element_by_name([’name1’, ’name2'])

# And similar methods for retrieving compounds:
c2 = pathway.get_compound_by_name(’name')
c_mult2 = pathway.get_compound_by_name([’name1’, ’name2'])


Before I make a start, does anyone on here have any comments/suggestions for the interface? I considered an index-like approach (pathway.element[’name’]), but I’d like the flexibility to provide a list of names/IDs - I can imagine circumstances where I’d want to highlight several elements.


Cheers,

L.

-- 
Leighton Pritchard
leightonpritchard at mac.com
gpg/pgp:0xDECACFFC



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython-dev/attachments/20141223/14a4f08f/attachment.html>


More information about the Biopython-dev mailing list