Skip to content

Instantly share code, notes, and snippets.

@sestaton
Last active November 17, 2015 15:44
Show Gist options
  • Save sestaton/3363783c73764f484e0e to your computer and use it in GitHub Desktop.
Save sestaton/3363783c73764f484e0e to your computer and use it in GitHub Desktop.
minimal genbank to fasta conversion
use strict;
use warnings;
my ($def, $seq);
while (<>) {
if (/^DEFINITION\s+(\S+.*)$/) {
$def = $1;
}
if (/^ORIGIN/) {
while (<>) {
chomp;
last if /^\/\//;
s/^\s+?\d+\s|^\d+\s//;
s/\s//g;
$seq .= $_;
}
}
}
die "\nERROR: No sequence in this record." unless $seq;
$seq =~ s/(.{60})/$1\n/gs;
print join "\n", ">".$def, "$seq\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment