comparison carpet-src-1/tools/CARPET/genecentrico.pl @ 0:cdd489d98766

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author matces
date Tue, 07 Jun 2011 16:50:41 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cdd489d98766
1 #! /usr/bin/perl
2
3 # Copyright 2009 Matteo Cesaroni, Lucilla Luzi
4 #
5 # This program is free software; ; you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or (at your
8 # option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15
16 $file_all=$ARGV[0];
17 $file_sub=$ARGV[1];
18 $down=$ARGV[2];
19 $up=$ARGV[6];
20 $scelta=$ARGV[3];
21 $result=$ARGV[4];
22 $output=$ARGV[5];
23
24
25 open(FILESUB, "<$file_sub") or die "Cannot find file $file_sub\n";
26 open(FILEALL, "<$file_all") or die "Cannot open file $file_all: $!\n";
27 open(FILEOUT, ">$output") or die "Cannot create file $output: $!\n";
28
29 print "Analysis Type=$scelta, Promoter def:$down/$up, output=$result\n";
30
31 @sub=<FILESUB>;
32 @all=<FILEALL>;
33 foreach $lines_all(@all){
34 chomp $lines_all;
35 #chop $lines_all;
36 if ($lines_all=~/#/g){next;}
37 @line_all=split("\t",$lines_all);
38 $chr=$line_all[2];
39 $refseq=$line_all[1];
40 $refStart=$line_all[3];
41 $refStop=$line_all[4];
42 $name=$line_all[0];
43 #$exon_count=$line_all[8];
44 #@exonStart=split(",",$line_all[9]);
45 #@exonStop=split(",",$line_all[10]);
46 $strand=$line_all[5];
47 if ($scelta eq "promoter"){
48 if ($strand eq "+"){
49 $prom_start=$refStart+$down;
50 $prom_stop=$refStart+$up;
51 }
52 if ($strand eq "-"){
53 $prom_start=$refStop-$up;
54 $prom_stop=$refStop-$down;
55 }
56 }
57 if ($scelta eq "all"){
58 if ($strand eq "+"){
59 $prom_start=$refStart+$down;
60 $prom_stop=$refStop;
61 }
62 if ($strand eq "-"){
63 $prom_start=$refStart;
64 $prom_stop=$refStop-$down;
65 }
66 }
67
68
69
70 @promotore=();
71 $max_prom=0;
72 foreach $lines_sub(@sub){
73 chomp $lines_sub;
74 if ($lines_sub=~/#/g){next;}
75 @line_sub=split("\t",$lines_sub);
76 $chr_p=$line_sub[0];
77 $peakStart=$line_sub[3];
78 $peakStop=$line_sub[4];
79 $value=$line_sub[5];
80 #print "$peakStart\t$peakStop\t$prom_start\t$prom_stop\n";
81 #print "$refStart\t$refStop\t$peakStart\t$peakStop\n";
82 if (((($peakStart>=$prom_start) && ($peakStart<=$prom_stop)) || (($peakStart<=$prom_start) && ($peakStop>=$prom_start))) && ("$chr" eq "$chr_p")){
83 push(@promotore,$value);
84 #print "cazzo";
85
86 }
87 }
88 $i=0;
89 foreach $valore(@promotore){
90 $i++;
91 if($max_prom<$valore){
92 $max_prom=$valore;
93 }
94 }
95 if ($result eq "max_value"){
96 print FILEOUT "$lines_all\t$max_prom\n";
97 }
98 else{
99 print FILEOUT "$lines_all\t$i\n";
100 }
101 }