Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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)
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)