Skip to content

Commit

Permalink
check if output ends with .bed
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikHamp authored Jan 11, 2019
1 parent 7514dfb commit 6cd8c7f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions bin/1.2_filter_motifs/compareBed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"

0 comments on commit 6cd8c7f

Please sign in to comment.