view build_mods_loc.py @ 5:9816d9abb501 draft

Added repo dependencies
author galaxyp
date Thu, 20 Jun 2013 16:12:09 -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)