@@ -262,6 +262,8 @@ class ReportController {
262262 def downloadScript (Long reportId ) {
263263 def samples = reportService. fetchDataForReport(reportId)
264264
265+ def filetypes = params. list(' filetypes' )
266+
265267 def data = []
266268
267269 samples. each { sample ->
@@ -270,41 +272,49 @@ class ReportController {
270272 // TODO: hard-coded
271273 def path
272274
273- if (experiment. fastq. read1) {
274- // replace "preview=False" with "to_ext=fastqsanger.gz"
275- path = experiment. fastq. read1. replace(" preview=False" , " to_ext=fastqsanger.gz" )
276-
277- data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _R1.fastq.gz ${ path} " )
278- }
279-
280- if (experiment. fastq. read2) {
281- // replace "preview=False" with "to_ext=fastqsanger.gz"
282- path = experiment. fastq. read2. replace(" preview=False" , " to_ext=fastqsanger.gz" )
283-
284- data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _R2.fastq.gz ${ path} " )
275+ if (filetypes. contains(' fastq' )) {
276+ if (experiment. fastq. read1) {
277+ // replace "preview=False" with "to_ext=fastqsanger.gz"
278+ path = experiment. fastq. read1. replace(" preview=False" , " to_ext=fastqsanger.gz" )
279+
280+ data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _R1.fastq.gz ${ path} " )
281+ }
282+
283+ if (experiment. fastq. read2) {
284+ // replace "preview=False" with "to_ext=fastqsanger.gz"
285+ path = experiment. fastq. read2. replace(" preview=False" , " to_ext=fastqsanger.gz" )
286+
287+ data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _R2.fastq.gz ${ path} " )
288+ }
285289 }
286290
287- if (alignment. bamRaw) {
288- data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _raw.bam ${ alignment.bamRaw} " )
291+ if (filetypes. contains(' raw_bam' )) {
292+ if (alignment. bamRaw) {
293+ data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _raw.bam ${ alignment.bamRaw} " )
294+ }
289295 }
290296
291- if (alignment. bam) {
292- data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _filtered.bam ${ alignment.bam} " )
297+ if (filetypes. contains(' filtered_bam' )) {
298+ if (alignment. bam) {
299+ data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _filtered.bam ${ alignment.bam} " )
300+ }
293301 }
294302
295- if (alignment. bigwigForwardFile) {
296- // replace "preview=False" with "to_ext=bigwig"
297- path = alignment. bigwigForwardFile. replace(" preview=False" , " to_ext=bigwig" )
298-
299- data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _forward.bigwig ${ path} " )
303+ if (filetypes. contains(' bigwig' )) {
304+ if (alignment. bigwigForwardFile) {
305+ // replace "preview=False" with "to_ext=bigwig"
306+ path = alignment. bigwigForwardFile. replace(" preview=False" , " to_ext=bigwig" )
307+
308+ data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _forward.bigwig ${ path} " )
309+ }
310+
311+ if (alignment. bigwigReverseFile) {
312+ // replace "preview=False" with "to_ext=bigwig"
313+ path = alignment. bigwigReverseFile. replace(" preview=False" , " to_ext=bigwig" )
314+
315+ data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _reverse.bigwig ${ path} " )
316+ }
300317 }
301-
302- if (alignment. bigwigReverseFile) {
303- // replace "preview=False" with "to_ext=bigwig"
304- path = alignment. bigwigReverseFile. replace(" preview=False" , " to_ext=bigwig" )
305-
306- data. add(" curl -o ${ sample.id} _${ sample.target} _${ sample.antibody} _${ sample.strain} _reverse.bigwig ${ path} " )
307- }
308318 }
309319 }
310320 }
0 commit comments