Skip to content

Instantly share code, notes, and snippets.

@cjfields
Created August 12, 2009 21:05
Show Gist options
  • Save cjfields/166764 to your computer and use it in GitHub Desktop.
Save cjfields/166764 to your computer and use it in GitHub Desktop.
my $gs = ${$self->symbols}{GAP};
# map gaps prior and post start/end
my ($newst, $newend) = ($start, $end);
while ($rawseq =~ m{([$gs]+)}g) {
my $len = CORE::length($1);
my $current = pos($rawseq) - $len;
# optimization : bail if current gap is past the end
last if $current >= $newend;
$newst += $len if $current <= $newst;
$newend += $len if $current <= $newend;
}
$seqstr = substr($rawseq, $newst, $newend -$newst + 1);
$seqstr =~ s/[$gs]//g unless $gaps;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment