Hello all, I would like to know whether there is a way to split a multi fasta file into several individual files and store all of them in one specific folder using IO::File, IO::File::WithPath; and Bio::SeqIO from Perl. I was trying to do it and I achieved split the multi fasta file into several files according to the sequences number, but I didn't get store all of them in a specific folder. All of them are stored directly at the path where I run the script. Am I doing something wrong with the command lines or maybe I need to use another module?
use IO::File::WithPath;
use Bio::SeqIO;
my $io = IO::File->new('path_new_folder_to_store_fasta_sequences', '>:utf8');
my $infile = "path_fasta_file";
my $seq_in = Bio::SeqIO->new( -file => $infile, -format => "fasta", );
while (my $inseq = $seq_in->next_seq) {
my $id = $inseq->id();
my $seq = $inseq->seq();
$io = IO::File->new(">$id.fasta");
print $io ">$id\n$seq\n";
}
Thanks in advance!
Thank you very much. A simple and effective solution