Skip to content

updated script. Now the path of subscripts is automatically aquired. … #33

Merged
merged 21 commits into from
Jan 9, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 9 additions & 11 deletions bin/1.2_filter_motifs/compareBed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fa=false
mi=false
ma=false
ou=false
pa=false
he=false

if [ $# -eq 0 ]
Expand Down Expand Up @@ -70,6 +71,7 @@ case $key in
;;
-p|--path)
path="$2"
pa=true
shift
shift
;;
Expand Down Expand Up @@ -120,6 +122,7 @@ then
echo " -max --max maximum size of footprints; default is 80"
echo " -o --output output path/file ; default dir is workdir and filename is newMotifs.bed and newMotifs.bed.fasta"
echo " -h --help shows this help message"
echo " -p --path the path where the required scripts merge.R and maxScore.R are stored. Default: same path as this scripts path"
exit 0
fi

Expand All @@ -133,6 +136,7 @@ echo min: $mi
echo max: $ma
echo output: $ou
echo help: $he
echo path of scripts: $pa

if [ $da == false ] || [ $mo == false ] || [ $fa == false ]
then
Expand All @@ -143,12 +147,8 @@ fi

if [ $wo == false ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should set $workdir in the beginning to './' and overwrite it if necessary. This would save you this whole if statement + an additional $wo variable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking a bit further I think that most if not all of your if statements in this part are overcomplicated. You should set default values at the beginning of your script. This would enable you to discard most of the if statements and leave you only with the required parameters. These should be checked for their existence or in other words whether they were set (https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash).

then
#if [ ! -d workdir1337 ]
#then
# mkdir workdir1337
#fi
wo=true
workdir=$path
workdir=$PWD
fi

if [ $ou == false ]
Expand All @@ -169,9 +169,10 @@ then
ma=true
fi

if [ ! -d $workdir ]
if [ $pa == false ]
then
mkdir $workdir
path=`echo $0 | sed 's/\/[^\/]*$/\//g'`
pa=true
fi

#1. first filter. no overlap vs. overlap
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Filter for sequences without overlap" would be a nicer comment.

Expand Down Expand Up @@ -268,8 +269,5 @@ fi
Rscript --vanilla $path/merge.R $min $max $workdir $data

#5. add fasta sequences to bed and create fasta file
bedtools getfasta -fi $fasta -bed "$workdir"/merged.bed -bedOut > $output
bedtools getfasta -fi $fasta -bed $workdir/merged.bed -bedOut > $output
bedtools getfasta -name -fi $fasta -bed "$output" -fo "$output".fasta

#6 clean up
#rm "$workdir"/pass1Fa.bed "$workdir"/pass1Tr.bed "$workdir"/pass2Tr.bed "$workdir"/merged.bed "$workdir"/pass1FaHelp.bed "$workdir"/pass1TrHelp.bed