1616
1717from math import ceil
1818
19- def TCSParser (infile_name ):
20- #Parses the TCS file
21- infile = open (infile_name ,'r' )
22- if infile .readline ().startswith ("#TCS" ) == False :
19+ def ListParser (infile_name ,minqual ,mincov ):
20+ """Discards every line in the TCS file with a coverage below mincov and a qual
21+ below minqual"""
22+ TCS = open (infile_name ,'r' )
23+ if TCS .readline ().startswith ("#TCS" ) == False :
2324 quit ("Invalid input file. Use a TCS file as input." )
2425 else :
25- TCS = []
26- for i in range (3 ): infile .readline () #Skip header
27-
28- for lines in infile :
29- TCS .append (lines )
30-
31- infile .close ()
32- return TCS
33-
34- def ListParser (TCS ,minqual ,mincov ):
35- #Discards every line in the TCS file with a coverage below mincov and a qual
36- #below minqual
26+ for i in range (3 ): TCS .readline () #Skip header
27+
3728 passed = []
3829 for lines in TCS :
3930 line = lines .split ('|' )
@@ -53,10 +44,11 @@ def ListParser(TCS,minqual,mincov):
5344 if quallist [- 2 ] >= minqual : #Filter by quality
5445 passed .append (lines )
5546
47+ TCS .close ()
5648 return passed
5749
5850def ListWriter (infile_name ,passed ):
59- # Write the selected list into a file.
51+ """ Write the selected list into a file."""
6052 outfile = open ((infile_name [0 :- 4 ] + '.short.tcs' ),'w' )
6153 outfile .write ("#TCS V1.0\n " )
6254 outfile .write ("#\n " )
@@ -67,9 +59,8 @@ def ListWriter(infile_name,passed):
6759 outfile .close ()
6860
6961def RunModule (infile_name ,minqual ,mincov ):
70-
71- TCS = TCSParser (infile_name )
72- ShortList = ListParser (TCS ,minqual ,mincov )
62+ """Run the module."""
63+ ShortList = ListParser (infile_name ,minqual ,mincov )
7364 ListWriter (infile_name ,ShortList )
7465
75- #RunModule("/home/francisco/Desktop/4PipeTest/TestData_assembly/TestData_d_results/TestData_out .tcs", 70, 15)
66+ #RunModule("/home/francisco/Programming/454/Scripts/ORF/test .tcs", 70, 15)
0 commit comments