-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnglarge-loci-by-V1.pl
47 lines (47 loc) · 1.03 KB
/
Englarge-loci-by-V1.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
##This script enlarges the windows by input bp
##Nima Rafati: 20140625
#
use Getopt::Long;
&GetOptions('w=i' =>\$windowSize, 'f=s' =>\$summaryLociFile);
my $contact = "nimarafati\@gmail.com";
my $usage = "Englarge-loci-by-V1.pl -w 5000 -f edgeR-results-Loci-summary.bed
-w size to enlarge
-f summary loci file generated by Loci-info-summary-V2-with-Flags-to-set-Column.pl
$contact\n";
if($windowSize eq "" || $summaryLociFile eq "")
{
print $usage;
exit;
}
open(inF1,$summaryLociFile);
while(<inF1>)
{
$cntr++;
chomp($_);
@lineArr=split("\t",$_);
$chr=$lineArr[0];
$start=$lineArr[1];
$end=$lineArr[2]+$windowSize;
$loci=$lineArr[4];
if($lineArr[1]-$windowSize>=0)
{
$start=$start-$windowSize;
print "$chr\t$start\t$end";
foreach (my $k=3; $k<scalar(@lineArr);$k++)
{
print "\t$lineArr[$k]";
}
}
else
{
$start=0;
print "$chr\t$start\t$end";
foreach (my $k=3; $k<scalar(@lineArr);$k++)
{
print "\t$lineArr[$k]";
}
}
print "\t$lineArr[0]-$lineArr[1]-$lineArr[2]\n";
}
close inF1;