#!/bin/env python27 import re, sys from getwiki import GlycanData w = GlycanData() for g in w.iterglycanid(): print g
#!/bin/env python2 import re, sys from getwiki import GlycanData from collections import defaultdict headers = """ accession Hex HexNAc dHex NeuAc NeuGc HexA HexN S P aldi Xxx X Count """.split() w = GlycanData() print "\t".join(headers) for acc in w.iterglycanid(): g = w.get(acc) row = defaultdict(lambda: [0, False]) row['accession'] = (acc, False) for ann in g.annotations(type="MonosaccharideCount", source="EdwardsLab"): try: value = [int(ann.get('value')), False] except ValueError: value = [int(ann.get('value')[:-1]), True] prop = ann.get('property') if prop.endswith('Count'): prop = prop[:-5] row[prop] = value # print row row['Count'] = row['Monosaccharide'] if 'Xxx' not in row: row['Xxx'] = [0, False] for k in row: