comparing sentences

Hi,

I have a file and that file contains the following sentences.

Here we show that a virus-encoded transcription factor, viral mRNA, cellular RNA-binding protein heterodimer G3BP/Caprin-1 (p137), translation initiation factors eIF4E and eIF4G, and ribosomal proteins are concentrated in the same subdomains of cytoplasmic DNA factories
The single-stranded DNA- and RNA-binding protein, Puralpha, has been implicated in many biological processes, including control of transcription of multiple genes, initiation of DNA replication, and RNA transport and translation
RNA-binding proteins are involved in processes such as protection of RNAs from RNase degradation, prevention of ribosome binding to mRNA, control of formation of secondary structures of the mRNA that permit or prevent translation initiation, and termination/antitermination of transcription in response to external signals
d)The La autoantigen is an RNA-binding protein that is involved in initiation and termination of RNA polymerase III transcription

Here is the code to match the sentence.

//Suppose if this is my input string

$str="Here we show that a virus-encoded transcription factor, viral mRNA, cellular RNA-binding protein heterodimer G3BP/Caprin-1 (p137), translation initiation factors eIF4E and eIF4G, and ribosomal proteins are concentrated in the same subdomains of cytoplasmic DNA factories";

open(FH,"sample.txt");
while(<FH>)
{
    if($_=~/$str/)
   {
      print "matched\n";
   }
  else
  {
     print "not match\n";
  }
}
close FH;

If the above string is matching it should print matched but even though that sentences is there still it is not matcing.

How should i match the above sentence?

How can i match sentences like these in perl?

With regards
Vanitha

Ignore

a)
b)
c)
d)

and try

Hi.

Some special characters need to be escaped in patterns. I did that here with the parens in scalar str:

#!/usr/bin/perl

# //Suppose if this is my input string

use warnings;

$str='Here we show that a virus-encoded transcription factor, viral mRNA, cellular RNA-binding protein heterodimer G3BP/Caprin-1 \(p137\), translation initiation factors eIF4E and eIF4G, and ribosomal proteins are concentrated in the same subdomains of cytoplasmic DNA factories';

open(FH,"sample.txt");
while(<FH>)
{
    if($_=~/$str/)
    # if($_=~ m|$str|)
   {
      print "matched\n";
   }
  else
  {
     print "not match\n";
  }
}
close FH;

Producing (with your data):

% ./p1
matched
not match
not match
not match

The commented if is how I often code conditional matching statements ... cheers, drl

Hi,

That is just for my refrence sake i have written !!!!

without that also it is not working!!!

Hi,

I tried but still its not matching!!!

Its giving not match only !!!

what else can be done?

With regards
Vanitha