0
我正在創建一個程序,用於確認給定的核苷酸序列是否是迴文序列。該腳本創建一個反向補語並將其與原始序列進行比較,確認它是否爲迴文,如果2匹配。問題是我的腳本會一直說它不是迴文,即使它是。預期輸出的無論值如何,腳本都返回false
#!/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