Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
QCTable NReads Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
skchronicles committed Aug 29, 2018
1 parent 9f8f08e commit b468c35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 11 additions & 5 deletions Results-template/Scripts/filterMetrics
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import sys
def add(i1, i2):
return int(i1) + int(i2)

def divide(num):
return int(num/4.0)

def getmetadata(type):
metadata = []
Expand All @@ -54,11 +56,11 @@ def getmetadata(type):
elif type == 'nrf':
metadata = ["NRF", "PBC1", "PBC2"]
elif type == 'tnreads':
metadata = 'NumberofReads'
metadata = 'NReads'
elif type == 'mnreads':
metadata = 'NumberofMappedReads'
metadata = 'NMappedReads'
elif type == 'unreads':
metadata = 'NumberofUniquelyMappedReads'
metadata = 'NUniqMappedReads'
return metadata


Expand All @@ -67,8 +69,12 @@ def filteredData(sample, ftype):
linelist = line.strip().split()
if 'reads' in ftype:
mtypes = getmetadata(ftype)
v1, v2 = linelist[0], linelist[1]
print("{}\t{}\t{}".format(sample, mtypes, add(v1,v2)))
if ftype == 'tnreads':
v1 = int(linelist[0])
print("{}\t{}\t{}".format(sample, mtypes, divide(v1)))
else:
v1, v2 = linelist[0], linelist[1]
print("{}\t{}\t{}".format(sample, mtypes, add(v1,v2)))
elif ftype == 'ppqt' or ftype == 'ngsqc' or ftype == 'nrf':
mtypes = getmetadata(ftype)
for i in range(len(linelist)):
Expand Down
4 changes: 3 additions & 1 deletion Rules/InitialChIPseqQC.snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ python {params.nrfscript} {output.preseqlog} > {output.nrf}
rule QCstats:
input:
flagstat=join(workpath,bam_dir,"{name}.sorted.bam.flagstat"),
infq=join(workpath,"{name}.R1.fastq.gz"),
ddflagstat=join(workpath,bam_dir,"{name}.sorted.Q5DD.bam.flagstat"),
nrf=join(workpath,"QC","{name}.nrf"),
ppqt=join(workpath,bam_dir,"{name}.sorted.Q5DD.ppqt"),
Expand All @@ -786,7 +787,8 @@ rule QCstats:
threads: 16
shell: """
# Number of reads
grep 'in total' {input.flagstat} | awk '{{print $1,$3}}' | {params.filterCollate} {wildcards.name} tnreads > {output.sampleQCfile}
#grep 'in total' {input.flagstat} | awk '{{print $1,$3}}' | {params.filterCollate} {wildcards.name} tnreads > {output.sampleQCfile}
zcat {input.infq} | wc -l | {params.filterCollate} {wildcards.name} tnreads > {output.sampleQCfile}
# Number of mapped reads
grep 'mapped (' {input.flagstat} | awk '{{print $1,$3}}' | {params.filterCollate} {wildcards.name} mnreads >> {output.sampleQCfile}
# Number of uniquely mapped reads
Expand Down

0 comments on commit b468c35

Please sign in to comment.