Skip to content

Commit

Permalink
Merge branch 'master' into ct-add-bwa-depletion
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkinsc committed Jan 25, 2018
2 parents 0163510 + 67cc4b3 commit 3a4dab9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
5 changes: 4 additions & 1 deletion pipes/WDL/workflows/align_and_plot.wdl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import "tasks/reports.wdl" as reports

workflow align_and_plot {
call reports.plot_coverage
call reports.plot_coverage {
input:
aligner_options = "-r Random -l 30 -g 40 -x 20 -t 502"
}
}
16 changes: 15 additions & 1 deletion pipes/WDL/workflows/tasks/assembly.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,24 @@ task refine_2x_and_plot {
samtools flagstat ${sample_name}.bam | tee ${sample_name}.bam.flagstat.txt
grep properly ${sample_name}.bam.flagstat.txt | cut -f 1 -d ' ' | tee read_pairs_aligned
samtools view ${sample_name}.mapped.bam | cut -f10 | tr -d '\n' | wc -c | tee bases_aligned
expr $(cat bases_aligned) / $(cat assembly_length) | tee mean_coverage
echo $(( $(cat bases_aligned) / $(cat assembly_length) )) | tee mean_coverage

# fastqc mapped bam
reports.py fastqc ${sample_name}.mapped.bam ${sample_name}.mapped_fastqc.html

# plot coverage
if [ $(cat reads_aligned) != 0 ]; then
reports.py plot_coverage \
${sample_name}.mapped.bam \
${sample_name}.coverage_plot.pdf \
--plotFormat pdf \
--plotWidth 1100 \
--plotHeight 850 \
--plotDPI 100 \
--loglevel=DEBUG
else
touch ${sample_name}.coverage_plot.pdf ${sample_name}.mapped_fastqc.html
fi
}

output {
Expand Down
27 changes: 17 additions & 10 deletions pipes/WDL/workflows/tasks/reports.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,31 @@ task plot_coverage {

samtools index ${sample_name}.mapped.bam

reports.py plot_coverage \
${sample_name}.mapped.bam \
${sample_name}.coverage_plot.pdf \
--plotFormat pdf \
--plotWidth 1100 \
--plotHeight 850 \
--plotDPI 100 \
--loglevel=DEBUG

# collect figures of merit
grep -v '^>' assembly.fasta | tr -d '\n' | wc -c | tee assembly_length
grep -v '^>' assembly.fasta | tr -d '\nNn' | wc -c | tee assembly_length_unambiguous
samtools view -c ${sample_name}.mapped.bam | tee reads_aligned
samtools flagstat ${sample_name}.bam | tee ${sample_name}.bam.flagstat.txt
grep properly ${sample_name}.bam.flagstat.txt | cut -f 1 -d ' ' | tee read_pairs_aligned
samtools view ${sample_name}.mapped.bam | cut -f10 | tr -d '\n' | wc -c | tee bases_aligned
expr $(cat bases_aligned) / $(cat assembly_length) | tee mean_coverage
echo $(( $(cat bases_aligned) / $(cat assembly_length) )) | tee mean_coverage

# fastqc mapped bam
reports.py fastqc ${sample_name}.mapped.bam ${sample_name}.mapped_fastqc.html

# plot coverage
if [ $(cat reads_aligned) != 0 ]; then
reports.py plot_coverage \
${sample_name}.mapped.bam \
${sample_name}.coverage_plot.pdf \
--plotFormat pdf \
--plotWidth 1100 \
--plotHeight 850 \
--plotDPI 100 \
--loglevel=DEBUG
else
touch ${sample_name}.coverage_plot.pdf ${sample_name}.mapped_fastqc.html
fi
}

output {
Expand Down

0 comments on commit 3a4dab9

Please sign in to comment.