Skip to content

Commit c577341

Browse files
committed
fix #333 Add checkbox to file download script
1 parent 19c56a9 commit c577341

2 files changed

Lines changed: 61 additions & 30 deletions

File tree

pegr/grails-app/controllers/pegr/ReportController.groovy

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

pegr/grails-app/views/report/listFiles.gsp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,29 @@
44
<asset:javascript src="exportCsv.js"/>
55
</head>
66
<body>
7-
<button class="btn btn-primary" id="export-csv">Export CSV file</button>
8-
<g:link action="downloadScript" params="[reportId:reportId]" class="btn btn-primary" id="download-script">Download script</g:link>
7+
<div>
8+
<button class="btn btn-primary" id="export-csv">Export CSV file</button>
9+
<button data-toggle="collapse" data-target="#select-files" aria-expanded="false" action="downloadScript" params="[reportId:reportId]" class="btn btn-primary" id="download-script">Download script</button>
10+
<div id="select-files" class="collapse well">
11+
<p>Please select the files to download.</p>
12+
<g:form controller="report" action="downloadScript" method="post">
13+
<input type="hidden" name="reportId" value="${reportId}">
14+
<div class="form-group">
15+
<input type="checkbox" name="filetypes" value="fastq"> <label>FASTQ</label>
16+
</div>
17+
<div class="form-group">
18+
<input type="checkbox" name="filetypes" value="raw_bam"> <label>Raw BAM</label>
19+
</div>
20+
<div class="form-group">
21+
<input type="checkbox" name="filetypes" value="filtered_bam"> <label>Filtered BAM</label>
22+
</div>
23+
<div class="form-group">
24+
<input type="checkbox" name="filetypes" value="bigwig"> <label>bigWig</label>
25+
</div>
26+
<g:submitButton name="submit" value="Submit" class="edit"></g:submitButton>
27+
</g:form>
28+
</div>
29+
</div>
930
<table class="table table-bordered">
1031
<thead>
1132
<tr>

0 commit comments

Comments
 (0)