iterate_seqs.pl
use Bio::SeqIO;
getArgsAndPrompt();
$in = Bio::SeqIO->new('-file' => "$inFile", '-format' => $inFormat);
while ($seqobj = $in->next_seq())
{
$seqID = $seqobj->display_id();
$seqFile = $seqID . ".$outFormat";
$out = Bio::SeqIO->new('-format' => $outFormat, -file => ">$seqFile");
$out->write_seq($seqobj);
print "Creating $seqFile\n";
}
print "\nAll done\n";
sub getArgsAndPrompt
{
if (! $ARGV[0])
{
print "\nSplit a file of multiple sequences into separate files\n";
print "\nUSAGE: $0 fastaInput inputFormat outputFormat\n";
print "What is the fasta file to process? ";
chomp ($inFile = <STDIN>);
}
else
{
$inFile = $ARGV[0];
}
if (! $ARGV[1])
{
print "\nWhat is the format of your input sequence file?\n";
print "Options: fasta, embl, genbank, pir, swiss, gcg\n";
chomp ($inFormat = <STDIN>);
}
else
{
$seqFormat = $ARGV[1];
}
if (! $ARGV[2])
{
print "\nWhat format files should be created?\n";
print "Options: fasta, embl, genbank, pir, swiss, gcg, raw\n";
chomp ($outFormat = <STDIN>);
}
else
{
$seqFormat = $ARGV[2];
}
}