annotate GALAXY_FILES/tools/EMBER/Integrate_Data.pl @ 3:037c3edda16e

Uploaded
author mmaiensc
date Thu, 22 Mar 2012 13:49:52 -0400
parents 003f802d4c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
1 #!/usr/bin/perl
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
2 # combine microarray pre-preprocessed data and binding data
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
3
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
4 use Getopt::Long;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
5 $|++;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
6
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
7 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
8 # command line arguments
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
9 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
10 $options = "Usage: ./Integrate_Data.pl <OPTIONS>
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
11 -b binding data (required)
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
12 -bf binding data format (default 1)
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
13 1 - .bed format (<chr> <pkposn> <other information>)
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
14 first two columns are required,
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
15 <other information> may contain peak ids, enrichments, etc, and is optional but will be retained
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
16 2 - Dinner group \"annotation\" format
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
17 -e pre-processed expression data (required)
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
18 -o output (required)
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
19 -d distance (positive number, in kbp, default 100)
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
20 -dt distance type (1 = to gene boundaries, 2 = to TSS, default 1)
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
21 -v verbose (print progress to stdout: y or n, default y)
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
22 \n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
23
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
24 $b = "";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
25 $bf = 1;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
26 $e = "";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
27 $o = "";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
28 $d = 100;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
29 $dt = "1";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
30 $v = "y";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
31
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
32 GetOptions('b=s' => \$b,
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
33 'bf=i' => \$bf,
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
34 'e=s' => \$e,
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
35 'o=s' => \$o,
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
36 'd=f' => \$d,
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
37 'dt=i' => \$dt,
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
38 'v=s' => \$v,
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
39 ) || die "\n$options\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
40
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
41 if( $b eq "" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
42 print "\nError: set a value for -b\n\n$options";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
43 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
44 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
45 if( $bf != 1 && $bf != 2 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
46 print "\nError: set -bf to be 1 or 2\n\n$options";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
47 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
48 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
49 if( $e eq "" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
50 print "\nError: set a value for -e\n\n$options";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
51 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
52 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
53 if( $o eq "" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
54 print "\nError: set a value for -o\n\n$options";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
55 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
56 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
57
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
58 if( $d < 0 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
59 print "\nError: choose -d to be positive\n\n$options";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
60 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
61 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
62 if( $dt != 1 && $dt != 2 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
63 print "\nError: choose -dt to be 1 or 2\n\n$options";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
64 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
65 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
66 if( $v ne "y" && $v ne "n" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
67 print "\nError: choose -v to be y or n\n\n$options";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
68 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
69 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
70
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
71 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
72 # read in binding data
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
73 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
74 if( $v eq "y" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
75 print "\nReading in binding and expression data\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
76 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
77 @peaks = ();
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
78 open(IN,"$b") || die "Error: can't open file $b\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
79 while($line = <IN>){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
80 if( $line !~ /#/ ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
81 chomp($line);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
82 @parts = split(' ',$line);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
83 $info = {};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
84 if( $bf == 1 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
85 $info->{chr} = $parts[0];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
86 $info->{pk} = $parts[1];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
87 $val = "";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
88 if( $#parts >= 2 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
89 $val = $parts[2];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
90 for($i=3; $i<= $#parts; $i++){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
91 $val = sprintf("%s %s", $val, $parts[$i]);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
92 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
93 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
94 $info->{rest} = $val;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
95 push(@peaks, $info);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
96 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
97 if( $bf == 2 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
98 if( $#parts == 19 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
99 $info->{chr} = $parts[2];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
100 $info->{pk} = $parts[3];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
101 $info->{rest} = sprintf("%s %s %s", $parts[0], $parts[1], $parts[6]);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
102 push(@peaks, $info);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
103 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
104 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
105 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
106 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
107 close(IN);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
108
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
109 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
110 # read in expression data
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
111 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
112 @expr = ();
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
113 open(IN,"$e") || die "Error: can't open file $e\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
114 while($line = <IN>){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
115 chomp($line);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
116 @parts = split(' ',$line);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
117 $info = {};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
118 $info->{chr} = $parts[2];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
119 $info->{start} = $parts[3];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
120 $info->{end} = $parts[4];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
121 $info->{strand} = $parts[5];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
122 $info->{line} = $line;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
123 push(@expr, $info);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
124 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
125 close(IN);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
126
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
127 if( $v eq "y" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
128 printf(" %i peaks, %i genes\n", $#peaks+1, $#expr+1);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
129 printf("\nSorting peaks and genes, indexing chromosomes\n");
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
130 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
131
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
132 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
133 # sort binding and expression data by chr to save some time
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
134 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
135 @speaks = sort{ $a->{chr} cmp $b->{chr} } @peaks;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
136 @sexpr = sort{ $a->{chr} cmp $b->{chr} } @expr;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
137
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
138 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
139 # index starting elements for each chromosome in sexpr
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
140 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
141 @chrinds = ();
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
142 $chr = $sexpr[0]->{chr};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
143 $info = {};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
144 $info->{chr} = $chr;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
145 $info->{start} = 0;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
146 for($i=0; $i<= $#sexpr; $i++){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
147 if( $sexpr[$i]->{chr} ne $chr ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
148 $info->{end} = $i-1;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
149 push(@chrinds, $info);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
150 $info = {};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
151 $chr = $sexpr[$i]->{chr};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
152 $info->{chr} = $chr;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
153 $info->{start} = $i;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
154 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
155 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
156 $info->{end} = $i-1;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
157 push(@chrinds, $info);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
158
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
159 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
160 # compile potential targets for each peak and print out
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
161 #
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
162 if( $v eq "y" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
163 printf("\nFinding potential targets\n");
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
164 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
165 open(OUT,">$o");
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
166 $count=0;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
167 for($i=0; $i<= $#speaks; $i++){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
168 if( $v eq "y" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
169 printf("\r peak %i of %i", $i+1, $#speaks+1);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
170 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
171 # print out peak info
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
172 printf OUT ("PEAK: %s %s %s\n", $speaks[$i]->{chr}, $speaks[$i]->{pk}, $speaks[$i]->{rest} );
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
173
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
174 # find the right chromosome and search through all the genes on the same chromosome for possible matches
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
175 $j=0;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
176 $end=$#chrinds;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
177 while( $chrinds[$j]->{chr} ne $speaks[$i]->{chr} && $j<= $end ){$j++;}
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
178 if( $chrinds[$j]->{chr} eq $speaks[$i]->{chr} ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
179 $start = $chrinds[$j]->{start};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
180 $end = $chrinds[$j]->{end};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
181 for($k=$start; $k<= $end; $k++){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
182 if( &distance( $i, $k ) <= $d ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
183 $count++;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
184 printf OUT ("GENE: %s\n", $sexpr[$k]->{line});
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
185 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
186 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
187 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
188 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
189 close(OUT);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
190 if( $v eq "y" ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
191 print "\n\nGot $count potential targets\n\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
192 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
193
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
194 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
195
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
196
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
197 # compute distance between peak $_[0] and gene $_[1]
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
198 sub distance{
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
199 my $dist;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
200 my $tss;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
201 my $ii;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
202 my $jj;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
203 $ii = $_[0];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
204 $jj = $_[1];
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
205
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
206 if( $speaks[$ii]->{chr} ne $sexpr[$jj]->{chr}){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
207 print "\nError: somehow computing distance between peak/gene on different chromosomes\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
208 print " peak chr: $speaks[$ii]->{chr}, gene chr: $sexpr[$jj]->{chr}\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
209 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
210 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
211 if( $dt == 1 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
212 # distance to closest side of gene
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
213 if( $speaks[$ii]->{pk} < $sexpr[$jj]->{start} ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
214 $dist = $sexpr[$jj]->{start} - $speaks[$ii]->{pk};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
215 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
216 elsif( $speaks[$ii]->{pk} > $sexpr[$jj]->{end} ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
217 $dist = $speaks[$ii]->{pk} - $sexpr[$jj]->{end};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
218 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
219 else{
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
220 $dist = 0;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
221 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
222 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
223 elsif( $dt == 2 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
224 # distance to TSS
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
225 if( $sexpr[$jj]->{strand} == 1 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
226 $tss = $sexpr[$jj]->{start};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
227 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
228 elsif( $sexpr[$jj]->{strand} == -1 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
229 $tss = $sexpr[$jj]->{end};
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
230 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
231 else{
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
232 print "\nError: did not have strand of +/-1 (got $sexpr[$jj]->{strand})\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
233 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
234 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
235 $dist = abs($speaks[$ii]->{pk} - $tss);
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
236 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
237 else{
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
238 print "\nError: wrong value for dt ($dt)\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
239 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
240 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
241 if( $dist < 0 ){
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
242 print "\nError: negative distance\n";
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
243 exit;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
244 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
245 # convert to kbp
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
246 $dist/=1000;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
247 return $dist;
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
248 }
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
249
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
250
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
251
003f802d4c7d Uploaded
mmaiensc
parents:
diff changeset
252