Mercurial > repos > melpetera > acorf
comparison ACF/lib/IonFiltration.pm @ 2:15430e89c97d draft default tip
Uploaded
author | melpetera |
---|---|
date | Thu, 07 Nov 2019 03:42:14 -0500 |
parents | d03fcbeb0a77 |
children |
comparison
equal
deleted
inserted
replaced
1:26aa3a8f95ce | 2:15430e89c97d |
---|---|
1 #!usr/bin/perl | |
2 package IonFiltration; | |
3 | |
4 ### Perl modules | |
5 use strict; | |
6 use warnings; | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 ######################################################################## | |
14 ### Création of a hash containing all adduits and fragments possible ### | |
15 ######################################################################## | |
16 | |
17 | |
18 sub MassCollecting{ | |
19 | |
20 my $mass_file = $_[0]; | |
21 my %hmass; | |
22 | |
23 open (F1, $mass_file); | |
24 | |
25 while(my $line = <F1>){ | |
26 chomp $line; | |
27 my @tline = split(/[\t;]/, $line); | |
28 if(defined($hmass{$tline[2]})){ | |
29 print "The mass difference already exists : $tline[2] !\n"; | |
30 } | |
31 $hmass{$tline[1]}{$tline[2]}=$tline[0]; | |
32 } | |
33 | |
34 close F1; | |
35 return %hmass; | |
36 | |
37 } | |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | |
44 | |
45 ######################################################## | |
46 ### Creation of a sif table + correlation filtration ### | |
47 ######################################################## | |
48 | |
49 | |
50 sub sifTableCreation{ | |
51 | |
52 my $file = $_[0]; | |
53 my $output_sif = $_[1]; | |
54 # my $opt = $_[2]; | |
55 # my $rt_threshold = $_[3]; | |
56 # my $mass_threshold = $_[4]; | |
57 my $correl_threshold = $_[5]; | |
58 # my $dataMatrix = $_[6]; | |
59 # my $output_tabular = $_[7]; | |
60 my $combined_DMVM = $_[8]; | |
61 # my $repres_opt = $_[9]; | |
62 # my $intensity_threshold = $_[10]; | |
63 # my $intensity_pourc = $_[11]; | |
64 # my $refhmass = $_[12]; | |
65 | |
66 | |
67 | |
68 | |
69 my %hheader_file; | |
70 my %hduplicate; | |
71 | |
72 my %hcorrelgroup; | |
73 my $groupct=1; | |
74 | |
75 | |
76 my $linenb3=0; | |
77 my %hheader_line; | |
78 my %hrtmz; | |
79 | |
80 open (F5, $combined_DMVM); | |
81 while(my $line = <F5>){ | |
82 chomp $line; | |
83 my @tline = split(/\t/, $line); | |
84 | |
85 if($linenb3 == 0){ | |
86 for(my $i=0; $i<scalar(@tline);$i++){ | |
87 my $a = $tline[$i]; | |
88 $hheader_line{$a}=$i; | |
89 } | |
90 } | |
91 else{ | |
92 if(defined($hheader_line{mzmed})){ | |
93 my $b = $tline[$hheader_line{mzmed}]; | |
94 $hrtmz{$tline[0]}{mz}=$b; | |
95 } | |
96 else{ | |
97 my $b = $tline[$hheader_line{mz}]; | |
98 $hrtmz{$tline[0]}{mz}=$b; | |
99 } | |
100 if(defined($hheader_line{rtmed})){ | |
101 my $d = $tline[$hheader_line{rtmed}]; | |
102 $hrtmz{$tline[0]}{rt}=$d; | |
103 } | |
104 else{ | |
105 my $d = $tline[$hheader_line{rt}]; | |
106 $hrtmz{$tline[0]}{rt}=$d; | |
107 } | |
108 } | |
109 | |
110 $linenb3 ++; | |
111 } | |
112 close F5; | |
113 | |
114 | |
115 my $linenb=0; | |
116 | |
117 open (F1, $file) or die "Impossible to open $file\n"; | |
118 open(F2, ">$output_sif") or die "Impossible to open $output_sif\n"; | |
119 | |
120 | |
121 while(my $line = <F1>){ | |
122 chomp $line; | |
123 my @tline = split(/\t/, $line); | |
124 | |
125 ############################### | |
126 ### Création of a sif table ### | |
127 ############################### | |
128 | |
129 if($linenb == 0){ | |
130 for(my $i=0; $i<scalar(@tline);$i++){ | |
131 my $a = $tline[$i]; | |
132 $hheader_file{$i}=$a; | |
133 } | |
134 } | |
135 else{ | |
136 for(my $i=1; $i<scalar(@tline);$i++){ | |
137 my $a=$tline[0]; | |
138 my $b=$hheader_file{$i}; | |
139 my $coef=$tline[$i]; | |
140 | |
141 if($a eq $b){ | |
142 # print "This is a correlation between A ($a) and A ($b) !\n" | |
143 } | |
144 else{ | |
145 | |
146 ######################### | |
147 ### Remove duplicates ### | |
148 ######################### | |
149 | |
150 my $y = $a."/".$b; | |
151 my $z = $b."/".$a; | |
152 | |
153 if((!(defined($hduplicate{$y}))) && (!(defined($hduplicate{$z})))){ | |
154 | |
155 $hduplicate{$y}=1; | |
156 # my $abcoef=abs($coef); # Only when you want to consider negative correlations | |
157 | |
158 # if($abcoef > $correl_threshold){ # Only when you want to consider negative correlations | |
159 if($coef > $correl_threshold){ | |
160 | |
161 print F2 "$a\t$coef\t$b\n"; | |
162 | |
163 my $count=0; | |
164 | |
165 } | |
166 } | |
167 } | |
168 } | |
169 } | |
170 $linenb ++; | |
171 } | |
172 close F1; | |
173 close F2; | |
174 return ($output_sif, %hrtmz); | |
175 } | |
176 | |
177 | |
178 | |
179 | |
180 | |
181 1; |