From bee69d75ab7e4ebda8a2b7099936e1f604974176 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Wed, 31 Jul 2024 14:02:12 -0400 Subject: [PATCH 1/5] turn on set -eo pipefail --- bin/Metafusion_forte.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/Metafusion_forte.sh b/bin/Metafusion_forte.sh index 22f901e..d61511f 100755 --- a/bin/Metafusion_forte.sh +++ b/bin/Metafusion_forte.sh @@ -1,4 +1,7 @@ #!/bin/bash + +set -eo pipefail + #STEPS # __author__ = "Alexandria Dymun" @@ -7,7 +10,6 @@ # __version__ = "0.0.1" # __status__ = "Dev" - output_ANC_RT_SG=1 RT_call_filter=1 blck_filter=1 @@ -60,15 +62,17 @@ if [[ ! $cff || ! $gene_info || ! $gene_bed ]]; then usage fi +env | grep -i tmp -mkdir $outdir +mkdir -p $outdir #Check CFF file format: #Remove entries with nonconformming chromosome name all_gene_bed_chrs=`awk -F '\t' '{print $1}' $gene_bed | sort | uniq | sed 's/chr//g '` awk -F " " -v arr="${all_gene_bed_chrs[*]}" 'BEGIN{OFS = "\t"; split(arr,arr1); for(i in arr1) dict[arr1[i]]=""} $1 in dict && $4 in dict' $cff > $outdir/$(basename $cff).cleaned_chr -grep -v -f $outdir/$(basename $cff).cleaned_chr $cff > problematic_chromosomes.cff +head $outdir/$(basename $cff).cleaned_chr +grep -v -f $outdir/$(basename $cff).cleaned_chr $cff > problematic_chromosomes.cff || test $? = 1 cff=$outdir/$(basename $cff).cleaned_chr #Rename cff @@ -116,10 +120,10 @@ fi #ReadThrough Callerfilter if [ $RT_call_filter -eq 1 ]; then echo ReadThrough, callerfilter $num_tools - cat $cluster | grep ReadThrough > $outdir/$(basename $cluster).ReadThrough + cat $cluster | grep ReadThrough > $outdir/$(basename $cluster).ReadThrough || test $? = 1 callerfilter_num.py --cluster $cluster --num_tools $num_tools > $outdir/$(basename $cluster).callerfilter.$num_tools callerfilter_excluded=$(comm -13 <(cut -f 22 $outdir/$(basename $cluster).callerfilter.$num_tools | sort | uniq) <(cut -f 22 $cluster | sort | uniq)) - grep -v ReadThrough $outdir/$(basename $cluster).callerfilter.$num_tools > $outdir/$(basename $cluster).RT_filter.callerfilter.$num_tools + grep -v ReadThrough $outdir/$(basename $cluster).callerfilter.$num_tools > $outdir/$(basename $cluster).RT_filter.callerfilter.$num_tools || test $? = 1 cluster_RT_call=$outdir/$(basename $cluster).RT_filter.callerfilter.$num_tools fi # Blocklist Filter From d49b97332029cbeef43b5b1c8034e3af05c32bfb Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Thu, 1 Aug 2024 15:02:43 -0400 Subject: [PATCH 2/5] specify temporary directory for sort command --- bin/Metafusion_forte.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/Metafusion_forte.sh b/bin/Metafusion_forte.sh index d61511f..c1bbb82 100755 --- a/bin/Metafusion_forte.sh +++ b/bin/Metafusion_forte.sh @@ -69,7 +69,7 @@ mkdir -p $outdir #Check CFF file format: #Remove entries with nonconformming chromosome name -all_gene_bed_chrs=`awk -F '\t' '{print $1}' $gene_bed | sort | uniq | sed 's/chr//g '` +all_gene_bed_chrs=`awk -F '\t' '{print $1}' $gene_bed | sort -T $TMPDIR | uniq | sed 's/chr//g '` awk -F " " -v arr="${all_gene_bed_chrs[*]}" 'BEGIN{OFS = "\t"; split(arr,arr1); for(i in arr1) dict[arr1[i]]=""} $1 in dict && $4 in dict' $cff > $outdir/$(basename $cff).cleaned_chr head $outdir/$(basename $cff).cleaned_chr grep -v -f $outdir/$(basename $cff).cleaned_chr $cff > problematic_chromosomes.cff || test $? = 1 @@ -122,7 +122,7 @@ if [ $RT_call_filter -eq 1 ]; then echo ReadThrough, callerfilter $num_tools cat $cluster | grep ReadThrough > $outdir/$(basename $cluster).ReadThrough || test $? = 1 callerfilter_num.py --cluster $cluster --num_tools $num_tools > $outdir/$(basename $cluster).callerfilter.$num_tools - callerfilter_excluded=$(comm -13 <(cut -f 22 $outdir/$(basename $cluster).callerfilter.$num_tools | sort | uniq) <(cut -f 22 $cluster | sort | uniq)) + callerfilter_excluded=$(comm -13 <(cut -f 22 $outdir/$(basename $cluster).callerfilter.$num_tools | sort -T $TMPDIR | uniq) <(cut -f 22 $cluster | sort -T $TMPDIR | uniq)) grep -v ReadThrough $outdir/$(basename $cluster).callerfilter.$num_tools > $outdir/$(basename $cluster).RT_filter.callerfilter.$num_tools || test $? = 1 cluster_RT_call=$outdir/$(basename $cluster).RT_filter.callerfilter.$num_tools fi @@ -156,8 +156,8 @@ cluster=$outdir/final.n$num_tools.cluster #for this in $(echo $out5); do grep $this $cff; done >> $outdir/$(basename $cff).filtered.cff rm -f filters.txt -cut -f 22 *.BLOCKLIST | tr "," "\n" | sort | uniq | sed "s/$/\tblocklist/g" > filters.txt -comm -23 <(cut -f 22 *.blck_filter | tr "," "\n" | sort | uniq) <(cut -f 22 *.ANC_filter | tr "," "\n" | sort | uniq) | sed "s/$/\tadjacent_noncoding/g" >> filters.txt -cut -f 22 *.ReadThrough | tr "," "\n" | sort | uniq | sed "s/$/\tread_through/g" >> filters.txt -echo -en "$callerfilter_excluded" | tr "," "\n" | sort | uniq | sed "s/$/\tcaller_filter/g" >> filters.txt +cut -f 22 *.BLOCKLIST | tr "," "\n" | sort -T $TMPDIR | uniq | sed "s/$/\tblocklist/g" > filters.txt +comm -23 <(cut -f 22 *.blck_filter | tr "," "\n" | sort -T $TMPDIR | uniq) <(cut -f 22 *.ANC_filter | tr "," "\n" | sort -T $TMPDIR | uniq) | sed "s/$/\tadjacent_noncoding/g" >> filters.txt +cut -f 22 *.ReadThrough | tr "," "\n" | sort -T $TMPDIR | uniq | sed "s/$/\tread_through/g" >> filters.txt +echo -en "$callerfilter_excluded" | tr "," "\n" | sort -T $TMPDIR | uniq | sed "s/$/\tcaller_filter/g" >> filters.txt From 9075dab4e9eca95ca539424939bc70ab11a79ef5 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Tue, 6 Aug 2024 15:14:34 -0400 Subject: [PATCH 3/5] Revert "specify temporary directory for sort command" This reverts commit d49b97332029cbeef43b5b1c8034e3af05c32bfb. --- bin/Metafusion_forte.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/Metafusion_forte.sh b/bin/Metafusion_forte.sh index c1bbb82..d61511f 100755 --- a/bin/Metafusion_forte.sh +++ b/bin/Metafusion_forte.sh @@ -69,7 +69,7 @@ mkdir -p $outdir #Check CFF file format: #Remove entries with nonconformming chromosome name -all_gene_bed_chrs=`awk -F '\t' '{print $1}' $gene_bed | sort -T $TMPDIR | uniq | sed 's/chr//g '` +all_gene_bed_chrs=`awk -F '\t' '{print $1}' $gene_bed | sort | uniq | sed 's/chr//g '` awk -F " " -v arr="${all_gene_bed_chrs[*]}" 'BEGIN{OFS = "\t"; split(arr,arr1); for(i in arr1) dict[arr1[i]]=""} $1 in dict && $4 in dict' $cff > $outdir/$(basename $cff).cleaned_chr head $outdir/$(basename $cff).cleaned_chr grep -v -f $outdir/$(basename $cff).cleaned_chr $cff > problematic_chromosomes.cff || test $? = 1 @@ -122,7 +122,7 @@ if [ $RT_call_filter -eq 1 ]; then echo ReadThrough, callerfilter $num_tools cat $cluster | grep ReadThrough > $outdir/$(basename $cluster).ReadThrough || test $? = 1 callerfilter_num.py --cluster $cluster --num_tools $num_tools > $outdir/$(basename $cluster).callerfilter.$num_tools - callerfilter_excluded=$(comm -13 <(cut -f 22 $outdir/$(basename $cluster).callerfilter.$num_tools | sort -T $TMPDIR | uniq) <(cut -f 22 $cluster | sort -T $TMPDIR | uniq)) + callerfilter_excluded=$(comm -13 <(cut -f 22 $outdir/$(basename $cluster).callerfilter.$num_tools | sort | uniq) <(cut -f 22 $cluster | sort | uniq)) grep -v ReadThrough $outdir/$(basename $cluster).callerfilter.$num_tools > $outdir/$(basename $cluster).RT_filter.callerfilter.$num_tools || test $? = 1 cluster_RT_call=$outdir/$(basename $cluster).RT_filter.callerfilter.$num_tools fi @@ -156,8 +156,8 @@ cluster=$outdir/final.n$num_tools.cluster #for this in $(echo $out5); do grep $this $cff; done >> $outdir/$(basename $cff).filtered.cff rm -f filters.txt -cut -f 22 *.BLOCKLIST | tr "," "\n" | sort -T $TMPDIR | uniq | sed "s/$/\tblocklist/g" > filters.txt -comm -23 <(cut -f 22 *.blck_filter | tr "," "\n" | sort -T $TMPDIR | uniq) <(cut -f 22 *.ANC_filter | tr "," "\n" | sort -T $TMPDIR | uniq) | sed "s/$/\tadjacent_noncoding/g" >> filters.txt -cut -f 22 *.ReadThrough | tr "," "\n" | sort -T $TMPDIR | uniq | sed "s/$/\tread_through/g" >> filters.txt -echo -en "$callerfilter_excluded" | tr "," "\n" | sort -T $TMPDIR | uniq | sed "s/$/\tcaller_filter/g" >> filters.txt +cut -f 22 *.BLOCKLIST | tr "," "\n" | sort | uniq | sed "s/$/\tblocklist/g" > filters.txt +comm -23 <(cut -f 22 *.blck_filter | tr "," "\n" | sort | uniq) <(cut -f 22 *.ANC_filter | tr "," "\n" | sort | uniq) | sed "s/$/\tadjacent_noncoding/g" >> filters.txt +cut -f 22 *.ReadThrough | tr "," "\n" | sort | uniq | sed "s/$/\tread_through/g" >> filters.txt +echo -en "$callerfilter_excluded" | tr "," "\n" | sort | uniq | sed "s/$/\tcaller_filter/g" >> filters.txt From a27c0b2701d26cbdf68d501f1a49b46c2d41ba45 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Tue, 6 Aug 2024 15:16:37 -0400 Subject: [PATCH 4/5] export TMPDIR variable --- modules/local/metafusion/run/main.nf | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/local/metafusion/run/main.nf b/modules/local/metafusion/run/main.nf index 022ff71..bd1d8fa 100644 --- a/modules/local/metafusion/run/main.nf +++ b/modules/local/metafusion/run/main.nf @@ -29,6 +29,7 @@ process METAFUSION_RUN { args = task.ext.args ?: "" def sample = "${meta.sample}" """ + export TMPDIR=\$TMPDIR Metafusion_forte.sh \\ --cff $cff \\ --outdir . \\ From c61e57a2f86aa37c76d7ef93f12d8fdbc938d265 Mon Sep 17 00:00:00 2001 From: Anne Marie Noronha Date: Tue, 6 Aug 2024 15:26:54 -0400 Subject: [PATCH 5/5] update change log --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39caca1..cded945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Fixed` +- [#118](https://github.com/mskcc/forte/pull/119) - change script error behavior in METAFUSION_RUN process + ### `Dependencies` ### `Deprecated`