Mercurial > repos > galaxyp > openms
view build_mods_loc.py @ 6:42b843627623 draft default tip
Uploaded
author | galaxyp |
---|---|
date | Fri, 21 Jun 2013 17:01:53 -0400 |
parents | cf0d72c7b482 |
children |
line wrap: on
line source
#!/usr/bin/env python import xml.etree.ElementTree as ET tree = ET.parse('unimod.xml') ns = '{http://www.unimod.org/xmlns/schema/unimod_2}' modifications_el = tree.getroot().find('%smodifications' % ns) def to_label(title, site): return "%s (%s)" % (title, site) labels = [] for mod in modifications_el.findall('%smod' % ns): for specificity in mod.findall('%sspecificity' % ns): title = mod.get('title') site = specificity.get('site') labels.append(to_label(title, site)) with open("openms_mods.loc", "w") as output: for mod in sorted(labels, key=str.lower): output.write("%s\n" % mod)