TP métagénomique

16S_workflow.sh 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. raw_reads_dir=$1
  3. output_dir=$2
  4. mkdir $output_dir
  5. mkdir trimmed_reads
  6. #TRIM READS WITH ALIENTRIMMER
  7. for R1 in $(ls $raw_reads_dir/*R1.fastq);
  8. do
  9. R2=`echo $R1 | sed 's/R1/R2/g'`
  10. oR1=`echo $R1 | sed 's/\.fastq/\.at\.fq/g'`
  11. oR1=`echo $oR1 | sed 's/fastq\///g'`
  12. oR2=`echo $R2 | sed 's/\.fastq/\.at\.fq/g'`
  13. oR2=`echo $oR2 | sed 's/fastq\///g'`
  14. java -jar soft/AlienTrimmer.jar -if $R1 -ir $R2 -q 20 -c databases/contaminants.fasta -of trimmed_reads/$oR1 -or trimmed_reads/$oR2
  15. done
  16. # MERGE READS AND OUTPUT FASTA
  17. mkdir fasta
  18. for R1 in $(ls trimmed_reads/*R1.at.fq);
  19. do
  20. R2=`echo $R1 | sed 's/R1/R2/g'`
  21. outname=`echo $R1 | sed 's/_R1\.at\.fq/\.fasta/g'`
  22. label=`echo $outname | sed 's/trimmed_reads\///g'`
  23. outname=`echo $outname | sed 's/trimmed_reads/fasta/g'`
  24. label=`echo $label | sed 's/\.fasta//g'`
  25. soft/vsearch --fastq_mergepairs $R1 --reverse $R2 --fastaout $outname --label_suffix ";sample=$label;"
  26. done
  27. # MERGE ALL FASTAS TO 'amplicon.fasta'
  28. cat fasta/*.fasta > fasta/amplicon.fasta
  29. # REMOVE ' ' FROM EACH READ NAME
  30. sed -i 's/ //g' fasta/amplicon.fasta
  31. # CREATE OTU
  32. # DEDUPLICATION
  33. mkdir otu
  34. soft/vsearch --derep_fulllength fasta/amplicon.fasta --output otu/fulllength_otu.fasta
  35. soft/vsearch --derep_prefix fasta/amplicon.fasta --output otu/prefix_otu.fasta
  36. # REMOVING SINGLETON
  37. soft/vsearch --derep_fulllength fasta/amplicon.fasta --output otu/fulllength_min10_otu.fasta --minuniquesize 10
  38. soft/vsearch --derep_prefix fasta/amplicon.fasta --output otu/prefix_min10_otu.fasta --minuniquesize 10
  39. # REMOVING CHIMERAS
  40. soft/vsearch --uchime_denovo otu/prefix_min10_otu.fasta --nonchimeras otu/prefix_min10_nochim_otu.fasta
  41. soft/vsearch --uchime_denovo otu/fulllength_min10_otu.fasta --nonchimeras otu/fulllength_min10_nochim_otu.fasta