########conda
# conda install multiqc 
# conda install trim-galore
# conda install RSeQC
# conda install subread
# conda install hisat2
# conda install samtools


conda activate rna
module load alignments/hisat2-2.1.0 
module load utils/samtools-1.9 
module load stringtie-2.1.5
module load tools/subread-1.6.3   
module list
module avail 

#salmon_path="/public/workspace/liyan/rna_data/clean_data/salmon-0.11.3-linux_x86_64/bin/salmon"

#index_path="/public/workspace/liyan/rna_data/clean_data/salmon-0.11.3-linux_x86_64/bin/Mm.GRCm39.Hs.GRCh38.ensembl.cdna_salmon_index"

#data_dir="/public/workspace/liyan/rna_data/newRaw_230908/Rawdata_GH"

#sample_list=("H1" "H2" "H3" "H4" "H5" "H6" "H7" "H8" "G2" "G3" "G4" "G7" "G8" "G10" "G11" "G12" "G15" "G16")

#output_dir='/public/workspace/liyan/rna_data/clean_data3/HG'



#! /bin/bash
ls /public/workspace/liyan/rna_data/clean_data/A1/*gz | xargs fastqc -t 64
multiqc ./ 



#! /bin/bash
cd /public/workspace/liyan/rna_data/clean_data/
ls /public/workspace/liyan/rna_data/H1/H1_1.fq.gz >1
ls /public/workspace/liyan/rna_data/H1/H1_2.fq.gz >2
paste 1 2  > config
 
 
dir='/public/workspace/liyan/rna_data/clean_data/H1/'
cat config |while read id
do
        arr=(${id})
        fq1=${arr[0]}
        fq2=${arr[1]} 
trim_galore -q 20 --phred33 --length 36 --stringency 3 --paired $fq1 $fq2 -o $dir   
done 


#download ref
#cd /public/workspace/liyan/rna_data/clean_data
#axel https://genome-idx.s3.amazonaws.com/hisat/grcm38_tran.tar.gz
#tar zxvf grcm38_tran.tar.gz 
#axel https://genome-idx.s3.amazonaws.com/hisat/grch38_tran.tar.gz
#tar zxvf grch38_tran.tar.gz 


#mapping
#! /bin/bash
for i in {"H1","H2","H3","H4","H5","H6","H7","H8","G2","G3","G4","G7","G8","G10","G11","G12","G15","G16"}

do
time
hisat2 -p 20 -x /public/workspace/liyan/rna_data/clean_data/grch38_tran/genome_tran -1 /public/workspace/liyan/rna_data/clean_data/${i}_1_val_1.fq.gz -2 /public/workspace/liyan/rna_data/clean_data/${i}_2_val_2.fq.gz -S /public/workspace/liyan/rna_data/clean_data/sam_aligned/${i}.sam
time
done




#! /bin/bash
for i in {"H1","H2","H3","H4","H5","H6","H7","H8","G2","G3","G4","G7","G8","G10","G11","G12","G15","G16"}

do
samtools view -@ 20 -S /public/workspace/liyan/ran_data/clean_data/sam_aligned/${i}.sam -1b -o /public/workspace/liyan/rna_data/clean_data/bam/${i}.bam
samtools sort -@ 20 -l 9 -o /public/workspace/liyan/rna_data/clean_data/bam/bam_sort/${i}.bam.sort /public/workspace/liyan/rna_data/clean_data/bam/${i}.bam
samtools index -@ 20 /public/workspace/liyan/rna_data/clean_data/bam/bam_sort/${i}.bam.sort /public/workspace/liyan/rna_data/clean_data/bam/bam_index/${i}.bam.index
samtools flagstat -@ 20 /public/workspace/liyan/rna_data/clean_data/bam/bam_sort/${i}.bam.sort > /public/workspace/liyan/rna_data/clean_data/bam/bam_flagstat/${i}.bam.flagstat
time
done


