@@ -28,34 +28,35 @@ def readMultiple(indir, outfile):
2828 transcript = filename .split ("." )[0 ]
2929 species = filename .split ("." )[1 ]
3030 if int (species ) > 2 :
31- with open (infile , "r" ) as mlc :
32- for line in mlc :
33- # Get substitution rates, tree lengths, etc
34- if "tree length =" in line :
35- length = line .split ("=" )[1 ].strip ()
36- elif "tree length for dN" in line :
37- dn = line .split (":" )[1 ].strip ()
38- elif "tree length for dS" in line :
39- ds = line .split (":" )[1 ].strip ()
40- elif "lnL" in line :
41- lnl = line .split ("):" )[1 ]
42- lnl = lnl .split ()[0 ].strip ()
43- # Calculate dN/dS and save as a string
4431 try :
45- dnds = str (float (dn )/ float (ds ))
46- except ZeroDivisionError :
47- dnds = "NA"
48- # Append data to list and convert into string
49- data = [dn , ds , dnds , length , lnl , species ]
50- transcript += ","
51- for i in data :
52- transcript += str (i ) + ","
53- transcript = transcript [:- 1 ]
54- output .write (transcript + "\n " )
32+ with open (infile , "r" ) as mlc :
33+ for line in mlc :
34+ # Get substitution rates, tree lengths, etc
35+ if "tree length =" in line :
36+ length = line .split ("=" )[1 ].strip ()
37+ elif "tree length for dN" in line :
38+ dn = line .split (":" )[1 ].strip ()
39+ elif "tree length for dS" in line :
40+ ds = line .split (":" )[1 ].strip ()
41+ elif "lnL" in line :
42+ lnl = line .split ("):" )[1 ]
43+ lnl = lnl .split ()[0 ].strip ()
44+ # Calculate dN/dS and save as a string
45+ try :
46+ dnds = str (float (dn )/ float (ds ))
47+ except ZeroDivisionError :
48+ dnds = "NA"
49+ # Append data to list and convert into string
50+ data = [dn , ds , dnds , length , lnl , species ]
51+ transcript += ","
52+ for i in data :
53+ transcript += str (i ) + ","
54+ transcript = transcript [:- 1 ]
55+ output .write (transcript + "\n " )
5556 else :
5657 # Skip files with only two sequences
5758 pass
58- except IsADirectoryError :
59+ except IsADirectoryError , UnboundLocalError :
5960 pass
6061
6162def readPairwise (indir , outfile ):
0 commit comments