Beispiel #1
0
gtc2taxid = defaultdict(lambda: defaultdict(set))
for f in sys.argv[1:]:
    for l in open(f):
        sl = l.split()
        gtc = sl[0]
        taxid = int(sl[1])
        source = sl[2]
        if len(sl) > 3:
            sourceid = sl[3]
        else:
            sourceid = None
        gtc2taxid[gtc][(source, sourceid)].add(taxid)
        allsources.add(source)

for m in w.iterglycan():
    start = time.time()
    acc = m.get('accession')

    for source in allsources:
        m.delete_annotations(source=source,
                             property="Taxonomy",
                             type="Taxonomy")

    for source, sourceid in gtc2taxid[acc]:
        m.set_annotation(value=list(gtc2taxid[acc][(source, sourceid)]),
                         property="Taxonomy",
                         source=source,
                         sourceid=sourceid,
                         type="Taxonomy")
Beispiel #2
0
            print "\t".join([acc, "Alignment", alignment])
            print "\t".join([acc, "MotifGlyTouCan", gtcacc])
            print "\t".join([acc, "ReducingEnd", redend])
            for i, pmid in enumerate(sorted(pmids, key=int)):
                print "\t".join([acc, "PMID", pmid])
            for i, kw in enumerate(sorted(keywords)):
                print "\t".join([acc, "Keyword", kw])
            for i, xr in enumerate(sorted(dbxrefs)):
                print "\t".join([acc, "CrossRef", xr])
        allmotifdata[acc] = dict(alignment=alignment, label=names[0])

if allmotifs:
    sys.exit(0)

print "\t".join(["GlyTouCanAccession", "MotifAccession", "Label", "Alignment"])
for g in w.iterglycan():

    acc = g.get('accession')

    motifs = set()
    for coll in collections:
        motifs.update(
            map(
                itemgetter(0),
                filter(lambda t: t[0] in allmotifdata and t[1],
                       gm.getmotif(coll, acc))))

    for motifacc in sorted(motifs):
        print "\t".join([
            acc, motifacc, allmotifdata[motifacc]['label'],
            allmotifdata[motifacc]['alignment']