# merge biology replicates
mkdir -p trinity/raw
DATAPATH=/cluster/oldgroup/extremophiles/rawdata/millet/proso_millet/mRNA/EPGSP0001
for NAME in 1-3D 1W 3W-S 8W-In 8W-L 8W-R 8W-S MS
do
ls $DATAPATH/*${NAME}*/*_R1_001.fastq.gz|xargs -I {} cat {} >> trinity/raw/${NAME}_R1.fastq.gz
ls $DATAPATH/*${NAME}*/*_R2_001.fastq.gz|xargs -I {} cat {} >> trinity/raw/${NAME}_R2.fastq.gz
done
# clean reads
adapter=$HOME/miniconda2/envs/gmatic/share/trimmomatic/adapters/TruSeq3-PE-2.fa
cd trinity/raw
for NAME in 1-3D 1W 3W-S 8W-In 8W-L 8W-R 8W-S MS
do
echo $NAME
nohup trimmomatic PE -threads 3 -phred33 ${NAME}_R1.fastq.gz ${NAME}_R2.fastq.gz ${NAME}_R1_paired.fastq.gz ${NAME}_R1_unpaired.fastq.gz ${NAME}_R2_paired.fastq.gz ${NAME}_R2_unpaired.fastq.gz ILLUMINACLIP:${adapter}:2:30:10 LEADING:3 TRAILING:3 SLIDINGWINDOW:4:15 MINLEN:36 &
done
cd - && mkdir -p trinity/clean trinity/fastqc
mv trinity/raw/*_paired.fastq.gz trinity/clean
rm trinity/raw/*_unpaired.fastq.gz
nohup fastqc -o trinity/fastqc -t 16 trinity/clean/*.fastq.gz &
# run trinity (v2.6.6)
mkdir trinity/assembly
find trinity/clean/*_R1_paired.fastq.gz -printf "%f\n"|sed -r 's/_R1.+//'|xargs -I {} Trinity --seqType fq --max_memory 100G --left trinity/clean/{}_R1_paired.fastq.gz --right trinity/clean/{}_R2_paired.fastq.gz --CPU 10 --SS_lib_type RF --output trinity/assembly/trinity_output_{} &
disown
# Sometimes Trinity seems to run forever, just kill the process and run it again.
# Before you rerun the Trinity, check the FailedCommands file and remove the failed command from recursive_trinity.cmds.ok file
# run CD-Hit
for NAME in 8W-R 8W-S MS
do
echo $NAME
nohup cd-hit-est -i trinity/assembly/trinity_output_${NAME}/Trinity.fasta -o trinity/assembly/trinity_output_${NAME}/Trinity_nr80.fasta -c 0.8 -n 4 -T 20 -M 0 &
done