Last active
November 17, 2015 15:44
-
-
Save sestaton/3363783c73764f484e0e to your computer and use it in GitHub Desktop.
minimal genbank to fasta conversion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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