#! /bin/bash
# aligns the two reads and returns the reconstructed sequence.-----------------------
illuminapairedend --score-min=35 -r frog_R.fastq frog_F.fastq > frog.fastq

# Unaligned sequences (mode=joined) cannot be used --------------------
obigrep -p 'mode!="joined"' frog.fastq > frog.ali.fastq

# assign sample. --------------------------------------------
ngsfilter -t frog_ngsfilter.txt -u unidentified.fastq frog.ali.fastq > frog.ali.assigned.fastq

# keep the information of the samples of origin for each unique sequence---------------------------------------
obiuniq -m sample frog.ali.assigned.fastq > frog.ali.assigned.uniq.fasta

# To keep only these two key=value attributes ---------------------------
obiannotate -k count -k merged_sample frog.ali.assigned.uniq.fasta > $$ ; mv $$ frog.ali.assigned.uniq.fasta

# we set the cut-off for keeping sequences for further analysis to a count of 10, remove sequences with a length shorter than 30 bp or longer than 130 bp--------------
obigrep -l 30 -L 130  -p 'count>=10' frog.ali.assigned.uniq.fasta  > frog.c10.fasta

# we keep the head sequences (-H option) that are sequences with no variants with a count greater than 5% of their own count -----------------
obiclean -s merged_sample -r 0.05 -H frog.c10.fasta > frog.clean.fasta

# taxonomic assignment be carried out using the ecotag command.------------------------
ecotag -d ./ECODB/embl_last -R own_reference.fasta frog.clean.fasta > frog.clean.tag.fasta

# generate tab file--------------------------------------
obitab -o frog.clean.tag.fasta > frog.tab
