Skip to content

Commit

Permalink
improve bash script and error message from builder
Browse files Browse the repository at this point in the history
  • Loading branch information
bowhan committed Dec 9, 2014
1 parent 1633b00 commit 52e0a87
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
Binary file removed bin/tailor
Binary file not shown.
1 change: 1 addition & 0 deletions bin/tailor
Binary file modified bin/tailor_linux
Binary file not shown.
33 changes: 14 additions & 19 deletions run_tailing_pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
export PIPELINE_DIRECTORY=$(dirname `readlink -f $0`)
export PATH=${PIPELINE_DIRECTORY}/bin:$PATH
export TAILOR_INDEX=$PIPELINE_DIRECTORY/indexes
export VERSION=1.1.0
export VERSION=1.1.1

#########
# USAGE #
Expand All @@ -35,6 +35,7 @@ cat << EOF
+++++++++++++++++++
+ Tailor pipeline +
+++++++++++++++++++
version: v$VERSION
Tailor pipeline to analyze tailing events from Next Generation Sequencing.
It requires
Expand All @@ -51,11 +52,11 @@ It requires
7. [ optional ] number of threads to use
usage: $0 \
-i input_file.fq \
-i input_file.fq[.gz] \
-g dm3.fa \
-t genomic_feature_file [ annotation/dm3.genomic_features ] \
-H hairpin.fa [ optional ] \
-M mature.fa [ optional ] \
-M mature.fa [ optional ] \
-o output_directory [ current directory ] \
-c cpu[ 8 ]
Expand All @@ -67,17 +68,17 @@ OPTIONS:
-t Files to store the genomic features. See annotation folder for examples.
<optional>
-H microRNA hairpin sequence in fasta format. The pipeline will automatically generate index.
-M microRNA mature sequence in fasta format. It is used to annotation the 5' and 3' ends of miRNA.
-o Output directory, default <current working directory>
-H microRNA hairpin sequence in fasta format. The pipeline will automatically generate index. default <null>
-M microRNA mature sequence in fasta format. It is used to annotation the 5' and 3' ends of miRNA. default <null>
-o Output directory, default <$PWD>
-c Number of CPUs to use, default <8>
-q The Phred score used to filter the reads. One read needs to have all its bases no less than this value to pass, default <20>
-t The PPM threshold used for reporting the miRNAs with editing, default 10
-T The PPM threshold used for reporting the miRNAs with editing, default <10>
EOF
}

while getopts "hi:g:o:c:q:t:H:M:t:" OPTION
while getopts "hi:g:o:c:q:t:H:M:T:" OPTION
do
case $OPTION in
h) usage && exit 0 ;;
Expand All @@ -97,6 +98,7 @@ do
M) MATURE_FA=`readlink -f $OPTARG` ;;
o) export OUTDIR=`readlink -f $OPTARG` ;;
c) export CPU=$OPTARG ;;
T) export PPM_THRESHOLD=$OPTARG ;;
q) MIN_PHRED=$OPTARG ;;
?) usage && exit 1 ;;
esac
Expand All @@ -111,7 +113,7 @@ COLOR_RED_BOLD="\e[31;1m";
COLOR_MAGENTA="\e[35;40m";
COLOR_END="\e[0m";
ISO_8601='%Y-%m-%d %H:%M:%S %Z'
case $2 in
case $2 in
error) echo -e $COLOR_RED_BOLD"[`date "+$ISO_8601"`] Error: $1${COLOR_END}" && exit 1 ;;
warning) echo -e $COLOR_MAGENTA"[`date "+$ISO_8601"`] Warning: $1${COLOR_END}" ;;
*) echo -e $COLOR_GREEN"[`date "+$ISO_8601"`] $1${COLOR_END}";;
Expand Down Expand Up @@ -155,7 +157,7 @@ FQ=`basename $INPUT_FQ`
export PREFIX=${FQ%.f[aq]*}
JOBUID=`echo ${FQ##*/} | md5sum | cut -d" " -f1`
INSERT=${FQ%.f[qa]*}.insert
ALLOW_MISMATCH="-v 1" # always allow mismatch
ALLOW_MISMATCH="-v" # always allow mismatch

##########
# folder #
Expand Down Expand Up @@ -193,8 +195,8 @@ STEP=$((STEP+1))
echo2 "Building the index if not exist"
tailor build \
-i $INDEX_FA \
-p $INDEX
# will raise warning if the index exists
-p $INDEX \
2> /dev/null

echo2 "Mapping the input fastq to the genome reference"
[ ! -f .${JOBUID}.status.${STEP}.tailor_mapping ] && \
Expand Down Expand Up @@ -333,13 +335,6 @@ if [ ! -z $HAIRPIN_INDEX_FA ]; then
$MAPPING_DIR/${PREFIX}.with_mm.bed \
$MAPPING_DIR/${PREFIX}.with_mm.bed \
> $MAPPING_DIR/${PREFIX}.with_mm.ppm$PPM_THRESHOLD.bed && \
Rscript --slave $PIPELINE_DIRECTORY/bin/draw_tailor_balloon.R \
$MAPPING_DIR/${PREFIX}.with_mm.ppm$PPM_THRESHOLD.bed \
$CPU \
$PREFIX \
$BALLOON_DIR && \
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$PDF_DIR/${PREFIX}.p${MIN_PHRED}.with_mm.ppm$PPM_THRESHOLD.balloon.pdf $BALLOON_DIR/*miRNATailingBalloonPlot.pdf && \
rm -rf $BALLOON_DIR/*miRNATailingBalloonPlot.pdf && \
touch .${JOBUID}.status.${STEP}.parse_MM_$PPM_THRESHOLD

[ ! -f .${JOBUID}.status.${STEP}.MM_figure_$PPM_THRESHOLD ] && \
Expand Down
4 changes: 2 additions & 2 deletions src/tailor_build.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ allowed, will be reported in the "MD" tag.
}
/* test whether input file exist */
if (!boost::filesystem::exists (inputFasta)) {
std::cerr << "Error: Input fasta file " << inputFasta << " does not exist! Please double check. Existing..." << std::endl;
std::cerr << "Error: Input fasta file " << inputFasta << " does not exist! Please double check. tailor-build exiting..." << std::endl;
exit (1);
}

Expand All @@ -90,7 +90,7 @@ allowed, will be reported in the "MD" tag.
}
/* check whether index already exist */
if (checkIndexIntact (indexPrefix) && !overwrite) {
std::cerr << "Error: index files already exist. If you want to overwrite them, please run it again with option -f.\nExisting..." << std::endl;
std::cerr << "Warning: index files already exist. If you would like to overwrite them, please run it again with option -f.\ntailor-build exiting..." << std::endl;
exit (2);
}
/* executing buildBWT */
Expand Down

0 comments on commit 52e0a87

Please sign in to comment.