#!/bin/bash 

#pairwise_alignment
#Database.Reads.fasta is a concatenated file of the database and the reads file 

vsearch --allpairs_global Database.Reads.fasta --iddef 3 --alnout Database.Reads.alnout --id 0.96 --qmask none --target_cov 0.90 --fasta_width 0 --threads 4 --userfields query+target+id3 --userout Database.Reads.tabout --gapopen *QL/*TL

#clustering
python clusterFromPairs.py Database.Reads.tabout Database.Reads.fasta

#analysis
python clusterAnalysis.py Database.Reads_clusters.tsv Database.Reads.tabout Reads.fasta species_names.txt


# database of fasta files and reads are concatenated, appended and dereplicated -> input for clustering. building a cluster considers all against all and forms clusters (Cluster from pairs). Cluster Analysis -> highest id between and one of the references, differentiate what comes from reads and what comes from database. output is reads to database and % ID. closest ind seq in the database vs identity to another seq to allow mismatches between seq and database