예제 #1
0
def test():
    # TESTS
    ncbi.get_sp_lineage("9606")
    t = ncbi.get_topology([9913,31033,7955,9606,7719,9615,44689,10116,7227,9031,13616,7165,8364,99883,10090,9598])
    ncbi.annotate_tree(t)
    print t.get_ascii(show_internal=True, compact=False)
    t.show()
예제 #2
0
def test():
    # TESTS
    ncbi.get_sp_lineage("9606")
    t = ncbi.get_topology([
        9913, 31033, 7955, 9606, 7719, 9615, 44689, 10116, 7227, 9031, 13616,
        7165, 8364, 99883, 10090, 9598
    ])
    ncbi.annotate_tree(t)
    print t.get_ascii(show_internal=True, compact=False)
    t.show()
예제 #3
0
def annotate_tree_with_taxa(t, name2taxa_file, tax2name=None, tax2track=None):
    if name2taxa_file:
        names2taxid = dict(
            [map(strip, line.split("\t")) for line in open(name2taxa_file)])
    else:
        names2taxid = dict([(n.name, n.name) for n in t.iter_leaves()])

    not_found = 0
    for n in t.iter_leaves():

        n.add_features(taxid=names2taxid.get(n.name, 1))
        n.add_features(species=n.taxid)
        if n.taxid == 1:
            not_found += 1
    if not_found:
        print >> sys.stderr, "WARNING: %s nodes where not found within NCBI taxonomy!!" % not_found

    return ncbi.annotate_tree(t, tax2name, tax2track)
예제 #4
0
파일: ete_ncbicomp.py 프로젝트: daisieh/ete
def annotate_tree_with_taxa(t, name2taxa_file, tax2name=None, tax2track=None):
    if name2taxa_file: 
        names2taxid = dict([map(strip, line.split("\t"))
                            for line in open(name2taxa_file)])
    else:
        names2taxid = dict([(n.name, n.name) for n in t.iter_leaves()])
        
    not_found = 0
    for n in t.iter_leaves():
               
        n.add_features(taxid=names2taxid.get(n.name, 1))
        n.add_features(species=n.taxid)
        if n.taxid == 1:
            not_found += 1
    if not_found:
        print >>sys.stderr, "WARNING: %s nodes where not found within NCBI taxonomy!!" %not_found
      
    return ncbi.annotate_tree(t, tax2name, tax2track)