monosdb = {} f = open(sys.argv[1], 'r') for line in f: k, v = line.split() monosdb[k] = v for g in w.iterglycan(): acc = g.get('accession') monodbids = set() glycan = g.getGlycan() if not glycan: continue for m in glycan.all_nodes(): try: glycoctsym = glycoctformat.mtoStr(m) except KeyError: continue try: monodbids.add(monosdb[glycoctsym]) except KeyError: continue g.delete_annotations(source="EdwardsLab", property="MonosaccharideDB", type="CrossReference") g.set_annotation(value=monodbids, property="MonosaccharideDB", source="EdwardsLab", type="CrossReference") if w.put(g): print acc
#!/bin/env python27 import sys from getwiki import GlycanData w = GlycanData() import findpygly from pygly.CompositionTable import PermethylCompositionTable from pygly.GlycanFormatter import GlycoCTFormat pctable = PermethylCompositionTable() glycoctformat = GlycoCTFormat() for g in w.iterglycan(): glycan = g.getGlycan() if not glycan: continue for m in glycan.all_nodes(): try: eltcomp = m.composition(pctable) except KeyError: print g.get('accession'), glycoctformat.mtoStr(m)
for m in glycan.all_nodes(undet_subst=True): node_count += 1 if node_count == 0: continue if glycan.has_root() and node_count != 1: continue special_node_count_one = False if glycan.has_root() and node_count == 1: r = glycan.root() floating_subst = [] for sl in r.substituent_links(): try: glycoctsym = glycoctformat.mtoStr(sl.child()) except KeyError: continue if sl.parent_pos() != None: continue if glycoctsym in basecomp: sub = sl.child() sub.set_connected(False) r.remove_substituent_link(sl) floating_subst.append(sub) glycan.set_root(None) glycan.set_undetermined([r]+floating_subst) node_count = len(floating_subst)+1 special_node_count_one = True comp = defaultdict(int)