-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinfer_tree_from_fasta.py
More file actions
executable file
·54 lines (42 loc) · 1.52 KB
/
infer_tree_from_fasta.py
File metadata and controls
executable file
·54 lines (42 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
if __name__ == '__main__':
import os, sys
if len(sys.argv) < 2:
print "infer_tree_from_fasta.py <fastafile> [--noalign] [--noclean]"
sys.exit(0)
fastafile = sys.argv[1]
alnname = fastafile.rsplit(".fasta",1)[0]
doalign = True
docleannames = True
if len(sys.argv) > 2:
for arg in sys.argv[2:]:
if arg == "--noalign":
doalign = False
elif arg == "--nocleannames":
docleannames = False
if docleannames:
cleanerargs = ["clean_gb_names_simple_fasta.py", fastafile]
os.system(" ".join(cleanerargs))
cleanedfasta = fastafile.rsplit(".fasta",1)[0] + ".cleaned.fasta"
fastatoalign = cleanedfasta
else:
fastatoalign = fastafile
if doalign:
alignedfasta = fastatoalign + ".aligned"
mafftargs = ["mafft", fastatoalign, ">", alignedfasta]
os.system(" ".join(mafftargs))
fastatoconvert = alignedfasta
else:
fastatoconvert = fastatoalign
phylipfile = alnname + ".phy"
fasta2phylipargs = ["fasta2phylip", fastatoconvert, phylipfile]
os.system(" ".join(fasta2phylipargs))
raxmlargs = ["raxmlHPC-PTHREADS-SSE3", \
"-s", phylipfile, \
"-n", alnname, \
"-p", "123", \
"-m", "GTRCAT", \
"-T", "4"]
os.system(" ".join(raxmlargs))
figtreeargs = ["figtree", "RAxML_bestTree." + alnname]
os.system(" ".join(figtreeargs))