#!/bin/bash 

# creates database of seq limited to species list. Eco PCR gets the marker of interest;
# NCBI database may be date limited

while read LINE
    do 

ecofind -d Database.creation/ncbi20150518 "^$LINE$" >> Results_ecofind.txt

done < species_list.txt


while read LINE
    do 
    grep '[0-9].	|' > taxid.xlsx

done < Results_ecofind.txt


while read LINE
    do 
    awk '{ print $1 }'  taxid.xlsx > taxid.txt

done < taxid.xlsx


while read LINE
    do 

ecoPCR -d Database.creation/mito.insecta -c -e 5 -r "$LINE"  ggTCAACAAATCATAAAgATATTgg TAAACTTCAgggTgACCAAAAAATCA >> sequences.ecoprimers

done < taxid.txt

obiuniq sequences.ecoprimers | obiannotate --delete-tag=count | obiannotate --delete-tag=family_name | obiannotate --delete-tag=species_name | obiannotate --delete-tag=family| obiannotate --delete-tag=reverse_match| obiannotate --delete-tag=taxid| obiannotate --delete-tag=rank| obiannotate --delete-tag=forward_error| obiannotate --delete-tag=forward_tm| obiannotate --delete-tag=genus_name| obiannotate --delete-tag=seq_length_ori| obiannotate --delete-tag=forward_match| obiannotate --delete-tag=reverse_tm| obiannotate --delete-tag=genus| obiannotate --delete-tag=reverse_error| obiannotate --delete-tag=species| obiannotate --delete-tag=strand | sed 's/                  //' > New_species.NCBI.COI.fasta




