/
fastq-vector-removal.cwl
181 lines (175 loc) · 5.05 KB
/
fastq-vector-removal.cwl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
class: Workflow
cwlVersion: v1.0
doc: This workflow clean up vectros from fastq files
label: FASTQ Vector Removal
requirements:
InlineJavascriptRequirement: {}
StepInputExpressionRequirement: {}
SubworkflowFeatureRequirement: {}
ShellCommandRequirement: {}
inputs:
threads: int
vector_fsa: File
fastq1: File
fastq2: File?
outputs:
fastq1_output:
outputSource: create_clean_fastq/output
type: File
fastq2_output:
outputSource: create_clean_fastq/output2
type: File?
clean_fasta_:
outputSource: create_clean_fasta_from_fastq/output
type: File
steps:
vector_blastdb:
run: ../../tools/blast/makeblastdb.cwl
label: Make Vector BlastDB
in:
dbtype: { default: "nucl" }
hash_index: { default: True }
out: { default: "myblastdb" }
in: vector_fsa
out: [ out_db ]
collect_blastdb:
run: ../../tools/basic/files2dir.cwl
label: Collect BlastDB
in:
files: vector_blastdb/out_db
dir: { default: "myblastdb" }
out: [ output ]
create_fasta_from_fastq:
label: Create FASTA from FASTQ
run: ../../tools/basic/fastq2fasta.cwl
in:
fastq1: fastq1
fastq2: fastq2
out: [output]
vector_blastn:
run: ../../tools/blast/blastn.cwl
label: Vector BlastN
in:
dbdir: collect_blastdb/output
db: { default: "myblastdb" }
query: create_fasta_from_fastq/output
num_threads: threads
out:
valueFrom: ${ return inputs.query.nameroot + ".tsv";}
outfmt: { default: "6 qseqid saccver qstart qend length evalue bitscore score" }
evalue: { default: 700 }
task: { default: "blastn" }
reward: { default: 1 }
penalty: { default: -5 }
gapopen: { default: 3 }
gapextend: { default: 3 }
dust: { default: "yes" }
soft_masking: { default: "true" }
max_target_seqs: {default: 1 }
searchsp: { default: 1750000000000 }
out: [ output ]
extract_read_ids:
label: Extract read IDs
run:
class: CommandLineTool
label: Extract read IDs
requirements:
InlineJavascriptRequirement: { }
hints:
- $import: ../../tools/basic/ubuntu-docker.yml
inputs:
tsv:
type: File
streamable: true
inputBinding:
position: 1
pipe:
type: string
default: "|"
inputBinding:
position: 3
shellQuote: False
awk:
type: string
default: "'{print $1}'"
inputBinding:
position: 4
prefix: awk
shellQuote: False
pipe2:
type: string
default: "|"
inputBinding:
position: 5
shellQuote: False
sort:
type: string
default: "-u"
inputBinding:
position: 6
prefix: sort
shellQuote: False
outputs:
output:
type: File
streamable: true
outputBinding:
glob: $(inputs.tsv.nameroot + "_unique.ids")
stdout: $(inputs.tsv.nameroot + "_unique.ids")
baseCommand: [ "cat" ]
in:
tsv: vector_blastn/output
out: [ output ]
create_clean_fastq:
label: Creates clean FASTQ
run: ../../tools/bbmap/filterbyname.cwl
in:
in: fastq1
in2: fastq2
out:
valueFrom: |
${
var nameroot = inputs.in.nameroot;
if (nameroot.endsWith(".fastq")){
nameroot = nameroot.replace(".fastq", "");
}else if (nameroot.endsWith(".fq")){
nameroot = nameroot.replace(".fq", "");
}
if (nameroot.endsWith("_1")){
nameroot = nameroot.replace('_1', '_clean_1.fastq.gz');
}else if (nameroot.includes("_R1_")){
nameroot = nameroot.substring(1, nameroot.indexOf("_R1_")) + '_clean_1.fastq.gz';
} else{
nameroot = nameroot + '_clean.fastq.gz';
}
return nameroot;
}
out2:
valueFrom: |
${
if (inputs.in2 != null){
var nameroot = inputs.in2.nameroot;
if (nameroot.endsWith(".fastq")){
nameroot = nameroot.replace(".fastq", "");
}else if (nameroot.endsWith(".fq")){
nameroot = nameroot.replace(".fq", "");
}
if (nameroot.endsWith("_2")){
nameroot = nameroot.replace('_2', '_clean_2.fastq.gz');
}else if (nameroot.includes("_R2_")){
nameroot = nameroot.substring(1, nameroot.indexOf("_R2_")) + '_clean_2.fastq.gz';
}
return nameroot;
}
return null;
}
names: extract_read_ids/output
include: {default: "f"}
out: [output, output2]
create_clean_fasta_from_fastq:
label: Create FASTA from FASTQ
run: ../../tools/basic/fastq2fasta.cwl
in:
fastq1: create_clean_fastq/output
fastq2: create_clean_fastq/output2
out: [ output ]