Skip to content
This repository was archived by the owner on Oct 7, 2021. It is now read-only.

Commit e9835fa

Browse files
authored
Merge pull request icgc-argo-workflows#26 from ICGC-ARGO-Structural-Variation-CN-WG/facets@0.4.0
Facets@0.4.0 [release]
2 parents 38a582b + a5b1c52 commit e9835fa

5 files changed

Lines changed: 78 additions & 13 deletions

File tree

facets/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ RUN mkdir -p /tools
1818
ENV PATH="/tools:${PATH}"
1919
COPY facetsRun.R /tools/
2020

21+
# Add results script:
22+
COPY facetsResults.sh /tools/
23+
2124
ENTRYPOINT ["/usr/bin/env"]
2225

2326
CMD ["/bin/bash"]

facets/facetsResults.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
function usage() {
4+
if [ -n "$1" ]; then
5+
echo -e "Error: $1\n";
6+
fi
7+
echo "extracts facets metrics and archives facets results"
8+
echo "Usage: $0 [-s summary] [-c cncf] [-p plot]"
9+
echo " -s, --summary facets summary file"
10+
echo " -c, --cncf facets cncf file"
11+
echo " -p, --plot facets plot file"
12+
echo ""
13+
exit 1
14+
}
15+
16+
# parse params
17+
while [[ "$#" > 0 ]]; do case $1 in
18+
-s|--summary) SUMMARY="$2"; shift;shift;;
19+
-c|--cncf) CNCF="$2";shift;shift;;
20+
-p|--plot) PLOT="$2";shift;shift;;
21+
*) usage "Unknown parameter passed: $1"; shift; shift;;
22+
esac; done
23+
24+
# verify mandatory inputs
25+
if [ -z "$SUMMARY" ]; then usage "Summary file not provided"; fi;
26+
27+
# verify input files
28+
29+
if [ ! -f "$SUMMARY" ]; then usage "Input file $SUMMARY does not exist"; fi;
30+
31+
32+
echo "{
33+
\"tool\": {
34+
\"name\": \"facets\",
35+
\"version\": \"$(grep Version $SUMMARY | sed -E -e 's/.+= //g' -e 's/ $//')\"
36+
},
37+
\"metrics\": {" > facets_metrics.json
38+
39+
# fill json report from facets summary file
40+
tail -n+2 $SUMMARY | sed -E -e 's/\# / \"/' -e 's/ \= (.+) $/\": \"\1\",/g' -e 's/\"([0-9\.\-]+)\"/\1/g' -e 's/dipt =/dipt" : ,/' -e 's/(loglik.+),/\1\n }\n}/' >> facets_metrics.json
41+
42+
# make tar_content.json
43+
# cncf and plot can be missing from facets results, but if produced both will be available
44+
if [[ -f "$CNCF" && -f "$PLOT" ]]
45+
then
46+
echo "{
47+
\"facets_metrics\": \"facets_metrics.json\",
48+
\"facets_summary\": \"$(basename $SUMMARY)\",
49+
\"facets_cncf\": \"$(basename $CNCF)\",
50+
\"facets_plot\": \"$(basename $PLOT)\"
51+
}" > tar_content.json
52+
else
53+
echo "{
54+
\"facets_metrics\": \"facets_metrics.json\",
55+
\"facets_summary\": \"$(basename $SUMMARY)\"
56+
}" > tar_content.json
57+
fi
58+
59+
# tar the results
60+
tar -czf $(basename -s .out $SUMMARY).tgz facets_metrics.json tar_content.json $SUMMARY $CNCF $PLOT

facets/main.nf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/* this block is auto-generated based on info from pkg.json where */
3030
/* changes can be made if needed, do NOT modify this block manually */
3131
nextflow.enable.dsl = 2
32-
version = '0.3.0' // package version
32+
version = '0.4.0'
3333

3434
container = [
3535
'ghcr.io': 'ghcr.io/icgc-argo-structural-variation-cn-wg/icgc-argo-sv-copy-number.facets'
@@ -45,7 +45,7 @@ params.container = ""
4545

4646
params.cpus = 1
4747
params.mem = 30 // GB
48-
params.publish_dir = "facets_outdir" // set to empty string will disable publishDir
48+
params.publish_dir = "" // set to empty string will disable publishDir
4949
params.help = null
5050

5151
// tool specific parmas go here, add / change as needed
@@ -118,15 +118,16 @@ process facets {
118118

119119

120120
output:
121-
path "*.Rdata", emit: output_Rdata
122-
path "*.out", emit: output_summary
123-
path "*.cncf.txt", optional: true, emit: output_cncf
124-
path "*.cncf.pdf", optional: true, emit: output_plot
121+
path "*.tgz", emit: facets_results
125122

126123

127124
shell:
128125
'''
126+
#run facets
129127
facetsRun.R --seed !{params.seed} --minNDepth !{params.minNDepth} --maxNDepth !{params.maxNDepth} --snp_nbhd !{params.snp_nbhd} --minGC !{params.minGC} --maxGC !{params.maxGC} --cval !{params.cval} --pre_cval !{params.pre_cval} --genome !{params.genome} --min_nhet !{params.min_nhet} --outPrefix !{params.tumor_id} --tumorName !{params.tumor_id} !{pileup}
128+
129+
#fetch results (cncf and plot can be missing from facets results, but if produced both will be available)
130+
facetsResults.sh -s !{params.tumor_id}.out $(if [[ -f !{params.tumor_id}.cncf.txt && -f !{params.tumor_id}.cncf.pdf ]]; then echo -c !{params.tumor_id}.cncf.txt -p !{params.tumor_id}.cncf.pdf; fi)
130131
'''
131132
}
132133

facets/pkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "facets",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "facets tool",
55
"main": "main.nf",
66
"deprecated": false,

facets/tests/checker.nf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/* this block is auto-generated based on info from pkg.json where */
3535
/* changes can be made if needed, do NOT modify this block manually */
3636
nextflow.enable.dsl = 2
37-
version = '0.3.0' // package version
37+
version = '0.4.0'
3838

3939
container = [
4040
'ghcr.io': 'ghcr.io/icgc-argo-structural-variation-cn-wg/icgc-argo-sv-copy-number.facets'
@@ -66,11 +66,12 @@ process file_smart_diff {
6666
output:
6767
stdout()
6868

69-
script:
70-
"""
71-
diff ${output_file} ${expected_file} \
69+
shell:
70+
'''
71+
tar -zxvf !{output_file} test.out
72+
diff $(basename -s .tgz !{output_file}).out !{expected_file} \
7273
&& ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 )
73-
"""
74+
'''
7475
}
7576

7677

@@ -87,7 +88,7 @@ workflow checker {
8788
)
8889

8990
file_smart_diff(
90-
facets.out.output_summary,
91+
facets.out.facets_results,
9192
expected_output
9293
)
9394
}

0 commit comments

Comments
 (0)