From 6cd8c7fd9f665315bb7d552f706c19aaa9e20129 Mon Sep 17 00:00:00 2001 From: JannikHamp Date: Fri, 11 Jan 2019 11:04:26 +0100 Subject: [PATCH] check if output ends with .bed --- bin/1.2_filter_motifs/compareBed.sh | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bin/1.2_filter_motifs/compareBed.sh b/bin/1.2_filter_motifs/compareBed.sh index 1cb3c1b..c50687a 100644 --- a/bin/1.2_filter_motifs/compareBed.sh +++ b/bin/1.2_filter_motifs/compareBed.sh @@ -10,7 +10,7 @@ # For parameter description, run the script without parameters or -h. # The output is a file with the filtered footprints and the log file FilterMotivs.stats -# Two R scripts are used, compareBed_runinfo.R and abs_max_score.R, stored in the same directory. +# One R scripts is used, compareBed_runinfo.R, stored in the same directory. # default parameters workdir=$PWD @@ -173,6 +173,10 @@ then echo "directory $workdir does not exist. Please check parameter -w / --workdir" exit 1 fi +if [[ ${output: -4: -1} != '.bed' ]] +then + output=`echo $output | sed "s|$|.bed|g"` +fi # remove trailing tabs in footprints cat $data | sed 's/[ \t]*$//' > "$workdir"/filtered.bed @@ -219,14 +223,6 @@ if [ $all_empty == true ] exit 1 fi -#calculate absolute max_score position -Rscript $path/abs_max_score.R "$workdir"/filtered.bed -# check if Rscript executed without errors -if [ $? -gt 0 ] -then - exit 1 -fi - # comparing unknown footprints with regions of known motifs # comparison is done iteratively # remove overlapping regions in unknown footprints @@ -292,6 +288,7 @@ else fi # add fasta sequences to bed and create fasta file +out_fasta=`echo $output | sed "s|.bed$|.fasta|g"` echo getting sequences from fasta-file bedtools getfasta -fi $fasta -bed "$workdir"/filtered_flagged.bed -bedOut >> $output -bedtools getfasta -name -fi $fasta -bed "$output" -fo "$output".fasta +bedtools getfasta -name -fi $fasta -bed "$output" -fo "$out_fasta"