コード例 #1
0
ファイル: ete_ncbiquery.py プロジェクト: daisieh/ete
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
ファイル: ete_ncbiquery.py プロジェクト: daisieh/ete
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)