hello, all.
I need to transform the column3 data from an input file as indicated below
into three values: 0, 0.4, 1.
if there are more than 3 NoCall continuously in column3, change NoCall into
"1". this option has the highest precedence.
for the rows where column2 is between 52 and 105 (range from a file),
transform the values in column3 into "0.4".
for the rows outside of this region, change the values in column3 into "0"
print into an output file.
I am struggling with how to go back to the line to change the column 3 after
3 consecutive NoCall has been counted???
I currently read the input data into an array and used this line to go back
to the beginning of first NoCall line: my $nocalline = $contents[$line_num -
3];
Perl does not like it and an error message says: ""my" variable $nocalline
masks earlier declaration in same scope a
line 38. Use of implicit split to @_ is deprecated at trynocall.pl line 38.
syntax error at trynocall.pl line 38, near ");"
Can anyone give some hints?
Thanks
Aiguo
input data is: output data should be:
====================== ========================
1 22 AA 1 22 0
1 24 AA 1 24 0
1 26 NoCall 1 26 0
1 27 BB 1 27 0
1 30 AB 1 30 0
1 35 NoCall 1 35 1
1 40 NoCall 1 40 1
1 41 NoCall 1 41 1
1 42 NoCall 1 42 1
1 48 AB 1 48 0
1 50 AB 1 50 0
1 52 BB 1 52 0.4
1 53 NoCall 1 53 0.4
1 55 NoCall 1 55 0.4
1 56 BB 1 56 0.4
1 66 AA 1 66 0.4
1 70 NoCall 1 70 1
1 90 NoCall 1 90 1
1 99 NoCall 1 99 1
1 100 NoCall 1 100 1
1 101 NoCall 1 101 1
1 103 AA 1 103 0.4
1 105 BB 1 105 0.4
2 22 AA 2 22 0
2 24 BB 2 24 0
2 26 AB 2 26 0
2 27 BB 2 27 0
2 30 AA 2 30 0
2 35 AA 2 35 0
2 40 AA 2 40 0
the code I have
=================
#!usr/local/bin/perl
use strict;
use warnings;
open (DATA, "C:/Aiguo_2004/SNP_Johnpark/work files/summary/testnocall1.txt")
or die "Can not open file \n";
open (LOH, "C:/Aiguo_2004/SNP_Johnpark/work files/summary/loh.txt") or die
"Can not open file \n";
open (OUT1, ">C:/perl/work/nocallout.txt") or "die can not open file \n";
my @contents = <DATA>;
my $chro_num;
my $lohbegin;
my $lohend;
my $line_num = 0;
while(my $lohline = <LOH>) #this file contain regions for changing to 0.4
{
($chro_num, $lohbegin, $lohend) = split(/\t/, $lohline);
foreach my $line (@contents)
{
while($line =~ /^[1..9]/)
{
$line_num++;
#print $line_num;
(my $chro, my $position, my $call) = split (/\t/, $line);
if(($chro_num == $chro)&&($position >= $lohbegin) &&
($position <= $lohend))
{
call = 0.4;
unless($call =~ "NoCall")
{
my $n++;
my $m++;
if($n >= 3)
{
my $nocalline = $contents[$line_num - 3];
my ($nocall_chro, $nocall_begin, $nocall =
split(/\t/, $nocalline);
print "Nocall chro = $nocall_chro, Nocall
begin = $nocall_begin \n";
$nocall = "Nocall";
}
#else{$call = 0.4;}
print $call;
$contents[$line_num] = join('\t', $chro, $position,
$call);
}
}
#print "Chro:$chro, Position:$position, call=$call\n";
}
#print @contents;
}
}
close DATA;
close OUT1;
close LOH;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>