How to use the newick.Newick_Tree function in newick

To help you get started, we’ve selected a few newick examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github linsalrob / crAssphage / Analysis / bin / rename_trees.py View on Github external
tagdata = {t[0]:t[1] for t in m}
                if args.n.lower() in tagdata:
                    tagcount[tagdata[args.n]] = tagcount.get(tagdata[args.n], 0)+1
                    idmap[p[0]] = "_".join(map (str, [tagdata[args.n], tagcount[tagdata[args.n]]]))
                else:
                    if args.n.lower() != 'id':
                        sys.stderr.write("No {} data found in sample: {}\n".format(args.n, l.strip()))
                    idmap[p[0]] = p[1].split()[0]


    tre = []
    with open(args.t, 'r') as f:
        for l in f:
            tre.append(l.strip())

    root = Newick_Tree().parse(''.join(tre))
    root = rename_nodes(root, idmap)
    Newick_Tree().print_tree(root)
github linsalrob / crAssphage / Analysis / bin / rename_trees.py View on Github external
tagcount[tagdata[args.n]] = tagcount.get(tagdata[args.n], 0)+1
                    idmap[p[0]] = "_".join(map (str, [tagdata[args.n], tagcount[tagdata[args.n]]]))
                else:
                    if args.n.lower() != 'id':
                        sys.stderr.write("No {} data found in sample: {}\n".format(args.n, l.strip()))
                    idmap[p[0]] = p[1].split()[0]


    tre = []
    with open(args.t, 'r') as f:
        for l in f:
            tre.append(l.strip())

    root = Newick_Tree().parse(''.join(tre))
    root = rename_nodes(root, idmap)
    Newick_Tree().print_tree(root)
github linsalrob / crAssphage / bin / negative_branch_lengths.py View on Github external
parser = argparse.ArgumentParser(description='Parse a tree and correct negative branch lengths')
    parser.add_argument('-t', help='tree file', required=True)
    parser.add_argument('-v', help='verbose output', action='store_true')
    args = parser.parse_args()

    tre = []
    with open(args.t, 'r') as f:
        for l in f:
            tre.append(l.strip())

    root = Newick_Tree().parse(''.join(tre))
    if args.v:
        sys.stderr.write("NEGATIVE NODES:\n")
        find_negative(root)
    correct_negative(root)
    Newick_Tree().print_tree(root)
github linsalrob / crAssphage / bin / negative_branch_lengths.py View on Github external
correct_negative(node.left)
    if node.right:
        correct_negative(node.right)

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Parse a tree and correct negative branch lengths')
    parser.add_argument('-t', help='tree file', required=True)
    parser.add_argument('-v', help='verbose output', action='store_true')
    args = parser.parse_args()

    tre = []
    with open(args.t, 'r') as f:
        for l in f:
            tre.append(l.strip())

    root = Newick_Tree().parse(''.join(tre))
    if args.v:
        sys.stderr.write("NEGATIVE NODES:\n")
        find_negative(root)
    correct_negative(root)
    Newick_Tree().print_tree(root)

newick

A python module to read and write the Newick format

Apache-2.0
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages