Exemplo n.º 1
0
    def __init__(self):
        sys.stderr.write("Parsing the taxonomy files\n")
        self.taxa = taxon.readNodes()
        self.names, self.blastname, self.genbankname, self.synonym = taxon.extendedNames(
        )
        self.divs = taxon.readDivisions()
        sys.stderr.write("Done parsing the taxonomy\n")

        self.wanted = [
            'species', 'genus', 'family', 'order', 'class', 'phylum',
            'superkingdom'
        ]

        self.taxonomy = {}
        self.nc2tax = {}
Exemplo n.º 2
0
try:
    inputF = sys.argv[1]
except:
    sys.exit(
        sys.argv[0] +
        " <file of taxon ids separated with tabs (phage in first column)>")

wanted = [
    'species', 'genus', 'family', 'order', 'class', 'phylum', 'superkingdom'
]
match = {w: 0 for w in wanted}
mismatch = {w: 0 for w in wanted}

taxa = taxon.readNodes()
names, blastname, genbankname, synonym = taxon.extendedNames()
divs = taxon.readDivisions()

with open(inputF, 'r') as inf:
    for line in inf:
        line = line.strip()
        hosts = line.split('\t')
        phage = hosts.pop(0)
        taxonomy = {}
        taxonomy[phage] = {}
        for h in hosts:
            taxonomy[h] = {}

        if phage not in taxa:
            sys.stderr.write("SKIPPED: Phage " + str(phage) +
                             " not found in the taxonomy\n")
            continue
Exemplo n.º 3
0
import sys
import taxon

## run this as a script
if __name__ == "__main__":
    ids=['1211997']
    if len(sys.argv) == 1:
        print "Supply your own id for the tree. Here is an example"
    else:
        ids=sys.argv[1:]

    taxa = taxon.readNodes()
    names,blastname = taxon.readNames()
    divs = taxon.readDivisions()
    for i in ids:
        c=0
        if i not in taxa:
            sys.stderr.write("Error: ID " + str(i) + " was not found in the taxonomy filei\n")
            sys.exit(0)
        while taxa[i].parent != '1' and i != '1':
            #print " " * c, taxa[i].taxid, "name:", names[i].name, "rank:", taxa[i].rank, "div:", taxa[i].division, "code:", divs[taxa[i].division].code
            bn=names[i].name
            if i in blastname:
                bn=blastname[i].name
            print taxa[i].taxid, "name:", names[i].name, "blast name", bn, "rank:", taxa[i].rank, "parent: ", taxa[i].parent
            i=taxa[i].parent
            c+=1
        print