0
|
1 #!/usr/bin/perl
|
|
2 ########################################
|
|
3 #### Filters peaks by p-value and width
|
|
4 #### Perl script
|
|
5 #######################################
|
|
6
|
|
7
|
|
8 use feature qw(say);
|
|
9
|
|
10
|
|
11 # ==================
|
|
12 # Parsing Arguments
|
|
13 # ==================
|
|
14 #initialize to NULL
|
|
15 my $bed_file = NULL; #bed file
|
|
16
|
|
17 #Parse the arguments
|
|
18 $bed_file = $ARGV[0]; #bed file
|
|
19 #=======================> DONE!
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24 # ========================================
|
|
25 # Parse the bed file and extend the reads
|
|
26 # ========================================
|
|
27 #open the file
|
|
28 open(DATA, $bed_file) || die("Can't open the bed file, probably you gave me the wrong path!");
|
|
29
|
|
30 while (<DATA>) {
|
|
31 my ($chr, $start, $end, $name, $score, $strand, $signal, $pvalue, $qvalue, $summit, $minpeak, $geom) = split(/\t/,$_,12);
|
|
32
|
|
33 my $size = $end - $start;
|
|
34
|
|
35 if($size >= $minpeak) {
|
|
36 if($signal > $geom) {
|
|
37 #Now write the new line
|
|
38 $summit =~ s/\015?\012?$//;
|
|
39 say join "\t", $chr, $start, $end, $name, $score, $strand, $signal, $pvalue, $qvalue, $summit;
|
|
40 }
|
|
41 }
|
|
42 }
|
|
43 #=======================> DONE!
|