annotate ACF/Analytic_correlation_filtration.pl @ 2:15430e89c97d draft default tip

Uploaded
author melpetera
date Thu, 07 Nov 2019 03:42:14 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
15430e89c97d Uploaded
melpetera
parents:
diff changeset
1 #!usr/bin/perl
15430e89c97d Uploaded
melpetera
parents:
diff changeset
2
15430e89c97d Uploaded
melpetera
parents:
diff changeset
3 ### Perl modules
15430e89c97d Uploaded
melpetera
parents:
diff changeset
4 use warnings;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
5 use strict;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
6 use Getopt::Long qw(GetOptions); #Creation of script options
15430e89c97d Uploaded
melpetera
parents:
diff changeset
7 use Pod::Usage qw(pod2usage); #Creation of script options
15430e89c97d Uploaded
melpetera
parents:
diff changeset
8
15430e89c97d Uploaded
melpetera
parents:
diff changeset
9 #Personnal packages
15430e89c97d Uploaded
melpetera
parents:
diff changeset
10 use FindBin ; ## Allows you to locate the directory of original perl script
15430e89c97d Uploaded
melpetera
parents:
diff changeset
11 #use lib $FindBin::Bin;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
12 use lib "$FindBin::Bin/lib";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
13 use IonFiltration;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
14
15430e89c97d Uploaded
melpetera
parents:
diff changeset
15 my ($file, $mass_file, $opt, $dataMatrix, $combined_DMVM, $repres_opt, $rt_threshold, $mass_threshold, $output_sif, $output_tabular, $correl_threshold, $intensity_threshold, $intensity_pourc); #Options to complete
15430e89c97d Uploaded
melpetera
parents:
diff changeset
16
15430e89c97d Uploaded
melpetera
parents:
diff changeset
17 ########################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
18 ### Options and help ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
19 ########################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
20
15430e89c97d Uploaded
melpetera
parents:
diff changeset
21 GetOptions("f=s"=>\$file, "m=s"=>\$mass_file, "o=s"=>\$opt, "d=s"=>\$dataMatrix, "v=s"=>\$combined_DMVM, "r=s"=>\$repres_opt, "rt=f"=>\$rt_threshold, "mass=f"=>\$mass_threshold, "output_sif=s"=>\$output_sif, "output_tabular=s"=>\$output_tabular, "correl=s"=>\$correl_threshold, "IT=f"=>\$intensity_threshold, "IP=f"=>\$intensity_pourc) or pod2usage(2);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
22
15430e89c97d Uploaded
melpetera
parents:
diff changeset
23 ### Check required parameters :
15430e89c97d Uploaded
melpetera
parents:
diff changeset
24 pod2usage({-message=>q{Mandatory argument '-f' is missing}, -exitval=>1, -verbose=>0}) unless $file;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
25 #pod2usage({-message=>q{Mandatory argument '-m' is missing}, -exitval=>1, -verbose=>0}) unless $mass_file;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
26 pod2usage({-message=>q{Mandatory argument '-o' is missing. It correspond to the grouping method for analytical correlation groups formation.
15430e89c97d Uploaded
melpetera
parents:
diff changeset
27 #It should be a number (1 ; 2 or 3) :
15430e89c97d Uploaded
melpetera
parents:
diff changeset
28 # 1 : Don't take into acount mass information (only RT) ;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
29 # 2 : Check that all mass differences are include in a specific list and taking into acount RT information
15430e89c97d Uploaded
melpetera
parents:
diff changeset
30 # 3 : Check that all mass differences are include in a specific list, ignoring RT information
15430e89c97d Uploaded
melpetera
parents:
diff changeset
31 #To use the tool without takinf into account mass and RT information, use option 1 and define the RT threshold to 999999999.}, -exitval=>1, -verbose=>0}) unless $opt;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
32 pod2usage({-message=>q{Mandatory argument '-r' is missing. It correspond to the group representent choosing method for analytical correlation groups formation.
15430e89c97d Uploaded
melpetera
parents:
diff changeset
33 It should be one of the 3 options below :
15430e89c97d Uploaded
melpetera
parents:
diff changeset
34 "mass" : choose the ion with the highest mass as the representant
15430e89c97d Uploaded
melpetera
parents:
diff changeset
35 "intensity" : choose the ion with the highest intensity as the representant
15430e89c97d Uploaded
melpetera
parents:
diff changeset
36 "mixt" : choose the ion with the highest (mass^2 * intensity) as the representant
15430e89c97d Uploaded
melpetera
parents:
diff changeset
37 "max_intensity_max_mass" : choose tha ion witht he highest intenisty among the 5 most intense ions of the group}, -exitval=>1, -verbose=>0}) unless $repres_opt;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
38 pod2usage({-message=>q{Mandatory argument '-d' is missing}, -exitval=>1, -verbose=>0}) unless $dataMatrix;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
39 pod2usage({-message=>q{Mandatory argument '-v' is missing}, -exitval=>1, -verbose=>0}) unless $combined_DMVM;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
40 #pod2usage({-message=>q{Mandatory argument '-rt' is missing}, -exitval=>1, -verbose=>0}) unless $rt_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
41 #pod2usage({-message=>q{Mandatory argument '-mass' is missing}, -exitval=>1, -verbose=>0}) unless $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
42 pod2usage({-message=>q{Mandatory argument '-correl' is missing}, -exitval=>1, -verbose=>0}) unless $correl_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
43 pod2usage({-message=>q{Mandatory argument '-output_tabular' is missing}, -exitval=>1, -verbose=>0}) unless $output_tabular;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
44 pod2usage({-message=>q{Mandatory argument '-output_sif' is missing}, -exitval=>1, -verbose=>0}) unless $output_sif;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
45
15430e89c97d Uploaded
melpetera
parents:
diff changeset
46
15430e89c97d Uploaded
melpetera
parents:
diff changeset
47 #if(($opt != 1) && ($opt != 2) && ($opt != 3)){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
48 # print "you must indicate \"1\", \"2\" or \"3\" for the --o otpion\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
49 # exit;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
50 #}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
51
15430e89c97d Uploaded
melpetera
parents:
diff changeset
52
15430e89c97d Uploaded
melpetera
parents:
diff changeset
53
15430e89c97d Uploaded
melpetera
parents:
diff changeset
54 if(($repres_opt ne "mass") && ($repres_opt ne "intensity") && ($repres_opt ne "mixt") && ($repres_opt ne "max_intensity_max_mass")){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
55 print "you must indicate \"mass\", \"intensity\", \"mix\" or \"max_intensity_max_mass\" for the --r otpion\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
56 exit;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
57 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
58
15430e89c97d Uploaded
melpetera
parents:
diff changeset
59
15430e89c97d Uploaded
melpetera
parents:
diff changeset
60
15430e89c97d Uploaded
melpetera
parents:
diff changeset
61 #########################################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
62 #### Création of a hash containing all adduits and fragments possible ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
63 #########################################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
64
15430e89c97d Uploaded
melpetera
parents:
diff changeset
65 my %hmass;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
66 if($opt != 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
67 %hmass = IonFiltration::MassCollecting($mass_file);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
68
15430e89c97d Uploaded
melpetera
parents:
diff changeset
69 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
70
15430e89c97d Uploaded
melpetera
parents:
diff changeset
71 my $refhmass = \%hmass;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
72
15430e89c97d Uploaded
melpetera
parents:
diff changeset
73 print "Création of a hash containing all adduits and fragments possible\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
74
15430e89c97d Uploaded
melpetera
parents:
diff changeset
75
15430e89c97d Uploaded
melpetera
parents:
diff changeset
76 ########################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
77 ### Creation of a sif table + correlation filtration ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
78 ########################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
79
15430e89c97d Uploaded
melpetera
parents:
diff changeset
80 my %hrtmz;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
81 ($output_sif, %hrtmz) = IonFiltration::sifTableCreation($file, $output_sif, $opt, $rt_threshold, $mass_threshold, $correl_threshold, $dataMatrix, $output_tabular, $combined_DMVM, $repres_opt, $intensity_threshold, $intensity_pourc, \%hmass);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
82 print "Creation of a sif table + correlation filtration done\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
83
15430e89c97d Uploaded
melpetera
parents:
diff changeset
84
15430e89c97d Uploaded
melpetera
parents:
diff changeset
85 ######################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
86 ### Analytic correlation filtrering follow options ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
87 ######################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
88
15430e89c97d Uploaded
melpetera
parents:
diff changeset
89 my %hheader_file;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
90 my %hduplicate;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
91
15430e89c97d Uploaded
melpetera
parents:
diff changeset
92 my %hcorrelgroup;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
93 my $groupct=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
94
15430e89c97d Uploaded
melpetera
parents:
diff changeset
95 my $linenb3=0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
96 my %hheader_line;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
97
15430e89c97d Uploaded
melpetera
parents:
diff changeset
98
15430e89c97d Uploaded
melpetera
parents:
diff changeset
99
15430e89c97d Uploaded
melpetera
parents:
diff changeset
100 open (F1, $output_sif) or die "Impossible to open $output_sif\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
101
15430e89c97d Uploaded
melpetera
parents:
diff changeset
102 while(my $line = <F1>){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
103 my $count=0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
104 chomp $line;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
105 my @tline = split(/\t/, $line);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
106 my $a = $tline[0];
15430e89c97d Uploaded
melpetera
parents:
diff changeset
107 my $b = $tline[2];
15430e89c97d Uploaded
melpetera
parents:
diff changeset
108
15430e89c97d Uploaded
melpetera
parents:
diff changeset
109 my $amass=$hrtmz{$a}{mz};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
110 my $atemp=$hrtmz{$a}{rt};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
111 my $bmass= $hrtmz{$b}{mz};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
112 my $btemp=$hrtmz{$b}{rt};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
113 my $diff = $amass-$bmass;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
114 $diff = abs($diff);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
115
15430e89c97d Uploaded
melpetera
parents:
diff changeset
116 ### Option 1: Don't take into acount mass information ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
117
15430e89c97d Uploaded
melpetera
parents:
diff changeset
118 if($opt == 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
119 my $btplus = $btemp + $rt_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
120 my $btmoins = $btemp - $rt_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
121 if(($btmoins <= $atemp) && ($atemp <= $btplus)){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
122 foreach my $k (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
123 if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
124 $hcorrelgroup{$k}{$a}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
125 $hcorrelgroup{$k}{$b}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
126 $count++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
127 last;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
128 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
129 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
130 if($count == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
131 my $groupnb="group".$groupct;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
132 $hcorrelgroup{$groupnb}{$a}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
133 $hcorrelgroup{$groupnb}{$b}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
134 $groupct ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
135 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
136 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
137 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
138
15430e89c97d Uploaded
melpetera
parents:
diff changeset
139
15430e89c97d Uploaded
melpetera
parents:
diff changeset
140
15430e89c97d Uploaded
melpetera
parents:
diff changeset
141 ### Option 2: Check that all mass differences are include in a specific list taking into account RT information ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
142
15430e89c97d Uploaded
melpetera
parents:
diff changeset
143 elsif($opt == 2){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
144
15430e89c97d Uploaded
melpetera
parents:
diff changeset
145 my $print = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
146 foreach my $s (keys %{$refhmass}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
147 foreach my $r (keys %{$refhmass->{$s}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
148 my $rm = $r - $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
149 my $rp = $r + $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
150 if(($diff <= $rp) && ($diff >= $rm)){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
151 if($print == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
152 my $btplus = $btemp + $rt_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
153 my $btmoins = $btemp - $rt_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
154
15430e89c97d Uploaded
melpetera
parents:
diff changeset
155 if(($btmoins <= $atemp) && ($atemp <= $btplus)){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
156 foreach my $k (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
157 if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
158 $hcorrelgroup{$k}{$a}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
159 $hcorrelgroup{$k}{$b}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
160 $count++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
161 last;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
162 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
163 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
164 if($count == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
165 my $groupnb="group".$groupct;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
166 $hcorrelgroup{$groupnb}{$a}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
167 $hcorrelgroup{$groupnb}{$b}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
168 $groupct ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
169 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
170 $print = 1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
171 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
172 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
173 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
174 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
175 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
176 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
177
15430e89c97d Uploaded
melpetera
parents:
diff changeset
178
15430e89c97d Uploaded
melpetera
parents:
diff changeset
179 ### Option 3: Check that all mass differences are include in a specific list, ignoring RT information ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
180
15430e89c97d Uploaded
melpetera
parents:
diff changeset
181 elsif($opt == 3){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
182
15430e89c97d Uploaded
melpetera
parents:
diff changeset
183 my $print = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
184 foreach my $s (keys %{$refhmass}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
185 foreach my $r (keys %{$refhmass->{$s}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
186 my $rm = $r - $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
187 my $rp = $r + $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
188 if(($diff <= $rp) && ($diff >= $rm)){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
189 if($print == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
190
15430e89c97d Uploaded
melpetera
parents:
diff changeset
191 foreach my $k (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
192 if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
193 $hcorrelgroup{$k}{$a}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
194 $hcorrelgroup{$k}{$b}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
195 $count++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
196 last;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
197 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
198 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
199 if($count == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
200 my $groupnb="group".$groupct;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
201 $hcorrelgroup{$groupnb}{$a}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
202 $hcorrelgroup{$groupnb}{$b}=1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
203 $groupct ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
204 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
205 $print = 1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
206 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
207 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
208 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
209 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
210 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
211 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
212 close F1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
213
15430e89c97d Uploaded
melpetera
parents:
diff changeset
214 print "Analytic correlation filtrering follow options done\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
215
15430e89c97d Uploaded
melpetera
parents:
diff changeset
216
15430e89c97d Uploaded
melpetera
parents:
diff changeset
217 #############################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
218 ### Join groups that have been subdivided ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
219 #############################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
220
15430e89c97d Uploaded
melpetera
parents:
diff changeset
221 my @tdelete;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
222
15430e89c97d Uploaded
melpetera
parents:
diff changeset
223 foreach my $k (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
224 foreach my $i (keys %{$hcorrelgroup{$k}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
225 foreach my $v (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
226 my $count = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
227 if ($v ne $k){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
228 foreach my $w (keys %{$hcorrelgroup{$v}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
229 if($w eq $i){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
230 $count = 1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
231 push(@tdelete, $v);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
232 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
233 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
234 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
235 if($count == 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
236 foreach my $w (keys %{$hcorrelgroup{$v}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
237 $hcorrelgroup{$k}{$w}=$hcorrelgroup{$v}{$w};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
238 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
239 delete($hcorrelgroup{$v});
15430e89c97d Uploaded
melpetera
parents:
diff changeset
240 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
241 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
242 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
243 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
244
15430e89c97d Uploaded
melpetera
parents:
diff changeset
245 foreach my $t (@tdelete){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
246 delete($hcorrelgroup{$t});
15430e89c97d Uploaded
melpetera
parents:
diff changeset
247 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
248
15430e89c97d Uploaded
melpetera
parents:
diff changeset
249
15430e89c97d Uploaded
melpetera
parents:
diff changeset
250 ### Do it twice to see if it fix the problem of unmerge groups
15430e89c97d Uploaded
melpetera
parents:
diff changeset
251
15430e89c97d Uploaded
melpetera
parents:
diff changeset
252 foreach my $k (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
253 foreach my $i (keys %{$hcorrelgroup{$k}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
254 foreach my $v (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
255 my $count = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
256 if ($v ne $k){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
257 foreach my $w (keys %{$hcorrelgroup{$v}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
258 if($w eq $i){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
259 $count = 1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
260 push(@tdelete, $v);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
261 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
262 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
263 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
264 if($count == 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
265 foreach my $w (keys %{$hcorrelgroup{$v}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
266 $hcorrelgroup{$k}{$w}=$hcorrelgroup{$v}{$w};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
267 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
268 delete($hcorrelgroup{$v});
15430e89c97d Uploaded
melpetera
parents:
diff changeset
269 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
270 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
271 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
272 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
273
15430e89c97d Uploaded
melpetera
parents:
diff changeset
274 foreach my $t (@tdelete){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
275 delete($hcorrelgroup{$t});
15430e89c97d Uploaded
melpetera
parents:
diff changeset
276 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
277
15430e89c97d Uploaded
melpetera
parents:
diff changeset
278 print "Join groups that have been subdivided done\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
279
15430e89c97d Uploaded
melpetera
parents:
diff changeset
280 #######################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
281 ### Addition of annotation information among groups ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
282 #######################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
283
15430e89c97d Uploaded
melpetera
parents:
diff changeset
284 foreach my $k (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
285 foreach my $i (keys %{$hcorrelgroup{$k}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
286 foreach my $j (keys %{$hcorrelgroup{$k}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
287 my $count = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
288 if ($i ne $j){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
289
15430e89c97d Uploaded
melpetera
parents:
diff changeset
290 my $a = $hrtmz{$i}{mz};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
291 my $b = $hrtmz{$j}{mz};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
292
15430e89c97d Uploaded
melpetera
parents:
diff changeset
293 my $diff = $a - $b;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
294 my $sign;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
295 if($diff>0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
296 $sign="+";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
297 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
298 if($diff<0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
299 $sign="-";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
300 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
301 $diff = abs($diff);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
302
15430e89c97d Uploaded
melpetera
parents:
diff changeset
303 foreach my $z (keys %{$refhmass}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
304
15430e89c97d Uploaded
melpetera
parents:
diff changeset
305 foreach my $y (keys %{$refhmass->{$z}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
306 my $ym = $y - $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
307 my $yp = $y + $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
308
15430e89c97d Uploaded
melpetera
parents:
diff changeset
309
15430e89c97d Uploaded
melpetera
parents:
diff changeset
310 if(($diff <= $yp) && ($diff >= $ym)){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
311 my $diff_list = $diff - $y;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
312 $diff_list = abs($diff_list);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
313 $diff_list = sprintf ("%0.6f", $diff_list);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
314
15430e89c97d Uploaded
melpetera
parents:
diff changeset
315 if($hcorrelgroup{$k}{$i} eq 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
316 my $val = "@".$j."|".$sign."(".$z.")(".$diff_list.")|";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
317 $hcorrelgroup{$k}{$i}=$val;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
318 $count ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
319 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
320 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
321 if($count == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
322 my $val = "@".$j."|".$sign."(".$z.")(".$diff_list.")|";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
323 $hcorrelgroup{$k}{$i}.=$val;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
324 $count ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
325 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
326 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
327 my $val = $sign."(".$z.")(".$diff_list.")|";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
328 $hcorrelgroup{$k}{$i}.=$val;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
329 $count ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
330 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
331 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
332 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
333 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
334 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
335 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
336 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
337 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
338 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
339
15430e89c97d Uploaded
melpetera
parents:
diff changeset
340
15430e89c97d Uploaded
melpetera
parents:
diff changeset
341 print "Addition of annotation information among groups done\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
342
15430e89c97d Uploaded
melpetera
parents:
diff changeset
343
15430e89c97d Uploaded
melpetera
parents:
diff changeset
344 ####################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
345 ### Choose the representative ion for each group ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
346 ####################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
347
15430e89c97d Uploaded
melpetera
parents:
diff changeset
348 my %hgrouprepres;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
349
15430e89c97d Uploaded
melpetera
parents:
diff changeset
350 open(F3, $dataMatrix);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
351
15430e89c97d Uploaded
melpetera
parents:
diff changeset
352 while (my $line = <F3>){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
353 chomp $line;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
354
15430e89c97d Uploaded
melpetera
parents:
diff changeset
355 my @tline = split (/\t/, $line);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
356
15430e89c97d Uploaded
melpetera
parents:
diff changeset
357 foreach my $k (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
358 foreach my $i (keys %{$hcorrelgroup{$k}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
359 if($tline[0] eq $i){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
360 $hgrouprepres{$k}{$i}{mass}=$hrtmz{$tline[0]}{mz};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
361 my $intensity;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
362 my $nbsubjects=0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
363 for(my $y=1;$y<scalar(@tline);$y++){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
364 $intensity += $tline[$y];
15430e89c97d Uploaded
melpetera
parents:
diff changeset
365 $nbsubjects ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
366 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
367 my $meanintensity = $intensity/$nbsubjects;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
368 $hgrouprepres{$k}{$i}{intensity}=$meanintensity;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
369 $hgrouprepres{$k}{$i}{squaredmassint}=($hgrouprepres{$k}{$i}{mass}**2)/($hgrouprepres{$k}{$i}{intensity});
15430e89c97d Uploaded
melpetera
parents:
diff changeset
370 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
371 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
372 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
373 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
374 close F3;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
375
15430e89c97d Uploaded
melpetera
parents:
diff changeset
376 foreach my $z (keys %hgrouprepres){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
377 my $max_intensity = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
378 my $max_int_ion = "";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
379 my $max_mass = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
380 my $max_mass_ion = "";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
381 my $max_squared = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
382 my $max_squared_ion = "";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
383 foreach my $w (keys %{$hgrouprepres{$z}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
384 if($hgrouprepres{$z}{$w}{intensity} > $max_intensity){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
385 $max_intensity = $hgrouprepres{$z}{$w}{intensity};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
386 $max_int_ion = $w;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
387 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
388 if($hgrouprepres{$z}{$w}{mass} > $max_mass){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
389 $max_mass = $hgrouprepres{$z}{$w}{mass};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
390 $max_mass_ion = $w;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
391 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
392 if($hgrouprepres{$z}{$w}{squaredmassint} > $max_squared){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
393 $max_squared = $hgrouprepres{$z}{$w}{squaredmassint};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
394 $max_squared_ion = $w;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
395 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
396 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
397
15430e89c97d Uploaded
melpetera
parents:
diff changeset
398 my $max_int_max_mass_ion="";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
399
15430e89c97d Uploaded
melpetera
parents:
diff changeset
400 if($repres_opt eq "max_intensity_max_mass"){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
401 my %hfirst;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
402 my $first=0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
403 foreach my $w (reverse sort {$hgrouprepres{$z}{$a}{intensity} <=> $hgrouprepres{$z}{$b}{intensity} } keys %{$hgrouprepres{$z}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
404 $first ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
405 if ($first <= 3){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
406 $hfirst{$w} = $hgrouprepres{$z}{$w}{intensity};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
407 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
408 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
409
15430e89c97d Uploaded
melpetera
parents:
diff changeset
410 my $first_2 = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
411 my $intens_max = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
412 my $mass_max = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
413
15430e89c97d Uploaded
melpetera
parents:
diff changeset
414 foreach my $y (reverse sort {$hfirst{$a} <=> $hfirst{$b}} keys %hfirst){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
415
15430e89c97d Uploaded
melpetera
parents:
diff changeset
416 $first_2 ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
417 if($first_2 == 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
418 $intens_max = $hfirst{$y};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
419 if($intensity_threshold > $intens_max){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
420 $intensity_threshold = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
421 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
422 $max_int_max_mass_ion = $y;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
423 $mass_max = $hgrouprepres{$z}{$y}{mass};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
424 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
425 if($hgrouprepres{$z}{$y}{mass} > $mass_max){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
426 if($hfirst{$y}>$intensity_threshold){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
427 my $a = $intens_max * $intensity_pourc;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
428 if($hfirst{$y} > $a){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
429 $max_int_max_mass_ion = $y;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
430 $mass_max = $hgrouprepres{$z}{$y}{mass};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
431 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
432 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
433 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
434 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
435 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
436
15430e89c97d Uploaded
melpetera
parents:
diff changeset
437 $hgrouprepres{$z}{max_int}=$max_int_ion;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
438 $hgrouprepres{$z}{max_mass}=$max_mass_ion;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
439 $hgrouprepres{$z}{max_squared}=$max_squared_ion;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
440 $hgrouprepres{$z}{max_int_max_mass}=$max_int_max_mass_ion;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
441
15430e89c97d Uploaded
melpetera
parents:
diff changeset
442 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
443
15430e89c97d Uploaded
melpetera
parents:
diff changeset
444
15430e89c97d Uploaded
melpetera
parents:
diff changeset
445 print "Choose the representative ion for each group done\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
446
15430e89c97d Uploaded
melpetera
parents:
diff changeset
447 #############################################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
448 ### Addition of annotation information relative to the representative ion ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
449 #############################################################################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
450
15430e89c97d Uploaded
melpetera
parents:
diff changeset
451 my %hreprescomparison;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
452
15430e89c97d Uploaded
melpetera
parents:
diff changeset
453 my $representative="";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
454
15430e89c97d Uploaded
melpetera
parents:
diff changeset
455 if($opt != 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
456 foreach my $k (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
457 foreach my $i (keys %{$hcorrelgroup{$k}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
458
15430e89c97d Uploaded
melpetera
parents:
diff changeset
459 if($repres_opt eq "mass"){$representative = $hgrouprepres{$k}{max_mass}}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
460 if($repres_opt eq "intensity"){$representative = $hgrouprepres{$k}{max_int}}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
461 if($repres_opt eq "mixt"){$representative = $hgrouprepres{$k}{max_squared}}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
462 if($repres_opt eq "max_intensity_max_mass"){$representative = $hgrouprepres{$k}{max_int_max_mass}}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
463
15430e89c97d Uploaded
melpetera
parents:
diff changeset
464
15430e89c97d Uploaded
melpetera
parents:
diff changeset
465 my $count = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
466 if ($i ne $representative){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
467
15430e89c97d Uploaded
melpetera
parents:
diff changeset
468 my $a = $hrtmz{$i}{mz};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
469 my $b = $hrtmz{$representative}{mz};
15430e89c97d Uploaded
melpetera
parents:
diff changeset
470
15430e89c97d Uploaded
melpetera
parents:
diff changeset
471 my $diff = $a - $b;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
472 my $sign;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
473 if($diff>0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
474 $sign="+";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
475 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
476 if($diff<0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
477 $sign="-";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
478 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
479 $diff = abs($diff);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
480
15430e89c97d Uploaded
melpetera
parents:
diff changeset
481 foreach my $z (keys %{$refhmass}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
482
15430e89c97d Uploaded
melpetera
parents:
diff changeset
483 foreach my $y (keys %{$refhmass->{$z}}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
484 my $ym = $y - $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
485 my $yp = $y + $mass_threshold;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
486
15430e89c97d Uploaded
melpetera
parents:
diff changeset
487 if(($diff <= $yp) && ($diff >= $ym)){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
488 my $diff_list = $diff - $y;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
489 $diff_list = abs($diff_list);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
490 $diff_list = sprintf ("%0.4f", $diff_list);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
491 if($hcorrelgroup{$k}{$i} eq 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
492 my $valrep = "[M ".$sign."(".$z.")]|";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
493 $hreprescomparison{$k}{$i}{repres_diff}=$valrep;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
494 $count ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
495 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
496 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
497 if($count == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
498 my $valrep = "[M ".$sign."(".$z.")]|";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
499 $hreprescomparison{$k}{$i}{repres_diff}.=$valrep;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
500 $count ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
501 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
502 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
503 my $valrep = "[M ".$sign."(".$z.")]|";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
504 $hreprescomparison{$k}{$i}{repres_diff}.=$valrep;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
505 $count ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
506 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
507 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
508 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
509 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
510 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
511 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
512 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
513 $hreprescomparison{$k}{$i}{repres_diff}="M";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
514 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
515 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
516 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
517 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
518
15430e89c97d Uploaded
melpetera
parents:
diff changeset
519
15430e89c97d Uploaded
melpetera
parents:
diff changeset
520 print "Addition of annotation information relative to the representative ion done\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
521
15430e89c97d Uploaded
melpetera
parents:
diff changeset
522 ##############################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
523 ### Print in result file ! ###
15430e89c97d Uploaded
melpetera
parents:
diff changeset
524 ##############################
15430e89c97d Uploaded
melpetera
parents:
diff changeset
525
15430e89c97d Uploaded
melpetera
parents:
diff changeset
526 open(F4, ">$output_tabular");
15430e89c97d Uploaded
melpetera
parents:
diff changeset
527 open(F5, $combined_DMVM);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
528
15430e89c97d Uploaded
melpetera
parents:
diff changeset
529 my $line_nb = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
530 my %hheader;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
531 while (my $line = <F5>){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
532 chomp $line;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
533
15430e89c97d Uploaded
melpetera
parents:
diff changeset
534
15430e89c97d Uploaded
melpetera
parents:
diff changeset
535 my @tline = split (/\t/, $line);
15430e89c97d Uploaded
melpetera
parents:
diff changeset
536
15430e89c97d Uploaded
melpetera
parents:
diff changeset
537 if($line_nb == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
538 print F4 "$line\tACorF_groups";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
539 if($opt == 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
540 if($repres_opt eq "intensity"){print F4 "\tACorF_filter\tintensity_repres\n"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
541 if($repres_opt eq "mass"){print F4 "\tACorF_filter\tmass_repres\n"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
542 if($repres_opt eq "mixt"){print F4 "\tACorF_filter\tmass2intens_repres\n"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
543 if($repres_opt eq "max_intensity_max_mass"){print F4 "\tACorF_filter\tmax_intensity_max_mass_repres\n"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
544 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
545 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
546 if($repres_opt eq "intensity"){print F4 "\tisotopes_adducts_fragments_[\@id|annotation(delta_annotation)]\tACorF_filter\tintensity_repres\tannotation_relative_to_representative\n"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
547 if($repres_opt eq "mass"){print F4 "\tisotopes_adducts_fragments_[\@id|annotation(delta_annotation)]\tACorF_filter\tmass_repres\tannotation_relative_to_representative\n"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
548 if($repres_opt eq "mixt"){print F4 "\tisotopes_adducts_fragments_[\@id|annotation(delta_annotation)]\tACorF_filter\tmass2intens_repres\tannotation_relative_to_representative\n"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
549 if($repres_opt eq "max_intensity_max_mass"){print F4 "\tisotopes_adducts_fragments_[\@id|annotation(delta_annotation)]\tACorF_filter\tmax_intensity_max_mass_repres\tannotation_relative_to_representative\n"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
550 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
551
15430e89c97d Uploaded
melpetera
parents:
diff changeset
552
15430e89c97d Uploaded
melpetera
parents:
diff changeset
553 ### Creation of a header hash
15430e89c97d Uploaded
melpetera
parents:
diff changeset
554 for(my $i=0; $i<scalar(@tline);$i++){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
555 my $a = $tline[$i];
15430e89c97d Uploaded
melpetera
parents:
diff changeset
556 $hheader{$a}=$i;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
557 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
558 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
559
15430e89c97d Uploaded
melpetera
parents:
diff changeset
560 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
561 my $find = 0;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
562 foreach my $v (keys %hcorrelgroup){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
563 if(defined($hgrouprepres{$v}{$tline[0]})){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
564 print F4 "$line\t$v";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
565
15430e89c97d Uploaded
melpetera
parents:
diff changeset
566 if($opt != 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
567 if(defined($hcorrelgroup{$v}{$tline[0]})){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
568 print F4 "\t$hcorrelgroup{$v}{$tline[0]}\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
569
15430e89c97d Uploaded
melpetera
parents:
diff changeset
570 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
571 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
572 print F4 "\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
573 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
574 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
575 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
576 print F4 "\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
577 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
578
15430e89c97d Uploaded
melpetera
parents:
diff changeset
579 if($repres_opt eq "intensity"){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
580 if($tline[0] eq $hgrouprepres{$v}{max_int}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
581 print F4 "1\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
582 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
583 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
584 print F4 "0\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
585 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
586 $find = 1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
587 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
588 if($repres_opt eq "mass"){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
589 if($tline[0] eq $hgrouprepres{$v}{max_mass}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
590 print F4 "1\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
591 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
592 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
593 print F4 "0\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
594 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
595 $find = 1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
596 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
597 if($repres_opt eq "mixt"){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
598 if($tline[0] eq $hgrouprepres{$v}{max_squared}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
599 print F4 "1\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
600 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
601 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
602 print F4 "0\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
603 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
604 $find = 1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
605 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
606 if($repres_opt eq "max_intensity_max_mass"){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
607 if($tline[0] eq $hgrouprepres{$v}{max_int_max_mass}){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
608 print F4 "1\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
609 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
610 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
611 print F4 "0\t";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
612 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
613 $find = 1;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
614 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
615
15430e89c97d Uploaded
melpetera
parents:
diff changeset
616 if($repres_opt eq "intensity"){print F4 "$hgrouprepres{$v}{max_int}\t"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
617 if($repres_opt eq "mass"){print F4 "$hgrouprepres{$v}{max_mass}\t"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
618 if($repres_opt eq "mixt"){print F4 "$hgrouprepres{$v}{max_squared}\t"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
619 if($repres_opt eq "max_intensity_max_mass"){print F4 "$hgrouprepres{$v}{max_int_max_mass}\t"}
15430e89c97d Uploaded
melpetera
parents:
diff changeset
620
15430e89c97d Uploaded
melpetera
parents:
diff changeset
621 if($opt != 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
622 if(defined($hreprescomparison{$v}{$tline[0]}{repres_diff})){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
623 print F4 "$hreprescomparison{$v}{$tline[0]}{repres_diff}\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
624 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
625 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
626 print F4 "-\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
627 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
628 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
629 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
630 print F4 "\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
631 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
632 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
633 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
634 if($find == 0){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
635 $groupct ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
636 my $group = "group".$groupct;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
637 if($opt != 1){
15430e89c97d Uploaded
melpetera
parents:
diff changeset
638 print F4 "$line\t$group\t-\t-\t-\t-\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
639 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
640 else{
15430e89c97d Uploaded
melpetera
parents:
diff changeset
641 print F4 "$line\t$group\t-\t-\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
642 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
643 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
644 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
645 $line_nb ++;
15430e89c97d Uploaded
melpetera
parents:
diff changeset
646 }
15430e89c97d Uploaded
melpetera
parents:
diff changeset
647
15430e89c97d Uploaded
melpetera
parents:
diff changeset
648 print "Print in result file done\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
649
15430e89c97d Uploaded
melpetera
parents:
diff changeset
650 print "All steps done\n";
15430e89c97d Uploaded
melpetera
parents:
diff changeset
651