Skip to content
Permalink
3228d4169c
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
39 lines (24 sloc) 884 Bytes
import sys
__bad_fields = ['no_feature', 'ambiguous', 'too_low_aQual', 'not_aligned', 'alignment_not_unique']
def htseq_count_quality(filename, cutoff):
values = []
total_count = 0
with open(filename, "r") as fin:
for l in fin:
gene, count = l.strip().split('\t')
if all([gene not in bf for bf in __bad_fields]):
values.append(int(count))
total_count += int(count)
if total_count == 0:
print("N50 check for", filename, "failed. No reads found")
return False
values.sort(reverse=True)
current_count = 0
for e, v in enumerate(values, start=1):
current_count += v
if current_count > total_count/2:
if e >= cutoff:
return True
break
print("N50 check for", filename, "failed.", e, cutoff)
return False