Skip to content

Commit 8743b19

Browse files
committed
Update variable naming scheme within scripts.
Now all bash variables (whether global or local) are written in upper case while nextflow variables are in lower case.
1 parent a379854 commit 8743b19

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

main.nf

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -266,28 +266,28 @@ process variant_effect_predictor {
266266

267267
script:
268268
"""
269-
infile="$infile"
270-
outfile="\$infile.vep"
271-
vep_cache="/sw/data/uppnex/vep/84"
272-
assembly="$params.vep.assembly"
273-
274-
case "\$infile" in
275-
*vcf) format="vcf" ;;
276-
*bed) format="ensembl" ;;
277-
*) printf "Unrecognized format for '%s'" "\$infile" >&2
269+
INFILE="$infile"
270+
OUTFILE="\${INFILE%.vcf}.vep.vcf"
271+
VEP_CACHE="/sw/data/uppnex/vep/84"
272+
ASSEMBLY="GRCh37"
273+
274+
case "\$INFILE" in
275+
*vcf) FORMAT="vcf" ;;
276+
*bed) FORMAT="ensembl" ;;
277+
*) printf "Unrecognized format for '%s'" "\$INFILE" >&2
278278
exit 1;;
279279
esac
280280
281-
## If the input file is empty, just copy
282-
if [ \$( wc -l "\$infile" | awk '{print \$1}' ) -eq 0 ]; then
283-
cp "\$infile" "\$outfile"
281+
## If the input file is empty, just copy it
282+
if [[ -f "\$INFILE" && -s "\$INFILE" ]]; then
283+
cp "\$INFILE" "\$OUTFILE"
284284
exit
285285
fi
286286
287287
variant_effect_predictor.pl \
288288
-i "\$infile" \
289-
--format "\$format" \
290-
-cache --dir "\$vep_cache" \
289+
--format "\$FORMAT" \
290+
-cache --dir "\$VEP_CACHE" \
291291
-o "\$outfile" \
292292
--vcf \
293293
--merged \
@@ -302,14 +302,14 @@ process variant_effect_predictor {
302302
--canonical \
303303
--ccds \
304304
--fields Consequence,Codons,Amino_acids,Gene,SYMBOL,Feature,EXON,PolyPhen,SIFT,Protein_position,BIOTYPE \
305-
--assembly "\$assembly" \
305+
--assembly "\$ASSEMBLY" \
306306
--offline
307307
"""
308308
}
309309

310310
process snpEff {
311311
input:
312-
file vcf from annotate_files.tap { annotate_files }
312+
file infile from annotate_files.tap { annotate_files }
313313
output:
314314
file '*.snpeff.vcf'
315315

@@ -326,25 +326,26 @@ process snpEff {
326326

327327
script:
328328
"""
329-
vcf="$vcf" ## Use bash-semantics for variables
330-
snpeffjar=''
329+
INFILE="$infile" ## Use bash-semantics for variables
330+
OUTFILE="\${INFILE%.vcf}.snpeff.vcf"
331+
SNPEFFJAR=''
331332
332-
for p in \$( tr ':' ' ' <<<"\$CLASSPATH" ); do
333-
if [ -f "\$p/snpEff.jar" ]; then
334-
snpeffjar="\$p/snpEff.jar"
333+
for P in \$( tr ':' ' ' <<<"\$CLASSPATH" ); do
334+
if [ -f "\$P/snpEff.jar" ]; then
335+
SNPEFFJAR="\$P/snpEff.jar"
335336
break
336337
fi
337338
done
338-
if [ -z "\$snpeffjar" ]; then
339+
if [ -z "\$SNPEFFJAR" ]; then
339340
printf "Can't find snpEff.jar in '%s'" "\$CLASSPATH" >&2
340341
exit 1
341342
fi
342343
343-
sed 's/ID=AD,Number=./ID=AD,Number=R/' "\$vcf" \
344+
sed 's/ID=AD,Number=./ID=AD,Number=R/' "\$INFILE" \
344345
| vt decompose -s - \
345346
| vt normalize -r $params.ref_fasta - \
346-
| java -Xmx7G -jar "\$snpeffjar" -formatEff -classic GRCh37.75 \
347-
> "\$vcf.snpeff"
347+
| java -Xmx7G -jar "\$SNPEFFJAR" -formatEff -classic GRCh37.75 \
348+
> "\$OUTFILE"
348349
"""
349350
}
350351

0 commit comments

Comments
 (0)