Skip to content

Commit ff06d1e

Browse files
committed
changed a variable and made file conformant to PEP8
1 parent 31b9bee commit ff06d1e

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

4Pipe4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def DiscoveryTCS(basefile):
237237
CAF_to_TCS.RunModule(basefile + '_assembly/' + miraproject
238238
+ '_d_results/' + miraproject + '_out.caf')
239239
TCS.RunModule(basefile + '_assembly/' + miraproject + '_d_results/'
240-
+ miraproject + '_out.tcs',
240+
+ miraproject + '_out.tcs', basefile + '_out.short.tcs'
241241
int(config.get('Variables', 'minqual')),
242242
int(config.get('Variables', 'mincov')))
243243

TCSfilter.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,57 @@
1616

1717
from math import ceil
1818

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:
19+
20+
def ListParser(infile_name, minqual, mincov):
21+
'''Discards every line in the TCS file with a coverage below mincov and
22+
a qual below minqual'''
23+
TCS = open(infile_name, 'r')
24+
if TCS.readline().startswith("#TCS") is False:
2425
quit("Invalid input file. Use a TCS file as input.")
2526
else:
26-
for i in range(3): TCS.readline() #Skip header
27-
27+
for i in range(3):
28+
TCS.readline() # Skip header
29+
2830
passed = []
2931
for lines in TCS:
3032
line = lines.split('|')
3133
tcov = int(line[2][:5])
3234
covs = line[2][5:].strip().split()
3335
covs = sorted(list(map(int, covs)))
34-
if tcov <= mincov: #Discard positions with less than mincov
36+
if tcov <= mincov: # Discard positions with less than mincov
37+
pass
38+
elif int(lines.split()[12]) >= tcov//2: # Discard pos with many gaps
3539
pass
36-
elif int(lines.split()[12]) >= tcov//2: #Discard positions with many gaps
37-
pass
38-
elif covs[-2] <= (ceil(tcov*0.2)): #Discard insufficient second variant
40+
elif covs[-2] <= (ceil(tcov * 0.2)): # Discard low freq second variant
3941
pass
4042
else:
41-
quals = line[3].replace('--','0')
43+
quals = line[3].replace('--', '0')
4244
quallist = quals.strip().split()
4345
quallist = sorted(list(map(int, quallist)))
44-
if quallist[-2] >= minqual: #Filter by quality
46+
if quallist[-2] >= minqual: # Filter by quality
4547
passed.append(lines)
4648

4749
TCS.close()
4850
return passed
4951

50-
def ListWriter(infile_name,passed):
51-
"""Write the selected list into a file."""
52-
outfile = open((infile_name[0:-4] + '.short.tcs'),'w')
52+
53+
def ListWriter(infile_name, outfile_name, passed):
54+
'''Write the selected list into a file.'''
55+
outfile = open(outfile_name, 'w')
5356
outfile.write("#TCS V1.0\n")
5457
outfile.write("#\n")
55-
outfile.write("# contig name\t\t\tpadPos\tupadPos| B Q |\ttcov covA covC covG covT cov* | qA qC qG qT q* | S |\tTags\n")
58+
outfile.write("# contig name\t\t\tpadPos\tupadPos| B Q |\ttcov covA \
59+
covC covG covT cov* | qA qC qG qT q* | S |\tTags\n")
5660
outfile.write("#\n")
5761
for lines in passed:
5862
outfile.write(lines)
5963
outfile.close()
6064

61-
def RunModule(infile_name,minqual,mincov):
62-
"""Run the module."""
63-
ShortList = ListParser(infile_name,minqual,mincov)
64-
ListWriter(infile_name,ShortList)
6565

66-
#RunModule("/home/francisco/Programming/454/Scripts/ORF/test.tcs", 70, 15)
66+
def RunModule(infile_name, outfile_name, minqual, mincov):
67+
'''Run the module.'''
68+
ShortList = ListParser(infile_name, minqual, mincov)
69+
ListWriter(infile_name, outfile_name, ShortList)
70+
71+
72+
#RunModule("/home/francisco/Programming/454/Scripts/ORF/test.tcs", 70, 15)

0 commit comments

Comments
 (0)