Hi Aiguo,

At 10:17 AM 2/22/2005 -0500, Li, Aiguo (NIH/NCI) wrote:
Hi, all.

I have the following data from a file.
__data from file IN__
SNP_A-1512608   23      148840899       0.828109        0.823391
11128
SNP_A-1512550   23      148841154       1.717397        1.750476
11129
SNP_A-1518843   23      149078514       0.832285        0.99744 11130
SNP_A-1507809   23      149080794       1.463225        1.463085
11131
SNP_A-1519263   23      149309465       0.990172        1.124282
11132
SNP_A-1512795   23      149514662       1.37836 1.51924 11133
SNP_A-1518711   23      149890944       1.541307        1.920374
11134
SNP_A-1517959   23      150083331       0.535966        0.942863
11135

While I trying to get a difference between column 4 and column5, I got the
following error message:
"Argument "STD" isn't numeric in subtraction (-) at cpdiffer.pl line 19,
<IN> lin
e 1.
Argument "gli3ak" isn't numeric in subtraction (-) at cpdiffer.pl line 19,
<IN>
line 1."

it seems you didn't include header line in you sample here.

MY QUESTIONS IS: why perl treat the numeric value in column 4 as string and
how to convert it?

Thanks,

AG Lee
The code is as below:

#!/bin/perl -w

#use strict;
use warnings;

my $differ;


open (IN, "C:/perl/work/data/cpdata.txt") or die ("Can not open cpdata.txt file! \n"); open (OUT, ">C:/perl/work/data/cpout.txt") or die ("Can not open cpout.txt file! \n");

# if you have header line in your data file, do:

my $header = <in>;

while(my $line = <IN>)
{
chomp $line;

my ($snp, $chro, $location, $gli3ak, $std, $rest) = split(/\t/, $line);
#print $line;
#print "$snp, $chro, $location, $gli3ak, $std, $rest\n";

$differ = $gli3ak-$std;

if(($differ >= 2) || ($differ <= -1.5))
        {

        print OUT "$snp\t$chro\t$location\t$gli3ak\t$std\t$rest\n";
        }

}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to