#!/bin/bash

#/data/results/tools/align/cufflinks-2.2.1.Linux_x86_64/
LABELS[1]="GM-tr-0h-a"
LABELS[2]="GM-tr-0h-b"
LABELS[3]="GM-tr-1h-a"
LABELS[4]="GM-tr-1h-b"
LABELS[5]="GM-tr-3h-a"
LABELS[6]="GM-tr-3h-b"
LABELS[7]="GM-untr-0h-a"
LABELS[8]="GM-untr-0h-b"


#BASE_DIR=/home/dimopoulos/TopHat_test/

#rm time_Cuff-mm9.txt
CONCUR=1
THREADS=8

echo BEGIN Cufflinks witth $CONCUR Concurrent and $THREADS threads `date` >> time_Cuff-mm9.txt
for i in `seq 2 8`
#for i in `seq 5 5`
do
echo ${LABELS[$i]}

#-F/--min-isoform-fraction <0.0-1.0>	 After calculating isoform abundance for a gene, Cufflinks filters out transcripts that it believes are very low abundance, because isoforms expressed at extremely low levels often cannot reliably be assembled, and may even be artifacts of incompletely spliced precursors of processed transcripts. This parameter is also used to filter out introns that have far fewer spliced alignments supporting them. The default is 0.1, or 10% of the most abundant isoform (the major isoform) of the gene.
#http://seqanswers.com/forums/showthread.php?p=76430
#--no-effective-length-correction	 Cufflinks will not employ its "effective" length normalization to transcript FPKM.
#/home/reczko/tools/align/cufflinks-2.1.1.Linux_x86_64/cufflinks --upper-quartile-norm -L ${LABELS[$i]} --no-update-check --library-type fr-unstranded --num-threads $THREADS -q -o ${OUT_DIR[$i]}/accepted_hits3 ${IN_DIR[$i]}/accepted_hits.bam 

samtools reheader /data/results/reference/hsa/GRCh37/human_g1k_v37.dict bams/${LABELS[$i]}.bam  > bam
/data/results/tools/samtools/mysamtools-0.1.19/samtools sort -@ 8 bam sorted.bam
rm bam
mv sorted.bam.bam bams/${LABELS[$i]}.bam2 
#rm sorted.bam.bam
/data/results/tools/align/cufflinks-2.2.1.Linux_x86_64/cufflinks --no-effective-length-correction  -g /data/results/reference/hsa/GRCh37/Homo_sapiens.GRCh37.75.gtf -L ${LABELS[$i]} --no-update-check --library-type fr-secondstrand --num-threads $THREADS -q -o ${LABELS[$i]}/accepted_hits_ensembl_novel bams/${LABELS[$i]}.bam2
#sem -j $CONCUR /data/results/tools/align/cufflinks-2.1.1.Linux_x86_64/cufflinks --no-effective-length-correction -G /data/results/reference/hg19/Homo_sapiens/UCSC/hg19/Annotation/Genes/genes.gtf -L ${LABELS[$i]} --no-update-check --library-type fr-secondstrand --num-threads $THREADS -q -o ${LABELS[$i]}/accepted_hits tracks/${LABELS[$i]}.bam

done

exit
#sem --wait

for i in `seq 1 2`
#for i in `seq 5 5`
do
echo ${LABELS[$i]}

#sem -j $CONCUR /home/reczko/tools/align/cufflinks-2.1.1.Linux_x86_64/cuffcompare -o ${OUT_DIR[$i]}/cuffcompare  -R -s /mnt/raid/data/reference/mmu/Mus_musculus/UCSC/mm9/Sequence/WholeGenomeFasta/genome.fa  -r /mnt/raid/data/reference/mmu/Mus_musculus/UCSC/mm9/Annotation/Archives/archive-2013-03-06-15-01-24/Genes/genes.gtf ${OUT_DIR[$i]}/accepted_hits3/transcripts.gtf

#sem -j $CONCUR cuffcompare -o ${OUT_DIR[$i]}/cuffcompare  -R -s /mnt/raid/data/reference/mmu/nocolor/mm9.fa  -r /mnt/raid/data/reference/mmu/filter/mm9-rRNAtRNA.gtf  ${OUT_DIR[$i]}/accepted_hits3/transcripts.gtf

done

sem --wait

echo END Cufflinks witth $CONCUR Concurrent and $THREADS threads `date` >> time_Cuff-mm9.txt
echo "************************ " >> time_Cuff-mm9.txt
echo "************************ " >> time_Cuff-mm9.txt
exit


