Perl脚本求得反向互补序列函数如下:
sub reverse_complement_IUPAC {
my $dna = shift;
# reverse the DNA sequence
my $revcomp = reverse($dna);
# complement the reversed DNA sequence
$revcomp =~ tr/ABCDGHMNRSTUVWXYabcdghmnrstuvwxy/TVGHCDKNYSAABWXRtvghcdknysaabwxr/;
return $revcomp;
}
sub reverse_complement {
my $dna = shift;
# reverse the DNA sequence
my $revcomp = reverse($dna);
# complement the reversed DNA sequence
$revcomp =~ tr/ACGTacgt/TGCAtgca/;
return $revcomp;
}
用法,以reverse_complement 为例:
$str = &reverse_complement($a);
#$a变量里存放序列字符串,$str为求得的反向互补序列。
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!