Skip to content

Instantly share code, notes, and snippets.

@slavailn
Created April 26, 2016 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slavailn/81ad90ddd25b8816d3f640e9cca2e7e2 to your computer and use it in GitHub Desktop.
Save slavailn/81ad90ddd25b8816d3f640e9cca2e7e2 to your computer and use it in GitHub Desktop.
#! /usr/bin/perl
# Universal? bioperl format converter
use strict; use warnings;
use Bio::SeqIO;
use Getopt::Long;
my $usage = "format_converter.pl --in-file <input_file> --in-format <input_file_format> --out-file <output_file> --out-format <output_file_format>\n";
my $in_file;
my $in_format;
my $out_file;
my $out_format;
GetOptions(
'in-file=s' => \$in_file,
'in-format=s' => \$in_format,
'out-file=s' => \$out_file,
'out-format=s' => \$out_format,
) or die $usage;
my $seq_in = Bio::SeqIO->new( -file => "<$in_file",
-format => $in_format, );
my $seq_out = Bio::SeqIO->new( -file => ">$out_file",
-format => $out_format, );
while ( my $inseq = $seq_in->next_seq )
{
$seq_out->write_seq($inseq);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment