Hi,
 
I have a similar problem that someone just asked about reading specific columns from a 
file and writing to another file. Eventually, I want to read the written file to be 
loaded into Matlab. Im having trouble writing the regular expression for this file. 
The format of the file looks like this:
 
Cell1=481 13 N control AFFX-MurIL2_at 0 13 A A A 0  8801  -1  -1  99 
Cell2=481 12 N control AFFX-MurIL2_at 0 13 A T A 0  8161  -1  -1  99
 
 I want to read the column mentioning 481 and leaving Cell?= portion.
Then second col. ie 13/12, third col, 5th(AFFX-KurIL2_at) and 7th(13/13). Please 
suggest how do i do that. The code i tried is as follows:
 
$writefilename = 'final.txt';
open(READFILE1,$writefilename);
open(WRITEFILE1,">>cdf.txt");
@array=<READFILE1>;
$len=scalar(@array);
print $len;
#foreach $lineblock(@array){
 #  
@colarray=split(/\w+\=\d+\s+\d+\s+\w\s+\w+\s+\w+\-\w+\-\w+\s+\d\s+\d+\s+\w\s+\w\s+\w\s+\d\s+\d+\s+\d\s+\d\s+\d+/,
 $lineblock);
 #  print WRITEFILE1 @colarray[1];
 
#}
foreach$lineblock(@array){
        @colarray=split(/\s*/,$lineblock);
        $colarray[0]=~ s/Cell\d=//ig;
        foreach $col(@colarray){
        print WRITEFILE1 $col;
        }     
}
close READFILE1;
close WRITEFILE1;
exit;
 
 
 
Thanks,
Shahzad.
 
 


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

Reply via email to