Entering edit mode
5.7 years ago
Mimmi Ahlmén
▴
30
Hello, a perl dummy here. The following script takes a input fasta file and converts it to the format swiss. How can I alter the script so that I can convert a file with any format to a new file in any other format, e.g. a universal format converter?
use strict;
use warnings;
use Bio::Seq;
use Bio::SeqIO;
my $file = 'infile.fas';
# Opens a sequence file
my $seqio = Bio::SeqIO->new( '-format' => 'fasta' , -file => $file);
# Fetch the next sequence from the stream, creates a Bio::Seq object
my $seqobj = $seqio->next_seq();
# Write the sequence to a new file, in a different format
my $out = Bio::SeqIO->new( -file => '>infile.swiss', -format => 'swiss' );
$out->write_seq($seqobj);