#!/bin/bash

#$ -q rg-el6,long
#$ -N GEMPIPELINE_Pc
#$ -e /users/rg/fcamara/Research/geneid_training/P.cucumerina/data/set1/gempipelinePc.log
#$ -o /users/rg/fcamara/Research/geneid_training/P.cucumerina/data/set1/gemepipelinePc.log
#$ -pe smp 8
#$ -l  virtual_free=48G
#$ -l h_rt=64:00:00

##$ -M fcamaraferreira@gmail.com
##$ -m ab

. /etc/profile

. ~fcamara/.bashrcant

export DIR=/users/rg/fcamara/Research/geneid_training/P.cucumerina/data/set1

#DIRECTORY CONTAINING THE OUTPUT OF MAPPING OF READS

mkdir -p $DIR/results


cd $DIR;

#MODIFIED GEMTOOLS TEMPLATE
./gemtools_pipeline.py

cd $DIR/results

samtools view -F 4 SPECIES_mapping.bam > SPECIES_mapping_mapped_reads.sam

samtools view -bT $DIR/SPECIES_GENOME.fa SPECIES_mapping_mapped_reads.sam >SPECIES_mapping_mapped_reads.bam

####IMPORTANT!!!
###modifyGEMSAM4CUFFLINKS always modify hash according to start fasta
##


samtools view Pcucumerina_mapping_mapped_reads.bam | ../modifyGEMSAM4CUFFLINKS.py > Pcucumerina_mapping4cufflinks_mapped_only.sam


#samtools view $DIR/results_lp21_noqual/lp21longestscaffolds_mapping.bam | $DIR/modifyGEMSAM4CUFFLINKS.py > $DIR/results_lp21_noqual/lp21longestscaffolds_mapping4cufflinks.bam























