Mercurial > repos > galaxyp > openms
comparison build_mods_loc.py @ 2:cf0d72c7b482 draft
Update.
author | galaxyp |
---|---|
date | Fri, 10 May 2013 17:31:05 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:5c65f8116244 | 2:cf0d72c7b482 |
---|---|
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) |