2
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import xml.etree.ElementTree as ET
|
|
4
|
|
5 tree = ET.parse('unimod.xml')
|
|
6 ns = '{http://www.unimod.org/xmlns/schema/unimod_2}'
|
|
7 modifications_el = tree.getroot().find('%smodifications' % ns)
|
|
8
|
|
9
|
|
10 def to_label(title, site):
|
|
11 return "%s (%s)" % (title, site)
|
|
12
|
|
13
|
|
14 labels = []
|
|
15 for mod in modifications_el.findall('%smod' % ns):
|
|
16 for specificity in mod.findall('%sspecificity' % ns):
|
|
17 title = mod.get('title')
|
|
18 site = specificity.get('site')
|
|
19 labels.append(to_label(title, site))
|
|
20
|
|
21 with open("openms_mods.loc", "w") as output:
|
|
22 for mod in sorted(labels, key=str.lower):
|
|
23 output.write("%s\n" % mod)
|