Professional Web Applications Themes

grep in perl - PERL Beginners

Help a perl newbie coding for a bioinfo guy please. I have a shell script that contains the following code # $1=sequence_file, $2=input_file, $3=output file, $4=chain. if [ $# != 4 ] then echo "Usage: p_pdb.sh sequence_file pdb_file output_file chain" exit fi TEMP_FILE=$$; #basename $2 >> $3 grep ^HELIX $2|sed 's/\ \ */\ /g'|cut -d" " -f1,5,6,9 >$TEMP_FILE grep ^SHEET $2|sed 's/\ \ */\ /g'|cut -d" " -f1,6,7,10 >>$TEMP_FILE p_pdb.pl $1 $TEMP_FILE $3 rm $TEMP_FILE I have to write a cgi-perl script which takes the same inputs as the shell script and pass them to the p_pdb.pl script. For that ...

  1. #1

    Default grep in perl


    Help a perl newbie coding for a bioinfo guy please.

    I have a shell script that contains the following code

    # $1=sequence_file, $2=input_file, $3=output file, $4=chain.

    if [ $# != 4 ]
    then
    echo "Usage: p_pdb.sh sequence_file pdb_file output_file chain"
    exit
    fi

    TEMP_FILE=$$;
    #basename $2 >> $3

    grep ^HELIX $2|sed 's/\ \ */\ /g'|cut -d" " -f1,5,6,9 >$TEMP_FILE
    grep ^SHEET $2|sed 's/\ \ */\ /g'|cut -d" " -f1,6,7,10 >>$TEMP_FILE

    p_pdb.pl $1 $TEMP_FILE $3

    rm $TEMP_FILE

    I have to write a cgi-perl script which takes the same inputs as the
    shell script and pass them to the p_pdb.pl script. For that I have
    to te the grep command. How can I do that using perl ? Ofcourse I
    dont have to use the shell script now.
    mk76@buffalo.edu Guest

  2. #2

    Default Re: grep in perl

    edu wrote: 

    You appear to have misunderstood the purpose of this list. It's *not*
    a "write my Perl program for me for free" list.

    If you want to learn Perl:

    http://learn.perl.org/

    If you want somebody who does the work for you:

    http://jobs.perl.org/

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Guest

  3. #3

    Default RE: grep in perl

    edu wrote: 

    If I was writing the shell script, I would have used awk (or Perl!). This
    guy maybe didn't know awk so he used grep, sed, and cut.

    Suppose you've opened the input file in your CGI script as handle IN and an
    output file corresponding to TEMP_FILE above as handle OUT. A loop to do
    what the grep/sed/cut business above is doing would look something like:

    while (<IN>) {
    my F = split;
    print OUT "F[0,4,5,8]\n" if /^HELIX/;
    print OUT "F[0,5,7,9]\n" if /^SHEET/;
    }

    Is that what you're after?
    Bob Guest

Similar Threads

  1. grep in php
    By Papa in forum PHP Development
    Replies: 2
    Last Post: March 31st, 12:46 PM
  2. using grep in perl
    By Andrew Gaffney in forum PERL Beginners
    Replies: 3
    Last Post: February 3rd, 05:03 PM
  3. perl grep..
    By John W. Krahn in forum PERL Beginners
    Replies: 0
    Last Post: January 16th, 11:30 PM
  4. grep
    By Anders Bystrup in forum PERL Miscellaneous
    Replies: 3
    Last Post: August 7th, 09:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139