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

module load QIIME2/2019.7


tablein=/data/mramseylab/proc_reads/fil-nocontrol/table-filtered_NoControls.qza
clsdir=/data/mramseylab/classifiers/silva-taxonomy-AL/silva-mod-taxonomy-AL.qza
filtdir=/data/mramseylab/proc_reads/
fil=taxon-filtered
# filter status of input files
#must make the directory you are filtering to 1st or else it will error
mkdir $filtdir$fil

qiime taxa filter-table \
  --i-table $tablein  \
  --i-taxonomy $clsdir \
  --p-mode contains \
  --p-exclude "Eukaryota"  \
  --o-filtered-table $filtdir$fil/taxon-filtered-table.qza
#this is done to take away IDd host within samples
#Use excluded table to generate barplot for checking
done

qiime taxa barplot \
  --i-table $filtdir/taxon-filtered/taxon-filtered-table.qza \
  --i-taxonomy $clsdir \
  --m-metadata-file $metadir \
  --o-visualization $filtdir$fil/taxon-filtered-table-barplot.qzv

  #use this to see if filtering worked

#Generate viewable feature table to look for ASVs of interest / filtering stats
qiime feature-table summarize \
  --i-table $filtdir/taxon-filtered/taxon-filtered-table.qza \
  --o-visualization $filtdir$fil/taxon-table-for-looking.qzv \
  --m-sample-metadata-file $metadir
