parsing text

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • idorjee
    New Member
    • Mar 2007
    • 76

    #1

    parsing text

    Hi,
    Can anyone please tell me how should I be parsing the following text file so that I could retrieve just the text following FUNCTION: and next two lines without the CC?

    --------------------- Input text file ---------------------------
    CC -!- FUNCTION: Involved in the secretion of a proteinaceous elicitor of
    CC the hypersensitivit y response in plants. Also required for
    CC pathogenicity on host plant.
    CC -!- SIMILARITY: Belongs to the hrpJ/yopN family.
    ---------------------------------------------------------------------

    This is how I started with:
    Code:
    if($ln =~ /^CC/){
    $ln =~ s/\n//g;
    next;
    }
    Thanks
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    A very contrived suggestion:

    [CODE=perl]use strict;
    use warnings;
    my $output = '';
    while( <DATA> ) {
    if (/\QCC -!- FUNCTION:\E\s*([\s\S]+)/) {
    $output = $1;
    $output .= <DATA>;
    $output .= <DATA>;
    $output =~ s/CC\s+//g;
    last;
    }
    }
    print $output;
    __DATA__
    CC -!- FUNCTION: Involved in the secretion of a proteinaceous elicitor of
    CC the hypersensitivit y response in plants. Also required for
    CC pathogenicity on host plant.
    CC -!- SIMILARITY: Belongs to the hrpJ/yopN family.[/CODE]

    Comment

    • idorjee
      New Member
      • Mar 2007
      • 76

      #3
      Thanks a lot, KevinADC.


      Originally posted by KevinADC
      A very contrived suggestion:

      [CODE=perl]use strict;
      use warnings;
      my $output = '';
      while( <DATA> ) {
      if (/\QCC -!- FUNCTION:\E\s*([\s\S]+)/) {
      $output = $1;
      $output .= <DATA>;
      $output .= <DATA>;
      $output =~ s/CC\s+//g;
      last;
      }
      }
      print $output;
      __DATA__
      CC -!- FUNCTION: Involved in the secretion of a proteinaceous elicitor of
      CC the hypersensitivit y response in plants. Also required for
      CC pathogenicity on host plant.
      CC -!- SIMILARITY: Belongs to the hrpJ/yopN family.[/CODE]

      Comment

      Working...