File 1
I want to count the number of entries in the second column of second file within 500+ (up) and 500- (down) to the number medntioned in the second column of first file.CTSC chr11 - 650 E RAB38 chr11 - 87883123 E + 12 2 INTRACHR-SS-OGO-0GAP inframe-shift file 2 chr11 602 63889087 HWI-ST216_106:3:67:14628:181851 - chr11 613 69889087 HWI-ST216_106:3:24:16406:176388 + chr11 614 80889087 HWI-ST216_106:3:21:13731:105239 + chr11 643 94888888 HWI-ST216_111:5:22:3149:116167 + chr11 678 98889079 HWI-ST216_106:3:5:18058:57952 + chr11 612 108888887 HWI-ST216_106:3:8:5578:44855 + chr5 612 63889087 HWI-ST216_106:3:67:14628:181851 - chr3 88033200 69889087 HWI-ST216_106:3:24:16406:176388 + chr2 88033345 80889087 HWI-ST216_106:3:21:13731:105239 + chr1 88033376 94888888 HWI-ST216_111:5:22:3149:116167 + chr6 88034000 98889079 HWI-ST216_106:3:5:18058:57952 + chr7 88034123 108888887 HWI-ST216_106:3:8:5578:44855 +
For this, I made an script, but does not giving the desired result:-
#!/usr/bin/perl -w $file1=$ARGV[0]; #First file $file2=$ARGV[1]; #second file open(TR,$file1); while ($line1=<TR>) { chomp($line1); @ar1 = split(/\t/,$line1); chomp($ar1[1]);chomp($ar1[3]); $up = $ar1[3]-500; $dn = $ar1[3]+500; open(SC,$file2); while ($line2=<SC>) { chomp($line2); @array2 = split (/\t/, $line2); if ($ar1[1] eq $array2[0]) { for ($mm=$up;$mm<=$dn;$mm+=100) { $gt = $up+100; $c ='0'; if (($array2[1]> $up) && ($array2[1] < $gt)) { print "$up\t$gt\t$array2[1]\n"; $c++; } $up=$up+50; } } } }
Result produced is
But where is the count of 612,613, 614 etc.. these numbers are in the rage.550 650 602 <p> 600 700 602 <p>
In reply to Sliding window perl program by genome
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |