#!/usr/bin/perl -w 

open TXT1 , "<./target_fasta_8_taxon_species_remove_unwanted.txt" or die "can't open file1:$!";

$out_dir = "./fna_8_taxon_species_remove_unwanted";
system "rm  -rf $out_dir";
system "mkdir $out_dir";


while(<TXT1>)
{
	chomp;
    
	if($_=~ /^\>(\d+)\s+.*/)
	{         
		$gi = $1;

		$out_file = "$out_dir/$gi.fna";
		open OUT , ">>./$out_file";

		print OUT "$_\n";
		
	}else{

		print OUT "$_\n";

	}
		
}

