[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Could you take a look



I don't know if i did not formulate the problem right. This is what I wanted.
The GI- number in File2 is a smaller subset of possible GI-in File 1 (This has the matching GI plus the sequence I am interested in).
(Or. I want to pull all the sequences from file-1 using the GI listed in File 2)
kiran

On 1/19/07, Jay Hannah <jay@jays.net > wrote:
On Jan 19, 2007, at 7:18 AM, kiran bina wrote:
> Could you please take a look at this.
> <test.zip>

Hi again Kiran.  :)


Your code (as viewed in the debugger):


   DB<6> l 9-15
9:      while (my $line=<IN1>)
10      {
11:         if ($line=~ m/\>\s+/)
12          {
13:             $line=~ m/^(\S+)\>\s(\S+)$/;
14==>           my $read = $1;
15:             my $value= $2;


Your first problem is that $line has carriage returns and/or newlines
at the end, so your regex demand that the line end with \S+ fails.

I'll step past the regex and show you the newlines:


                                                  main::(test.pl:
13):             $line=~ m/^(\S+)\>\s(\S+)$/;

DB<1> n
main::(test.pl:14):             my $read = $1;





      DB<3> p "[$line]"
[a> APPLE
]


Now normally you could just 'chomp $line;', but that didn't work for
me on your data. Perhaps because my Mac defines newlines differently
than wherever you made your file? Even after I added chomp it still
wasn't working, so I x'd it in the debugger to see why not:


   DB<3> x $line
0  "a> APPLE\cM"


Bummer. I believe "\r\n" (carriage return, linefeed) is interpreted
as Control-M, So I added a regex to remove all carriage returns and
linefeeds


     $line =~ s/[\r\n]//g;


(chomp might work fine for you.)

The next annoyance was all these warnings:


Use of uninitialized value in string eq at test.pl line 43, <IN1>
line 5.


Which you can avoid by NOT running look_up_order() if there is no
$value. I don't know if that's what you wanted to do or not, but you
can do that with this line


         next unless ($value);  #  No value in file...


So your code now reads like this:


while (my $line=<IN1>)
{
     $line =~ s/[\r\n]//g;
     if ($line=~ m/\>\s+/)
     {
         $line=~ m/^(\S+)\>\s(\S+)$/;
         my $read = $1;
         my $value= $2;
         next unless ($value);  #  No value in file...


which seems to work?


$ perl test.pl
a
APPLE
b
BOY
d
DOG


?

Lower, your look_up_order() doesn't seem to do anything at all. Were
you wanting it to pull values out of File2 if File1 didn't have a
$value or something?

HTH,

j


_______________________________________________
Omaha-pm mailing list
Omaha-pm@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm



--
Dhundy R. Bastola
Assistant Professor
Department of Pediatrics
University of Nebraska Medical Center
Omaha NE 68198
Always reply to: dbastola@unmc.edu