Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# call-transcripts.sh
script_name="call-transcripts.sh"
script_ver="1.0.0"
#Help function
usage() {
echo "-h Help documentation for $script_name"
echo "-f --File path to Replicate 1 alignments"
echo "-r --UCSC Reference genome (e.g. hg19, mm10)"
echo "-o --Path to output directory"
echo "-b --The LtsProbB value"
echo "-u --The UTS value"
echo "-v --Version of script"
echo "Example: $script_name -f 'foo_1.bam' -r 'hg19' -o '/path/to/output/dir/' -b -200 -u 5"
exit 1
}
# Version function
version(){
echo "$script_name $script_ver"
exit 1
}
main(){
# Load required modules
module load python/2.7.x-anaconda
module load R/3.1.0-intel
# Parsing options
OPTIND=1 # Reset OPTIND
while getopts :f:r:o:b:u:vh opt
do
case $opt in
f) aln1=$OPTARG;;
s) aln2=$OPTARG;;
r) ucsc_reference=$OPTARG;;
o) out=$OPTARG;;
b) ltprob=$OPTARG;;
u) uts=$OPTARG;;
v) version;;
h) usage;;
esac
done
shift $(($OPTIND -1))
# Check for mandatory options
if [[ -z $aln1 ]] || [[ -z $ucsc_reference ]] || [[ -z $ltprob ]] || [[ -z $uts ]] || [[ -z $out ]]; then
usage
fi
# Define the out directory
out_dir=$out\/$script_name-$script_ver
# Make sure directories exist
if [ ! -e $out ]; then
mkdir $out
fi
if [ ! -e $out_dir ]; then
mkdir $out_dir
fi
# Run call-transcripts.R
if [ ! -e $out_dir/metadata.json ]; then
Rscript call-transcripts.R --replicate1 $aln1 --genome $ucsc_reference --out $out_dir --ltprob $ltprob --uts $uts
# Get input and output files and then print out metadata.json file
input_files=("$aln1")
printf -v input "\"%s\"," "${input_files[@]}"
input=${input%,}
output_file=($out_dir\/$prefix*)
printf -v output "\"%s\"," "${output_file[@]}"
output=${output%,}
printf '{"script name":"%s","script version":"%s", "input files": [%s], "LtsProbB": [%s], "UTS": [%s], "output files": [%s]}' "$script_name" "$script_ver" "$input" "$ltprob" "$uts" "$output" | python -m json.tool > $out_dir/metadata.json
else
aln1_fn=$(basename "$aln1")
echo "* Transcripts has been made from $aln1_fn"
fi
}
main "$@"