use strict; use warnings; my $seq = "MTVLLLVVLQMWKATAGHSIAVSQDDGADDWETDPDFVNDVSEKEQRWGAKTVKGSGHQE"; my $peptide = getPeptide($seq,2,7,7); print $peptide; sub getPeptide { my ($seq, $site, $left, $right) = @_; my $len = length($seq); die " > seq length: $len\n" if $len < $site; die "'$site' < 1\n" if $site < 1; $seq = ("*" x $left).$seq.("*" x $right); my $peptide = substr($seq, $site - 1, $right + $left + 1); return $peptide; }