【发布时间】:2016-03-07 14:46:38
【问题描述】:
我正在创建一个程序来确认给定的核苷酸序列是否是回文。该脚本创建一个反向补码并将其与原始序列进行比较,确认如果 2 匹配,它是一个回文。问题是我的脚本总是会声明它不是回文,即使它是。
#!/usr/bin/perl
use strict;
print "Enter the sequence\n";
my $seq = <STDIN>;
my $r=reverse($seq);
$r =~ tr/ACTGactg/TGACtgac/;
print "Reverse complement: $r \n";
if ($r eq $seq) {
print "The sequence is a palindrome\n";
} else {
print "The sequence is NOT a palindrome\n";
}
预期输出示例:
Enter the sequence:
CG
Reverse complement:
CG
The sequence is a palindrome
【问题讨论】:
标签: perl string-matching palindrome dna-sequence