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

Commit

Permalink
Merge pull request icgc-argo-workflows#26 from ICGC-ARGO-Structural-V…
Browse files Browse the repository at this point in the history
…ariation-CN-WG/facets@0.4.0

Facets@0.4.0
[release]
  • Loading branch information
abenjak authored Oct 5, 2021
2 parents 38a582b + a5b1c52 commit e9835fa
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 13 deletions.
3 changes: 3 additions & 0 deletions facets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ RUN mkdir -p /tools
ENV PATH="/tools:${PATH}"
COPY facetsRun.R /tools/

# Add results script:
COPY facetsResults.sh /tools/

ENTRYPOINT ["/usr/bin/env"]

CMD ["/bin/bash"]
60 changes: 60 additions & 0 deletions facets/facetsResults.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

function usage() {
if [ -n "$1" ]; then
echo -e "Error: $1\n";
fi
echo "extracts facets metrics and archives facets results"
echo "Usage: $0 [-s summary] [-c cncf] [-p plot]"
echo " -s, --summary facets summary file"
echo " -c, --cncf facets cncf file"
echo " -p, --plot facets plot file"
echo ""
exit 1
}

# parse params
while [[ "$#" > 0 ]]; do case $1 in
-s|--summary) SUMMARY="$2"; shift;shift;;
-c|--cncf) CNCF="$2";shift;shift;;
-p|--plot) PLOT="$2";shift;shift;;
*) usage "Unknown parameter passed: $1"; shift; shift;;
esac; done

# verify mandatory inputs
if [ -z "$SUMMARY" ]; then usage "Summary file not provided"; fi;

# verify input files

if [ ! -f "$SUMMARY" ]; then usage "Input file $SUMMARY does not exist"; fi;


echo "{
\"tool\": {
\"name\": \"facets\",
\"version\": \"$(grep Version $SUMMARY | sed -E -e 's/.+= //g' -e 's/ $//')\"
},
\"metrics\": {" > facets_metrics.json

# fill json report from facets summary file
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

# make tar_content.json
# cncf and plot can be missing from facets results, but if produced both will be available
if [[ -f "$CNCF" && -f "$PLOT" ]]
then
echo "{
\"facets_metrics\": \"facets_metrics.json\",
\"facets_summary\": \"$(basename $SUMMARY)\",
\"facets_cncf\": \"$(basename $CNCF)\",
\"facets_plot\": \"$(basename $PLOT)\"
}" > tar_content.json
else
echo "{
\"facets_metrics\": \"facets_metrics.json\",
\"facets_summary\": \"$(basename $SUMMARY)\"
}" > tar_content.json
fi

# tar the results
tar -czf $(basename -s .out $SUMMARY).tgz facets_metrics.json tar_content.json $SUMMARY $CNCF $PLOT
13 changes: 7 additions & 6 deletions facets/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/* this block is auto-generated based on info from pkg.json where */
/* changes can be made if needed, do NOT modify this block manually */
nextflow.enable.dsl = 2
version = '0.3.0' // package version
version = '0.4.0'

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

params.cpus = 1
params.mem = 30 // GB
params.publish_dir = "facets_outdir" // set to empty string will disable publishDir
params.publish_dir = "" // set to empty string will disable publishDir
params.help = null

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


output:
path "*.Rdata", emit: output_Rdata
path "*.out", emit: output_summary
path "*.cncf.txt", optional: true, emit: output_cncf
path "*.cncf.pdf", optional: true, emit: output_plot
path "*.tgz", emit: facets_results


shell:
'''
#run facets
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}
#fetch results (cncf and plot can be missing from facets results, but if produced both will be available)
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)
'''
}

Expand Down
2 changes: 1 addition & 1 deletion facets/pkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "facets",
"version": "0.3.0",
"version": "0.4.0",
"description": "facets tool",
"main": "main.nf",
"deprecated": false,
Expand Down
13 changes: 7 additions & 6 deletions facets/tests/checker.nf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/* this block is auto-generated based on info from pkg.json where */
/* changes can be made if needed, do NOT modify this block manually */
nextflow.enable.dsl = 2
version = '0.3.0' // package version
version = '0.4.0'

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

script:
"""
diff ${output_file} ${expected_file} \
shell:
'''
tar -zxvf !{output_file} test.out
diff $(basename -s .tgz !{output_file}).out !{expected_file} \
&& ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 )
"""
'''
}


Expand All @@ -87,7 +88,7 @@ workflow checker {
)

file_smart_diff(
facets.out.output_summary,
facets.out.facets_results,
expected_output
)
}
Expand Down

0 comments on commit e9835fa

Please sign in to comment.