!/usr/bin/perl
use Cwd;
use warnings;
open($fh,'<', "clinical.txt");
$line = <$fh>;
while($line = <$fh>)
{
my @fields2 =split(" ",$line);
push(@id,$fields2[1]);
push(@status,$fields2[3]);
}
@flow = grep { -d } glob "*";
$arrSize = @flow;
for ($p = 0; $p < $arrSize; $p++)
{
@files=<$flow[$p]/*.maf>;
print $flow[$p],"\n";
foreach $file(@files)
{
print $file,"\n";
open(x,$file);
%hash={};
%tested={};
%Mut_Count={};
$hyper=0;
$line = <x>;
$line = <x>;
$line = <x>;
$line = <x>;
$line = <x>;
$line = <x>;
while($line = <x>)
{
@temp=split("\t",$line);
$key=$temp[4]."_".$temp[5]."_".$temp[6]."_".$temp[10]."_".$temp[11]."_".$temp[12]."_".$temp[15];
push @{$hash{$key}}, "0";
push @{$Mut_Count{$temp[15]}}, "0";
}
@nm=split(/\./,$file);
open(x,$file);
open(Out1,">Results/".$nm[1]."_Hyper.txt");
$line = <x>;
$line = <x>;
$line = <x>;
$line = <x>;
$line = <x>;
@temp=split(" ",$line);
@temp2=split(",",$temp[1]);
print Out1 "Gene\tMutation\tType\tdbSNP\tStatus\tPolyphen\tSift";
for($j=0;$j<scalar(@id);$j++){
my @M=split('-', $id[$j]);
for($i=0;$i<scalar(@temp2);$i++)
{
my @N=split('-', $temp2[$i]);
if(scalar(@{$Mut_Count{$temp2[$i]}})>499 && $M[0] eq $N[0] && $M[1] eq $N[1] && $M[2] eq $N[2] && $status[$j] eq 'MSS')
{
print Out1 "\t",$temp2[$i];
$hyper++;
}
}
}
$line = <x>;
while($line = <x>)
{
$hy=0;
@temp=split("\t",$line);
$key=$temp[4]."_".$temp[5]."_".$temp[6]."_".$temp[10]."_".$temp[11]."_".$temp[12];
if(!exists $tested{$key})
{
push @{$tested{$key}}, "0";
print Out1 "\n",$temp[0],"\t",$key,"\t",$temp[8],"\t",$temp[13],"\t",$temp[25],"\t",$temp[72],"\t",$temp[73];
for($i=0;$i<scalar(@temp2);$i++)
{
$key=$temp[4]."_".$temp[5]."_".$temp[6]."_".$temp[10]."_".$temp[11]."_".$temp[12]."_".$temp2[$i];
my @L=split('-', $temp2[$i]);
for($j=0;$j<scalar(@id);$j++){
my @O=split('-', $id[$j]);
if(scalar(@{$Mut_Count{$temp2[$i]}})>499 && $L[0] eq $O[0] && $L[1] eq $O[1] && $L[2] eq $O[2] && $status[$j] eq 'MSS')
{
if(exists $hash{$key})
{
print Out1 "\t1";
$hy++;
}
else
{
print Out1 "\t0";
}
}
}
}
}
}
open(Out3,">Results/".$nm[1]."_Summary.txt");
print Out3 "Hypermutated\t$hyper\n";
}
}
$line = <$fh>; while($line = <$fh>)
these lines are showing readline() on closed filehandle $fh
%hash={}; %tested={}; %Mut_Count={};
on these three lines it says Reference found where even-sized list expected
.maf are basically GDC downloaded files with bit modified header according to our need with unique TCGA IDs. Whereas, Clinical Info is file contaning TCGA IDs, its source and MSI_Status that tells us whether it is MSI-L, MSI-H or MSS. I'm reading multiple .maf files and comparing it with clinical_info file and if the if condition is satisfied that I want it to generate mastertable(write a file) I'm doing it in windows. Kindly, help me resolve this, Thanks in anticipation.
use warnings;(adding which requires no changes to the rest of the code), anduse strict;(for which you need to declare withmyall variables as they are introduced)readline on a closed filehandlea while ago. Not is is something different. Please post links to the input files you are using -- there is not enough context to fault find you issue by just looking at the code. Ideally keep the input file ssmall.