I have a file given below:
>AAF88103.1 zinc finger protein 226 [Homo sapiens]
MNMFKEAVTFKDVAVAFTEEELGLLGPAXRKLYRDVMVENFRNLLSVGHPPFKQDVSPIERNEQLWIMTT
ATRRQGNLGEKNQSKLITVQDRESEEELSCWQIWQQIANDLTRCQDSMINNSQCHKQGDFPYQVGTELSI
QISEDENYIVNKADGPNNTGNPEFPILRTQDSWRKTFLTESQRLNRDQQISIKNKLCQCKKGVDPIGWIS
HHDGHRVHKSEKSYRPNDYEKDNMKILTFDHNSMIHTGQKSYQCNECKKPFSDLSSFDLHQQLQSGEKSL
TCVERGKGFCYSPVLPVHQKVHVGEKLKCDECGKEFSQGAHLQTHQKVHVIEKPYKCKQCGKGFSRRSAL
NVHCKVHTAEKPYNCEECGRAFSQASHLQDHQRLHTGEKPFKCDACGKSFSRNSHLQSHQRVHTGEKPYK
CEECGKGFICSSNLYIHQRVHTGEKPYKCEECGKGFSRPSSLQAHQGVHTGEKSYICTVCGKGFTLSSNL
QAHQRVHTGEKPYKCNECGKSFRRNSHYQVHLVVHTGEKPYKCEICGKGFSQSSYLQIHQKAHSIEKPFK
CEECGQGFNQSSRLQIHQLIHTGEKPYKCEECGKGFSRRADLKIHCRIHTGEKPYNCEECGKVFRQASNL
LAHQRVHSGEKPFKCEECGKSFGRSAHLQAHQKVHTGDKPYKCDECGKGFKWSLNLDMHQRVHTGEKPYK
CGECGKYFSQASSLQLHQSVHTGEKPYKCDVCGKVFSRSSQLQSHQRVHTGEKPYKCEICGKSFSWRSNL
TVHHRIHVGDKSYKSNRGGKNIRESTQEKKSIK.
In this file i am trying to look for a sequence ie: CDECGKEFSQGAHLQTHQKVH I have to hardcode this pattern in the program and then look for it, my code is as follows
open FILE1, "file.fasta" or die;
while (my $line= <FILE1>) {
chomp $line;
}
if ($line =~ /CDECGKEFSQGAHLQTHQKVH/) {
print "The protein contains the domain";
}else{
print "The protein doesn't contain the domain";
}
Now this pattern occurs in the sequence but i always get the message "The protein doesn't contain the domain". Am i doing it wrong?
The $line evaluation occurs outside of the loop... Give this a try:
my $found = 0;
open(my $fh, '<', 'file.fasta') or die "Could not open file '$filename': $!";
while (my $line = <$fh>) {
if ($line =~ /CDECGKEFSQGAHLQTHQKVH/) {
$found = 1;
last;
}
}
if ($found == 1) {
print "The protein contains the domain";
} else {
print "The protein doesn't contain the domain";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.