# HG changeset patch # User melpetera # Date 1557404273 14400 # Node ID fff7de4f9fed76f75fab9d5e019d9da4c84cc112 # Parent 243347918a63a1a4b95453a4a29c94f22cf4f398 Uploaded diff -r 243347918a63 -r fff7de4f9fed ACF/Analytic_correlation_filtration.pl --- a/ACF/Analytic_correlation_filtration.pl Thu Apr 11 08:42:38 2019 -0400 +++ b/ACF/Analytic_correlation_filtration.pl Thu May 09 08:17:53 2019 -0400 @@ -8,8 +8,8 @@ #Personnal packages use FindBin ; ## Allows you to locate the directory of original perl script -use lib $FindBin::Bin; -use lib "$FindBin::Bin/../lib"; +#use lib $FindBin::Bin; +use lib "$FindBin::Bin/lib"; use IonFiltration; 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 diff -r 243347918a63 -r fff7de4f9fed ACF/IonFiltration.pm --- a/ACF/IonFiltration.pm Thu Apr 11 08:42:38 2019 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,668 +0,0 @@ -#!usr/bin/perl -package IonFiltration; - -### Perl modules -use strict; -use warnings; - - - - - - -######################################################################## -### Création of a hash containing all adduits and fragments possible ### -######################################################################## - - -sub MassCollecting{ - - my $mass_file = $_[0]; - my %hmass; - - open (F1, $mass_file); - - while(my $line = ){ - chomp $line; - my @tline = split(/[\t;]/, $line); - if(defined($hmass{$tline[2]})){ - print "Il existe déjà une même différence de masse : $tline[2] !\n"; - } - $hmass{$tline[1]}{$tline[2]}=$tline[0]; - } - - close F1; -# my $count=0; -# foreach my $k (keys %hmass){ -# $count++; -# } - - return %hmass; - - -} - - - - - - - -######################################################## -### Creation of a sif table + correlation filtration ### -######################################################## - - -sub sifTableCreation{ - - my $file = $_[0]; - my $output_sif = $_[1]; - my $opt = $_[2]; - my $rt_threshold = $_[3]; - my $mass_threshold = $_[4]; - my $correl_threshold = $_[5]; - my $dataMatrix = $_[6]; - my $output_tabular = $_[7]; - my $combined_DMVM = $_[8]; - my $repres_opt = $_[9]; - my $intensity_threshold = $_[10]; - my $intensity_pourc = $_[11]; - my $refhmass = $_[12]; - - - - - my %hheader_file; - my %hduplicate; - - my %hcorrelgroup; - my $groupct=1; - - - my $linenb3=0; - my %hheader_line; - my %hrtmz; - - open (F5, $combined_DMVM); - while(my $line = ){ - chomp $line; - my @tline = split(/\t/, $line); - - if($linenb3 == 0){ - for(my $i=0; $i$output_sif") or die "Impossible to open $output_sif\n"; - - while(my $line = ){ - chomp $line; - my @tline = split(/\t/, $line); - - - ############################### - ### Création of a sif table ### - ############################### - - if($linenb == 0){ - for(my $i=0; $i $correl_threshold){ - - print F2 "$a\t$coef\t$b\n"; - - my $count=0; - - ###################################################### - ### Analytic correlation filtrering follow options ### - ###################################################### - - - - my $amass=$hrtmz{$a}{mz}; - my $atemp=$hrtmz{$a}{rt}; - my $bmass= $hrtmz{$b}{mz}; - my $btemp=$hrtmz{$b}{rt}; - my $diff = $amass-$bmass; - $diff = abs($diff); - - ### Option 1: Don't take into acount mass information ### - - if($opt == 1){ - my $btplus = $btemp + $rt_threshold; - my $btmoins = $btemp - $rt_threshold; - if(($btmoins <= $atemp) && ($atemp <= $btplus)){ - foreach my $k (keys %hcorrelgroup){ - - if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){ - $hcorrelgroup{$k}{$a}=1; - $hcorrelgroup{$k}{$b}=1; - $count++; - last; - } - } - if($count == 0){ - my $groupnb="group".$groupct; - $hcorrelgroup{$groupnb}{$a}=1; - $hcorrelgroup{$groupnb}{$b}=1; - $groupct ++; - } - - } - } - - - ### Option 2: Check that all mass differences are include in a specific list taking into account RT information ### - - elsif($opt == 2){ - - my $print = 0; - foreach my $s (keys %$refhmass){ - foreach my $r (keys %{%$refhmass{$s}}){ - my $rm = $r - $mass_threshold; - my $rp = $r + $mass_threshold; - if(($diff <= $rp) && ($diff >= $rm)){ - if($print == 0){ - my $btplus = $btemp + $rt_threshold; - my $btmoins = $btemp - $rt_threshold; - - if(($btmoins <= $atemp) && ($atemp <= $btplus)){ -# foreach my $s (keys %{%$refhmass{$r}}){ - # print F2 "$line\t$hmass{$r}{$s} : $s ($r)\n"; - foreach my $k (keys %hcorrelgroup){ - if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){ - $hcorrelgroup{$k}{$a}=1; - $hcorrelgroup{$k}{$b}=1; -# $hcorrelgroup{$k}{frag}.="#".$s; - $count++; - last; - } - } - if($count == 0){ - my $groupnb="group".$groupct; - $hcorrelgroup{$groupnb}{$a}=1; - $hcorrelgroup{$groupnb}{$b}=1; -# $hcorrelgroup{$groupnb}{frag}.="#".$s; - $groupct ++; - - } - $print = 1; - } - - } - } - } - } - } - - - ### Option 3: Check that all mass differences are include in a specific list, ignoring RT information ### - - elsif($opt == 3){ - - my $print = 0; - foreach my $s (keys %$refhmass){ - foreach my $r (keys %{%$refhmass{$s}}){ - my $rm = $r - $mass_threshold; - my $rp = $r + $mass_threshold; - if(($diff <= $rp) && ($diff >= $rm)){ - if($print == 0){ - -# foreach my $s (keys %{%$refhmass{$r}}){ - # print F2 "$line\t$hmass{$r}{$s} : $s ($r)\n"; - foreach my $k (keys %hcorrelgroup){ - if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){ - $hcorrelgroup{$k}{$a}=1; - $hcorrelgroup{$k}{$b}=1; -# $hcorrelgroup{$k}{frag}.="#".$s; - $count++; - last; - } - } - if($count == 0){ - my $groupnb="group".$groupct; - $hcorrelgroup{$groupnb}{$a}=1; - $hcorrelgroup{$groupnb}{$b}=1; -# $hcorrelgroup{$groupnb}{frag}.="#".$s; - $groupct ++; - } - $print = 1; - } - } - } - } - } - } - - - } - } - } - } - $linenb ++; - } - close F1; - close F2; - - - - - ############################################# - ### Join groups that have been subdivided ### - ############################################# - - my @tdelete; - - foreach my $k (keys %hcorrelgroup){ - foreach my $i (keys %{$hcorrelgroup{$k}}){ - foreach my $v (keys %hcorrelgroup){ - my $count = 0; - if ($v ne $k){ - foreach my $w (keys %{$hcorrelgroup{$v}}){ -# if($w ne "frag"){ - if($w eq $i){ - $count = 1; - push(@tdelete, $v); - } -# } - } - } - if($count == 1){ - foreach my $w (keys %{$hcorrelgroup{$v}}){ - $hcorrelgroup{$k}{$w}=$hcorrelgroup{$v}{$w}; - } - delete($hcorrelgroup{$v}); - } - } - } - } - - foreach my $t (@tdelete){ - delete($hcorrelgroup{$t}); - } - - - ### Do it twice to see if it fix the problem of unmerge groups - - foreach my $k (keys %hcorrelgroup){ - foreach my $i (keys %{$hcorrelgroup{$k}}){ - foreach my $v (keys %hcorrelgroup){ - my $count = 0; - if ($v ne $k){ - foreach my $w (keys %{$hcorrelgroup{$v}}){ -# if($w ne "frag"){ - if($w eq $i){ - $count = 1; - push(@tdelete, $v); - } -# } - } - } - if($count == 1){ - foreach my $w (keys %{$hcorrelgroup{$v}}){ - $hcorrelgroup{$k}{$w}=$hcorrelgroup{$v}{$w}; - } - delete($hcorrelgroup{$v}); - } - } - } - } - - foreach my $t (@tdelete){ - delete($hcorrelgroup{$t}); - } - - - - ########################################## - ### Addition of annotation information ### - ########################################## - - foreach my $k (keys %hcorrelgroup){ - foreach my $i (keys %{$hcorrelgroup{$k}}){ - foreach my $j (keys %{$hcorrelgroup{$k}}){ - my $count = 0; - if ($i ne $j){ - - my $a = $hrtmz{$i}{mz}; - my $b = $hrtmz{$j}{mz}; - - my $diff = $a - $b; - my $sign; - if($diff>0){ - $sign="+"; - } - if($diff<0){ - $sign="-"; - } - $diff = abs($diff); - - foreach my $z (keys %$refhmass){ - - foreach my $y (keys %{%$refhmass{$z}}){ - my $ym = $y - $mass_threshold; - my $yp = $y + $mass_threshold; - - - if(($diff <= $yp) && ($diff >= $ym)){ - my $diff_list = $diff - $y; - $diff_list = abs($diff_list); - $diff_list = sprintf ("%0.6f", $diff_list); - - if($hcorrelgroup{$k}{$i} eq 1){ - my $val = "#".$j."|".$sign."(".$z.")(".$diff_list.")|"; - $hcorrelgroup{$k}{$i}=$val; - $count ++; - } - else{ - if($count == 0){ - my $val = "#".$j."|".$sign."(".$z.")(".$diff_list.")|"; - $hcorrelgroup{$k}{$i}.=$val; - $count ++; - } - else{ - my $val = $sign."(".$z.")(".$diff_list.")|"; - $hcorrelgroup{$k}{$i}.=$val; - $count ++; - } - } - } - } - } - } - } - } - } - - - - #################################################### - ### Choose the representative ion for each group ### - #################################################### - - my %hgrouprepres; - - open(F3, $dataMatrix); - - while (my $line = ){ - chomp $line; - - my @tline = split (/\t/, $line); - - - - foreach my $k (keys %hcorrelgroup){ - foreach my $i (keys %{$hcorrelgroup{$k}}){ - - if($tline[0] eq $i){ - $hgrouprepres{$k}{$i}{mass}=$hrtmz{$tline[0]}{mz}; - - my $intensity; - my $nbsubjects=0; - for(my $y=1;$y $max_intensity){ - $max_intensity = $hgrouprepres{$z}{$w}{intensity}; - $max_int_ion = $w; - - } - if($hgrouprepres{$z}{$w}{mass} > $max_mass){ - $max_mass = $hgrouprepres{$z}{$w}{mass}; - $max_mass_ion = $w; - } - if($hgrouprepres{$z}{$w}{squaredmassint} > $max_squared){ - $max_squared = $hgrouprepres{$z}{$w}{squaredmassint}; - $max_squared_ion = $w; - } - } - - my $max_int_max_mass_ion=""; - - if($repres_opt eq "max_intensity_max_mass"){ - my %hfirst; - my $first=0; - foreach my $w (reverse sort {$hgrouprepres{$z}{$a}{intensity} <=> $hgrouprepres{$z}{$b}{intensity} } keys %{$hgrouprepres{$z}}){ - $first ++; - if ($first <= 3){ - $hfirst{$w} = $hgrouprepres{$z}{$w}{intensity}; - } - } - - my $first_2 = 0; - my $intens_max = 0; - my $mass_max = 0; - - foreach my $y (reverse sort {$hfirst{$a} <=> $hfirst{$b}} keys %hfirst){ - - - - $first_2 ++; - if($first_2 == 1){ - $intens_max = $hfirst{$y}; - if($intensity_threshold > $intens_max){ - $intensity_threshold = 0; - } - $max_int_max_mass_ion = $y; - $mass_max = $hgrouprepres{$z}{$y}{mass}; - } - if($hgrouprepres{$z}{$y}{mass} > $mass_max){ - if($hfirst{$y}>$intensity_threshold){ - my $a = $intens_max * $intensity_pourc; - if($hfirst{$y} > $a){ - $max_int_max_mass_ion = $y; - $mass_max = $hgrouprepres{$z}{$y}{mass}; - } - } - } - - } - } - - - $hgrouprepres{$z}{max_int}=$max_int_ion; - $hgrouprepres{$z}{max_mass}=$max_mass_ion; - $hgrouprepres{$z}{max_squared}=$max_squared_ion; - $hgrouprepres{$z}{max_int_max_mass}=$max_int_max_mass_ion; - - } - - - ###################### - ### Print result ! ### - ###################### - - open(F4, ">$output_tabular"); - open(F5, $combined_DMVM); - - my $line_nb = 0; - my %hheader; - while (my $line = ){ - chomp $line; - - - my @tline = split (/\t/, $line); - - if($line_nb == 0){ - print F4 "$line\tACF_groups"; - if($opt == 1){ - if($repres_opt eq "intensity"){print F4 "\tintensity_repres\tACF_filter\n"} - if($repres_opt eq "mass"){print F4 "\tmass_repres\tACF_filter\n"} - if($repres_opt eq "mixt"){print F4 "\tmass2intens_repres\tACF_filter\n"} - if($repres_opt eq "max_intensity_max_mass"){print F4 "\tmax_intensity_max_mass_repres\tACF_filter\n"} - - } - else{ - if($repres_opt eq "intensity"){print F4 "\tintensity_repres\tisotopes_adducts_fragments_[#id|annotation(delta_annotation)]\tACF_filter\n"} - if($repres_opt eq "mass"){print F4 "\tmass_repres\tisotopes_adducts_fragments_[#id|annotation(delta_annotation)]\tACF_filter\n"} - if($repres_opt eq "mixt"){print F4 "\tmass2intens_repres\tisotopes_adducts_fragments_[#id|annotation(delta_annotation)]\tACF_filter\n"} - if($repres_opt eq "max_intensity_max_mass"){print F4 "\tmax_intensity_max_mass_repres\tisotopes_adducts_fragments_[#id|annotation(delta_annotation)]\tACF_filter\n"} - } - - - ### Creation of a header hash - for(my $i=0; $i - - perl-statistics - perl-soap-lite - ){ + chomp $line; + my @tline = split(/[\t;]/, $line); + if(defined($hmass{$tline[2]})){ + print "Il existe déjà une même différence de masse : $tline[2] !\n"; + } + $hmass{$tline[1]}{$tline[2]}=$tline[0]; + } + + close F1; +# my $count=0; +# foreach my $k (keys %hmass){ +# $count++; +# } + + return %hmass; + + +} + + + + + + + +######################################################## +### Creation of a sif table + correlation filtration ### +######################################################## + + +sub sifTableCreation{ + + my $file = $_[0]; + my $output_sif = $_[1]; + my $opt = $_[2]; + my $rt_threshold = $_[3]; + my $mass_threshold = $_[4]; + my $correl_threshold = $_[5]; + my $dataMatrix = $_[6]; + my $output_tabular = $_[7]; + my $combined_DMVM = $_[8]; + my $repres_opt = $_[9]; + my $intensity_threshold = $_[10]; + my $intensity_pourc = $_[11]; + my $refhmass = $_[12]; + + + + + my %hheader_file; + my %hduplicate; + + my %hcorrelgroup; + my $groupct=1; + + + my $linenb3=0; + my %hheader_line; + my %hrtmz; + + open (F5, $combined_DMVM); + while(my $line = ){ + chomp $line; + my @tline = split(/\t/, $line); + + if($linenb3 == 0){ + for(my $i=0; $i$output_sif") or die "Impossible to open $output_sif\n"; + + while(my $line = ){ + chomp $line; + my @tline = split(/\t/, $line); + + + ############################### + ### Création of a sif table ### + ############################### + + if($linenb == 0){ + for(my $i=0; $i $correl_threshold){ + + print F2 "$a\t$coef\t$b\n"; + + my $count=0; + + ###################################################### + ### Analytic correlation filtrering follow options ### + ###################################################### + + + + my $amass=$hrtmz{$a}{mz}; + my $atemp=$hrtmz{$a}{rt}; + my $bmass= $hrtmz{$b}{mz}; + my $btemp=$hrtmz{$b}{rt}; + my $diff = $amass-$bmass; + $diff = abs($diff); + + ### Option 1: Don't take into acount mass information ### + + if($opt == 1){ + my $btplus = $btemp + $rt_threshold; + my $btmoins = $btemp - $rt_threshold; + if(($btmoins <= $atemp) && ($atemp <= $btplus)){ + foreach my $k (keys %hcorrelgroup){ + + if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){ + $hcorrelgroup{$k}{$a}=1; + $hcorrelgroup{$k}{$b}=1; + $count++; + last; + } + } + if($count == 0){ + my $groupnb="group".$groupct; + $hcorrelgroup{$groupnb}{$a}=1; + $hcorrelgroup{$groupnb}{$b}=1; + $groupct ++; + } + + } + } + + + ### Option 2: Check that all mass differences are include in a specific list taking into account RT information ### + + elsif($opt == 2){ + + my $print = 0; + foreach my $s (keys %{$refhmass}){ + foreach my $r (keys %{$refhmass->{$s}}){ + my $rm = $r - $mass_threshold; + my $rp = $r + $mass_threshold; + if(($diff <= $rp) && ($diff >= $rm)){ + if($print == 0){ + my $btplus = $btemp + $rt_threshold; + my $btmoins = $btemp - $rt_threshold; + + if(($btmoins <= $atemp) && ($atemp <= $btplus)){ +# foreach my $s (keys %{%$refhmass{$r}}){ + # print F2 "$line\t$hmass{$r}{$s} : $s ($r)\n"; + foreach my $k (keys %hcorrelgroup){ + if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){ + $hcorrelgroup{$k}{$a}=1; + $hcorrelgroup{$k}{$b}=1; +# $hcorrelgroup{$k}{frag}.="#".$s; + $count++; + last; + } + } + if($count == 0){ + my $groupnb="group".$groupct; + $hcorrelgroup{$groupnb}{$a}=1; + $hcorrelgroup{$groupnb}{$b}=1; +# $hcorrelgroup{$groupnb}{frag}.="#".$s; + $groupct ++; + + } + $print = 1; + } + + } + } + } + } + } + + + ### Option 3: Check that all mass differences are include in a specific list, ignoring RT information ### + + elsif($opt == 3){ + + my $print = 0; + foreach my $s (keys %{$refhmass}){ + foreach my $r (keys %{$refhmass->{$s}}){ + my $rm = $r - $mass_threshold; + my $rp = $r + $mass_threshold; + if(($diff <= $rp) && ($diff >= $rm)){ + if($print == 0){ + +# foreach my $s (keys %{%$refhmass{$r}}){ + # print F2 "$line\t$hmass{$r}{$s} : $s ($r)\n"; + foreach my $k (keys %hcorrelgroup){ + if((defined($hcorrelgroup{$k}{$a})) || (defined($hcorrelgroup{$k}{$b}))){ + $hcorrelgroup{$k}{$a}=1; + $hcorrelgroup{$k}{$b}=1; +# $hcorrelgroup{$k}{frag}.="#".$s; + $count++; + last; + } + } + if($count == 0){ + my $groupnb="group".$groupct; + $hcorrelgroup{$groupnb}{$a}=1; + $hcorrelgroup{$groupnb}{$b}=1; +# $hcorrelgroup{$groupnb}{frag}.="#".$s; + $groupct ++; + } + $print = 1; + } + } + } + } + } + } + + + } + } + } + } + $linenb ++; + } + close F1; + close F2; + + + + + ############################################# + ### Join groups that have been subdivided ### + ############################################# + + my @tdelete; + + foreach my $k (keys %hcorrelgroup){ + foreach my $i (keys %{$hcorrelgroup{$k}}){ + foreach my $v (keys %hcorrelgroup){ + my $count = 0; + if ($v ne $k){ + foreach my $w (keys %{$hcorrelgroup{$v}}){ +# if($w ne "frag"){ + if($w eq $i){ + $count = 1; + push(@tdelete, $v); + } +# } + } + } + if($count == 1){ + foreach my $w (keys %{$hcorrelgroup{$v}}){ + $hcorrelgroup{$k}{$w}=$hcorrelgroup{$v}{$w}; + } + delete($hcorrelgroup{$v}); + } + } + } + } + + foreach my $t (@tdelete){ + delete($hcorrelgroup{$t}); + } + + + ### Do it twice to see if it fix the problem of unmerge groups + + foreach my $k (keys %hcorrelgroup){ + foreach my $i (keys %{$hcorrelgroup{$k}}){ + foreach my $v (keys %hcorrelgroup){ + my $count = 0; + if ($v ne $k){ + foreach my $w (keys %{$hcorrelgroup{$v}}){ +# if($w ne "frag"){ + if($w eq $i){ + $count = 1; + push(@tdelete, $v); + } +# } + } + } + if($count == 1){ + foreach my $w (keys %{$hcorrelgroup{$v}}){ + $hcorrelgroup{$k}{$w}=$hcorrelgroup{$v}{$w}; + } + delete($hcorrelgroup{$v}); + } + } + } + } + + foreach my $t (@tdelete){ + delete($hcorrelgroup{$t}); + } + + + + ########################################## + ### Addition of annotation information ### + ########################################## + + foreach my $k (keys %hcorrelgroup){ + foreach my $i (keys %{$hcorrelgroup{$k}}){ + foreach my $j (keys %{$hcorrelgroup{$k}}){ + my $count = 0; + if ($i ne $j){ + + my $a = $hrtmz{$i}{mz}; + my $b = $hrtmz{$j}{mz}; + + my $diff = $a - $b; + my $sign; + if($diff>0){ + $sign="+"; + } + if($diff<0){ + $sign="-"; + } + $diff = abs($diff); + + foreach my $z (keys %{$refhmass}){ + + foreach my $y (keys %{$refhmass->{$z}}){ + my $ym = $y - $mass_threshold; + my $yp = $y + $mass_threshold; + + + if(($diff <= $yp) && ($diff >= $ym)){ + my $diff_list = $diff - $y; + $diff_list = abs($diff_list); + $diff_list = sprintf ("%0.6f", $diff_list); + + if($hcorrelgroup{$k}{$i} eq 1){ + my $val = "#".$j."|".$sign."(".$z.")(".$diff_list.")|"; + $hcorrelgroup{$k}{$i}=$val; + $count ++; + } + else{ + if($count == 0){ + my $val = "#".$j."|".$sign."(".$z.")(".$diff_list.")|"; + $hcorrelgroup{$k}{$i}.=$val; + $count ++; + } + else{ + my $val = $sign."(".$z.")(".$diff_list.")|"; + $hcorrelgroup{$k}{$i}.=$val; + $count ++; + } + } + } + } + } + } + } + } + } + + + + #################################################### + ### Choose the representative ion for each group ### + #################################################### + + my %hgrouprepres; + + open(F3, $dataMatrix); + + while (my $line = ){ + chomp $line; + + my @tline = split (/\t/, $line); + + + + foreach my $k (keys %hcorrelgroup){ + foreach my $i (keys %{$hcorrelgroup{$k}}){ + + if($tline[0] eq $i){ + $hgrouprepres{$k}{$i}{mass}=$hrtmz{$tline[0]}{mz}; + + my $intensity; + my $nbsubjects=0; + for(my $y=1;$y $max_intensity){ + $max_intensity = $hgrouprepres{$z}{$w}{intensity}; + $max_int_ion = $w; + + } + if($hgrouprepres{$z}{$w}{mass} > $max_mass){ + $max_mass = $hgrouprepres{$z}{$w}{mass}; + $max_mass_ion = $w; + } + if($hgrouprepres{$z}{$w}{squaredmassint} > $max_squared){ + $max_squared = $hgrouprepres{$z}{$w}{squaredmassint}; + $max_squared_ion = $w; + } + } + + my $max_int_max_mass_ion=""; + + if($repres_opt eq "max_intensity_max_mass"){ + my %hfirst; + my $first=0; + foreach my $w (reverse sort {$hgrouprepres{$z}{$a}{intensity} <=> $hgrouprepres{$z}{$b}{intensity} } keys %{$hgrouprepres{$z}}){ + $first ++; + if ($first <= 3){ + $hfirst{$w} = $hgrouprepres{$z}{$w}{intensity}; + } + } + + my $first_2 = 0; + my $intens_max = 0; + my $mass_max = 0; + + foreach my $y (reverse sort {$hfirst{$a} <=> $hfirst{$b}} keys %hfirst){ + + + + $first_2 ++; + if($first_2 == 1){ + $intens_max = $hfirst{$y}; + if($intensity_threshold > $intens_max){ + $intensity_threshold = 0; + } + $max_int_max_mass_ion = $y; + $mass_max = $hgrouprepres{$z}{$y}{mass}; + } + if($hgrouprepres{$z}{$y}{mass} > $mass_max){ + if($hfirst{$y}>$intensity_threshold){ + my $a = $intens_max * $intensity_pourc; + if($hfirst{$y} > $a){ + $max_int_max_mass_ion = $y; + $mass_max = $hgrouprepres{$z}{$y}{mass}; + } + } + } + + } + } + + + $hgrouprepres{$z}{max_int}=$max_int_ion; + $hgrouprepres{$z}{max_mass}=$max_mass_ion; + $hgrouprepres{$z}{max_squared}=$max_squared_ion; + $hgrouprepres{$z}{max_int_max_mass}=$max_int_max_mass_ion; + + } + + + ###################### + ### Print result ! ### + ###################### + + open(F4, ">$output_tabular"); + open(F5, $combined_DMVM); + + my $line_nb = 0; + my %hheader; + while (my $line = ){ + chomp $line; + + + my @tline = split (/\t/, $line); + + if($line_nb == 0){ + print F4 "$line\tACF_groups"; + if($opt == 1){ + if($repres_opt eq "intensity"){print F4 "\tintensity_repres\tACF_filter\n"} + if($repres_opt eq "mass"){print F4 "\tmass_repres\tACF_filter\n"} + if($repres_opt eq "mixt"){print F4 "\tmass2intens_repres\tACF_filter\n"} + if($repres_opt eq "max_intensity_max_mass"){print F4 "\tmax_intensity_max_mass_repres\tACF_filter\n"} + + } + else{ + if($repres_opt eq "intensity"){print F4 "\tintensity_repres\tisotopes_adducts_fragments_[#id|annotation(delta_annotation)]\tACF_filter\n"} + if($repres_opt eq "mass"){print F4 "\tmass_repres\tisotopes_adducts_fragments_[#id|annotation(delta_annotation)]\tACF_filter\n"} + if($repres_opt eq "mixt"){print F4 "\tmass2intens_repres\tisotopes_adducts_fragments_[#id|annotation(delta_annotation)]\tACF_filter\n"} + if($repres_opt eq "max_intensity_max_mass"){print F4 "\tmax_intensity_max_mass_repres\tisotopes_adducts_fragments_[#id|annotation(delta_annotation)]\tACF_filter\n"} + } + + + ### Creation of a header hash + for(my $i=0; $i