#!/bin/bash
#SBATCH -t 4:00:00
#SBATCH --nodes=1 --ntasks-per-node=1
#SBATCH --mem=144g
#SBATCH --export=NONE
#SBATCH --mail-user=alex_labossiere@uri.edu
#SBATCH --mail-type=BEGIN,END,FAIL

module load QIIME2/2024.2

rawdir=/data/mramseylab/16S/proc_reads/2022_AL_SUPP/2022
visdir=/data/mramseylab/16S/proc_reads/2022_AL_SUPP/2022
metadata=/data/mramseylab/16S/metadata/plaque_meta_2.tsv
# table summarize will give info on how many sequences are associated with each sample. This has useful graphs and info w/ sum. stats.
# table tabulate-seqs will map feature IDs to sequences and BLAST that to NCBI. this stuff will be used later on

qiime dada2 denoise-single \
  --i-demultiplexed-seqs $rawdir/2022-demux-trips.qza \
  --p-trim-left 6 \
  --p-trunc-len 266 \
  --o-representative-sequences $visdir/rep-seqs-single-2022.qza \
  --o-table $visdir/table-single-2022.qza \
  --o-denoising-stats $visdir/stats-dada2-single-2022.qza


# I think FeatureTables and Feature data summaries are next. Mix from perera and qiime moving pictures.
# table summarize will give info on how many sequences are associated with each sample. This has useful graphs and info w/ sum. stats.
# table tabulate-seqs will map feature IDs to sequences and BLAST that to NCBI. this stuff will be used later on
#will likely be the slowest script to run

qiime feature-table summarize \
  --i-table $rawdir/table-single-2022.qza \
  --o-visualization $visdir/table-sum-2022-single.qzv \
  --m-sample-metadata-file $metadata \

qiime feature-table tabulate-seqs \
  --i-data $rawdir/rep-seqs-single-2022.qza \
  --o-visualization $visdir/rep-seqs-single-2022.qzv

#now it seems that phylogeny is next
#qiime2021.11 code is shorter and gives us same artifacts

qiime phylogeny align-to-tree-mafft-fasttree \
  --i-sequences $rawdir/rep-seqs-single-2022.qza \
  --o-alignment $rawdir/aligned-rep-seqs-2022-single.qza \
  --o-masked-alignment $rawdir/masked-aligned-rep-seqs-2022-single.qza \
  --o-tree $rawdir/unrooted-tree-2022-single.qza \
  --o-rooted-tree $rawdir/rooted-tree-2022-single.qza
