forked from BauerLab/ngsane
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtrinity_chrysalis.sh
More file actions
executable file
·144 lines (114 loc) · 5.59 KB
/
Copy pathtrinity_chrysalis.sh
File metadata and controls
executable file
·144 lines (114 loc) · 5.59 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash -e
# Martin Smith, August 2013
# tested with trinityrnaseq_r2013-02-25
# QCVARIABLES,Resource temporarily unavailable
# RESULTFILENAME <DIR>/<TASK>/<SAMPLE>.chrysalis.timing
echo ">>>>> transcriptome assembly with trinity chrysalis"
echo ">>>>> startdate "`date`
echo ">>>>> hostname "`hostname`
echo ">>>>> job_name "$JOB_NAME
echo ">>>>> job_id "$JOB_ID
echo ">>>>> $(basename $0) $*"
function usage {
echo -e "usage: $(basename $0) -k NGSANE -f FASTQ -r REFERENCE -o OUTDIR [OPTIONS]"
exit
}
if [ ! $# -gt 3 ]; then usage ; fi
while [ "$1" != "" ]; do
case $1 in
-k | --toolkit ) shift; CONFIG=$1 ;; # location of the configuration file
-f | --fastq ) shift; f=$1 ;; # fastq file
-o | --outdir ) shift; OUTDIR=$1 ;; # output dir
--recover-from ) shift; NGSANE_RECOVERFROM=$1 ;; # attempt to recover from log file
-h | --help ) usage ;;
* ) echo "don't understand "$1
esac
shift
done
. $CONFIG
. ${NGSANE_BASE}/conf/header.sh
. $CONFIG
if [ -e $NODE_TMP ]; then TMP=$NODE_TMP; fi # overwrites temp folder variable to node-local temp folder, if specified
################################################################################
NGSANE_CHECKPOINT_INIT "programs"
# save way to load modules that itself loads other modules
hash module 2>/dev/null && for MODULE in $MODULES_TRINITY; do module load $MODULE; done && module list
export PATH=$PATH_TRINITY:$PATH
echo "PATH=$PATH"
echo "[NOTE] set java parameters"
JAVAPARAMS="-Xmx"$(python -c "print int($MEMORY_CHRYSALIS*0.75)")"g -Djava.io.tmpdir="$TMP" -XX:ConcGCThreads=1 -XX:ParallelGCThreads=1"
unset _JAVA_OPTIONS
echo "JAVAPARAMS "$JAVAPARAMS
echo -e "--NGSANE --\n" $(trigger.sh -v 2>&1)
echo -e "--JAVA --\n" $(java -Xmx200m -version 2>&1)
[ -z "$(which java)" ] && echo "[ERROR] no java detected" && exit 1
echo -e "--bowtie --\n "$(bowtie --version)
[ -z "$(which bowtie)" ] && echo "[ERROR] no bowtie detected" && exit 1
echo -e "--perl --\n "$(perl -v | grep "version" )
[ -z "$(which perl)" ] && echo "[ERROR] no perl detected" && exit 1
echo -e "--trinity --\n "$(Trinity.pl --version)
[ -z "$(which Trinity.pl)" ] && echo "[ERROR] no trinity detected" && exit 1
ulimit -s unlimited
NGSANE_CHECKPOINT_CHECK
################################################################################
NGSANE_CHECKPOINT_INIT "detect library"
# get basename of f
n=${f##*/}
SAMPLE=${n/%$READONE.$FASTQ/}
## is paired ?
if [ -e ${f/%$READONE.$FASTQ/$READTWO.$FASTQ} ]; then
PAIRED="1"
f2=${f/%$READONE.$FASTQ/$READTWO.$FASTQ}
echo "[NOTE] Paired library detected: "$f" + "$f2
else
PAIRED="0"
echo "[ERROR] Single-Strand (unpaired) library detected !!!! currently unsupported !!!!"
exit 1
fi
# fancy symbolic link generation to work in common trinity folder
mkdir -p $OUTDIR/../$TASK_TRINITY/$SAMPLE
ln -f -s ../$TASK_TRINITY/$SAMPLE $OUTDIR/$SAMPLE
# make sure we use the same tmp folder name all time so stick with one jobid
if [ ! -f $OUTDIR/$SAMPLE/persistent_id.tmp ]; then
echo "[ERROR] persistent ID not detected"
exit 1
else
PERSISTENT_ID="$(head -n 1 $OUTDIR/$SAMPLE/persistent_id.tmp)"
echo "[NOTE] Persistent ID found: $PERSISTENT_ID"
fi
NGSANE_CHECKPOINT_CHECK
###############################################################################
NGSANE_CHECKPOINT_INIT "recall files from tape"
if [ -n "$DMGET" ]; then
dmget -a ${f/$READONE/"*"}
dmget -a $OUTDIR/$SAMPLE/*
fi
NGSANE_CHECKPOINT_CHECK
################################################################################
NGSANE_CHECKPOINT_INIT "Chrysalis"
if [[ $(NGSANE_CHECKPOINT_TASK) == "start" ]]; then
mkdir -p $TMP/$PERSISTENT_ID
cp -r $OUTDIR/$SAMPLE/* $TMP/$PERSISTENT_ID
cd $TMP/$PERSISTENT_ID
echo "[NOTE] --max_reads_per_graph set to 1 million because very high I/O is needed otherwise. It is unlikely that a transcript needs more than 1 million reads to be assembled"
if [ -z "$SS_LIBRARY_TYPE" ]; then
echo "[WARN] strand-specific RNAseq library type not set ($SS_LIBRARY_TYPE): treating input as non-stranded"
RUN_COMMAND="$(which perl) $(which Trinity.pl) --seqType fq --left $f --right $f2 --output $TMP/$PERSISTENT_ID --JM $MEMORY_CHRYSALIS"G" --CPU $NCPU_CHRYSALIS --no_run_quantifygraph"
else
echo "[NOTE] RNAseq library type: $SS_LIBRARY_TYPE"
RUN_COMMAND="$(which perl) $(which Trinity.pl) --seqType fq --left $f --right $f2 --SS_lib_type $SS_LIBRARY_TYPE --output $TMP/$PERSISTENT_ID --JM $MEMORY_CHRYSALIS"G" --CPU $NCPU_CHRYSALIS --no_run_quantifygraph"
fi
echo $RUN_COMMAND && eval $RUN_COMMAND
cp -r $TMP/$PERSISTENT_ID/* $OUTDIR/$SAMPLE/
rm -r $TMP/$PERSISTENT_ID/* $OUTDIR/../$TASK_TRINITY/$SAMPLE/target.fa
ln -f -s $OUTDIR/../$TASK_TRINITY/$SAMPLE/inchworm.K25.L25.fa $OUTDIR/../$TASK_TRINITY/$SAMPLE/target.fa
cp $OUTDIR/$SAMPLE/Trinity.timing $OUTDIR/$SAMPLE.chrysalis.timing
echo "Read count:"$(head -n 1 $OUTDIR/$SAMPLE/chrysalis/readcounts.out) > $OUTDIR/$SAMPLE.summary.txt
echo "[NOTE] Chrysalis pt.1 has completed properly! thank Martin by buying him another beer"
# mark checkpoint
NGSANE_CHECKPOINT_CHECK $OUTDIR/$SAMPLE.chrysalis.timing
fi
################################################################################
[ -e $OUTDIR/$SAMPLE.chrysalis.timing.dummy ] && rm $OUTDIR/$SAMPLE.chrysalis.timing.dummy
echo ">>>>> transcriptome assembly with trinity chrysalis - FINISHED"
echo ">>>>> enddate "`date`