Skip to content

Commit

Permalink
auto trim length
Browse files Browse the repository at this point in the history
  • Loading branch information
Kincekara committed Nov 17, 2023
1 parent 4d8f2c9 commit e2154df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion tasks/task_fastp.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ command <<<
# parse output
jq -r '.summary.fastp_version' fastp.json > VERSION
jq '.summary.before_filtering.total_bases' fastp.json > total_bases.txt
jq '.summary.after_filtering.total_bases' fastp.json >> total_bases.txt
jq '.summary.after_filtering.total_bases' fastp.json >> total_bases.txt
jq '.read1_before_filtering.total_reads' fastp.json > R1_READS
jq '.read2_before_filtering.total_reads' fastp.json > R2_READS
jq '.summary.before_filtering.total_reads' fastp.json > TOTAL_READS
jq '.summary.after_filtering.total_reads' fastp.json > TOTAL_READS_TRIM


r1_q30=$(jq '.read1_before_filtering.q30_bases' fastp.json)
r1_total=$(jq '.read1_before_filtering.total_bases' fastp.json)
Expand All @@ -77,6 +78,9 @@ command <<<
r1_total_trim=$(jq '.read1_after_filtering.total_bases' fastp.json)
r2_q30_trim=$(jq '.read2_after_filtering.q30_bases' fastp.json)
r2_total_trim=$(jq '.read2_after_filtering.total_bases' fastp.json)

echo $(($(jq '.summary.before_filtering.read1_mean_length' fastp.json) + 1 )) > read_length.txt


if [ "$r1_total_trim" -gt 0 ]
then
Expand Down Expand Up @@ -107,6 +111,7 @@ output {
Int total_reads_trim = read_int("TOTAL_READS_TRIM")
Int r1_reads = read_int("R1_READS")
Int r2_reads = read_int("R2_READS")
Int read_length = read_int("read_length.txt")
Float r1_q30_raw = read_float("R1_Q30_RAW")
Float r2_q30_raw = read_float("R2_Q30_RAW")
Float r1_q30_trim = read_float("R1_Q30_TRIM")
Expand Down
3 changes: 2 additions & 1 deletion tasks/task_spades.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ task spades_pe {
input {
File read1
File read2
Int? contig_threshold = 300
Int contig_threshold
String samplename
String docker = "staphb/spades:3.15.5"

Expand All @@ -22,6 +22,7 @@ task spades_pe {
mv out/scaffolds.fasta ~{samplename}_scaffolds.fasta

# remove short contigs
echo "removing contigs shorter than ~{contig_threshold}"
python <<CODE
import re
with open("~{samplename}_scaffolds.fasta", "r") as input:
Expand Down
3 changes: 2 additions & 1 deletion workflows/wf_c-bird.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ workflow cbird_workflow {
input:
samplename = samplename,
read1 = assembly_prep.read1_clean_norm,
read2 = assembly_prep.read2_clean_norm
read2 = assembly_prep.read2_clean_norm,
contig_threshold = fastp_trim.read_length * 2
}

if ( target_genes_fasta != 'null' ) {
Expand Down

0 comments on commit e2154df

Please sign in to comment.