annotate lib/hr.pm @ 3:78afd7f439f3 draft default tip

master branch Updating with tag :CI_COMMIT_TAG - - Fxx
author fgiacomoni
date Wed, 15 Feb 2023 15:57:49 +0000
parents 23970530a518
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
1 package lib::hr ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
2
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
3 use strict;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
4 no strict "refs" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
5 use warnings ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
6 use Exporter ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
7 use threads ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
8 use HTML::Template ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
9 use Carp ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
10
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
11 use Data::Dumper ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
12
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
13 use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS);
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
14
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
15 our $VERSION = "1.0";
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
16 our @ISA = qw(Exporter);
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
17 our @EXPORT = qw( manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe );
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
18 our %EXPORT_TAGS = ( ALL => [qw(manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe )] );
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
19
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
20 =head1 NAME
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
21
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
22 lib::hr - A module for managing / launching hr binary (structure elucidation c++ progr)
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
23
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
24 =head1 SYNOPSIS
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
25
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
26 use lib::hr;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
27 my $object = lib::hr->new();
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
28 print $object->as_string;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
29
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
30 =head1 DESCRIPTION
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
31
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
32 This module does not really exist, it
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
33 was made for the sole purpose of
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
34 demonstrating how POD works.
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
35
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
36 =head1 METHODS
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
37
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
38 Methods are :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
39
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
40 =head2 METHOD new
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
41
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
42 ## Description : new
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
43 ## Input : $self
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
44 ## Ouput : bless $self ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
45 ## Usage : new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
46
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
47 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
48
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
49 sub new {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
50 ## Variables
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
51 my $self={};
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
52 bless($self) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
53 return $self ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
54 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
55 ### END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
56
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
57
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
58 =head2 METHOD manageAtomsConf
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
59
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
60 ## Description : take all max atom values from CONF file and personal choice
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
61 ## Input : $confFile, $C12_max_value, $C13_max_value, $H_max_value, $N_max_value, $O_max_value, $P_max_value, $S_max_value, $F_max_value, $Cl_max_value, $K_max_value, $Br_max_value, $Na_max_value
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
62 ## Output : $atomFullConfig
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
63 ## Usage : my ( $atomFullConfig ) = manageAtomsConf ( $confFile, $C12_max_value, $C13_max_value, $H_max_value, $N_max_value, $O_max_value, $P_max_value, $S_max_value, $F_max_value, $Cl_max_value, $K_max_value, $Br_max_value, $Na_max_value ) ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
64
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
65 =cut
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
66 ## START of SUB
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
67 sub manageAtomsConf{
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
68 ## Retrieve Values
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
69 my $self = shift ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
70 my ($confFile, $C12_max_value, $C13_max_value, $H_max_value, $N_max_value, $O_max_value, $P_max_value, $S_max_value, $F_max_value, $Cl_max_value, $K_max_value, $Br_max_value, $Na_max_value) = @_ ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
71
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
72 my %atomFullConfig = () ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
73 $atomFullConfig{'C'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
74 $atomFullConfig{'H'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
75 $atomFullConfig{'N'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
76 $atomFullConfig{'O'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
77 $atomFullConfig{'P'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
78 $atomFullConfig{'S'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
79 $atomFullConfig{'F'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
80 $atomFullConfig{'L'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
81 $atomFullConfig{'K'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
82 $atomFullConfig{'B'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
83 $atomFullConfig{'A'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
84 $atomFullConfig{'1'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
85
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
86 if (defined $C12_max_value) { $atomFullConfig{'C'}{'max'} = $C12_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
87 else { $atomFullConfig{'C'}{'max'} = $confFile->{'C'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
88
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
89 if (defined $H_max_value) { $atomFullConfig{'H'}{'max'} = $H_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
90 else { $atomFullConfig{'H'}{'max'} = $confFile->{'H'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
91
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
92 if (defined $N_max_value) { $atomFullConfig{'N'}{'max'} = $N_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
93 else { $atomFullConfig{'N'}{'max'} = $confFile->{'N'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
94
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
95 if (defined $O_max_value) { $atomFullConfig{'O'}{'max'} = $O_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
96 else { $atomFullConfig{'O'}{'max'} = $confFile->{'O'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
97
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
98 if (defined $P_max_value) { $atomFullConfig{'P'}{'max'} = $P_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
99 else { $atomFullConfig{'P'}{'max'} = $confFile->{'DEFAULT_MAX'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
100
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
101 if (defined $S_max_value) { $atomFullConfig{'S'}{'max'} = $S_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
102 else { $atomFullConfig{'S'}{'max'} = $confFile->{'DEFAULT_MAX'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
103
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
104 if (defined $F_max_value) { $atomFullConfig{'F'}{'max'} = $F_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
105 else { $atomFullConfig{'F'}{'max'} = $confFile->{'DEFAULT_MAX'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
106
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
107 if (defined $Cl_max_value) { $atomFullConfig{'L'}{'max'} = $Cl_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
108 else { $atomFullConfig{'L'}{'max'} = $confFile->{'DEFAULT_MAX'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
109
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
110 if (defined $K_max_value) { $atomFullConfig{'K'}{'max'} = $K_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
111 else { $atomFullConfig{'K'}{'max'} = $confFile->{'DEFAULT_MAX'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
112
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
113 if (defined $Br_max_value) { $atomFullConfig{'B'}{'max'} = $Br_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
114 else { $atomFullConfig{'B'}{'max'} = $confFile->{'DEFAULT_MAX'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
115
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
116 if (defined $Na_max_value) { $atomFullConfig{'A'}{'max'} = $Na_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
117 else { $atomFullConfig{'A'}{'max'} = $confFile->{'DEFAULT_MAX'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
118
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
119 if (defined $C13_max_value) { $atomFullConfig{'1'}{'max'} = $C13_max_value ; }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
120 else { $atomFullConfig{'1'}{'max'} = $confFile->{'DEFAULT_MAX'} }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
121
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
122 return (\%atomFullConfig) ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
123 }
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
124 ### END of SUB
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
125
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
126 =head2 METHOD manage_atoms_and_ranges
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
127
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
128 ## Description : allow from an initial config to add or delete atoms and their range
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
129 ## Input : $atomsconfig, $atombasic, $atomsupp
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
130 ## Output : $atomcleanconfig
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
131 ## Usage : my ( $atomcleanconfig ) = manage_atoms_and_ranges ( $atomsconfig, $atombasic, $atomsupp ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
132
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
133 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
134 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
135 sub manage_atoms_and_ranges {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
136 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
137 my $self = shift ;
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
138 my ( $atomFullconfig, $atombasic, $atomsupp ) = @_;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
139 my ( $atomConfigCmd ) = ( undef ) ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
140 my %atomCurrentConfig = () ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
141 $atomCurrentConfig{'C'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
142 $atomCurrentConfig{'H'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
143 $atomCurrentConfig{'N'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
144 $atomCurrentConfig{'O'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
145 $atomCurrentConfig{'P'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
146 $atomCurrentConfig{'S'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
147 $atomCurrentConfig{'F'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
148 $atomCurrentConfig{'L'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
149 $atomCurrentConfig{'K'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
150 $atomCurrentConfig{'B'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
151 $atomCurrentConfig{'A'} = {'min' => 0, 'max' => 0} ;
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
152 $atomCurrentConfig{'1'} = {'min' => 0, 'max' => 0} ;
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
153
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
154 # basic atoms case:
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
155 foreach my $atom ( (split(",", $atombasic )) ) {
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
156 if ( exists $atomFullconfig->{$atom}{'max'} ) { $atomCurrentConfig{$atom}{'max'} = $atomFullconfig->{$atom}{'max'} ; }
1
e2cbcf6fa22e master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 0
diff changeset
157 else { print "*** $atom not recognized***\n" ; }
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
158 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
159
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
160 # suppl. atoms case
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
161 foreach my $atom ( (split(",", $atomsupp )) ) {
2
23970530a518 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 1
diff changeset
162 #print "*** $atom***\n" ;
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
163 if ( exists $atomFullconfig->{$atom}{'max'} ) { $atomCurrentConfig{$atom}{'max'} = $atomFullconfig->{$atom}{'max'} ; }
1
e2cbcf6fa22e master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 0
diff changeset
164 else { print "*** $atom not recognized***\n" ; }
e2cbcf6fa22e master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 0
diff changeset
165
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
166 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
167
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
168 # Create atoms and range parameters:
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
169 foreach my $selectedAtom ( keys %atomCurrentConfig ) {
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
170 $atomConfigCmd .= ' -'.$selectedAtom.' '.$atomCurrentConfig{$selectedAtom}{'min'}.'-'.$atomCurrentConfig{$selectedAtom}{'max'} ;
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
171 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
172
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
173 return ($atomConfigCmd) ;
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
174 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
175 ### END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
176
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
177 =head2 METHOD manage_tolerance
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
178
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
179 ## Description : check range and format of tolerance
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
180 ## Input : $tolerance, $default_value
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
181 ## Output : $set_tol
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
182 ## Usage : my ( $set_tol ) = manage_tolerance( $tolerance, $default_value ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
183
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
184 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
185 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
186 sub manage_tolerance {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
187 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
188 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
189 my ( $tolerance, $default_value ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
190 my ($set_tol, $tmp_tol ) = (undef, undef) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
191
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
192 if ( ( defined $$tolerance ) and ( defined $$default_value )) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
193 $tmp_tol = $$tolerance ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
194 $tmp_tol =~ tr/,/./;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
195 ## tolerance doit etre >0 et <10
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
196 if ( $tmp_tol <= 0 || $tmp_tol >= 10 ){
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
197 $set_tol = $$default_value ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
198 warn "The used tolerance is set to $$default_value (out of authorized range)\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
199 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
200 else{ $set_tol = $tmp_tol ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
201 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
202 else { warn "Your tolerance or the default tol are not defined\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
203
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
204 return(\$set_tol) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
205 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
206 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
207
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
208 =head2 METHOD manage_mode
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
209
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
210 ## Description : manage mode and apply mass correction (positive/negative/neutral)
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
211 ## Input : $mode, $charge, $electron, $proton, $mass
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
212 ## Output : $exact_mass
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
213 ## Usage : my ( $exact_mass ) = manage_mode( $mode, $charge, $electron, $proton, $mass ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
214
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
215 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
216 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
217 sub manage_mode {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
218 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
219 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
220 my ( $mode, $charge, $electron, $proton, $mass ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
221 my ($exact_mass, $tmp_mass) = ( undef, undef ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
222
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
223 ## some explanations :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
224 # MS in + mode = adds H+ (proton) and molecule is positive : el+ => $charge = "positive"
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
225 # For HR, need to subtrack proton mz and to add electron mz (1 electron per charge) to the input mass which comes neutral!
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
226
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
227 if ( ( defined $$electron ) and ( defined $$proton ) ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
228 # check mass
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
229 if ( defined $$mass ) { $tmp_mass = $$mass ; $tmp_mass =~ tr/,/./ ; } # manage . and , in case of...
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
230 else { warn "No mass is defined\n" }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
231
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
232 # manage charge
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
233 if ( ( !defined $$charge ) || ($$charge < 0) ){ warn "Charge is not defined or value is less than zero\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
234
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
235 # set neutral mass in function of ms mode
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
236 if($$mode eq 'positive') { $exact_mass = ( $tmp_mass - $$proton + $$electron) * $$charge ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
237 elsif($$mode eq 'negative') { $exact_mass = ( $tmp_mass + $$proton - $$electron) * $$charge ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
238 elsif($$mode eq "neutral") { $exact_mass = $tmp_mass ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
239 else { warn "This mode doesn't exist : please select positive/negative or neutral mode\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
240 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
241 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
242 warn "Missing some parameter values (electron, neutron masses), please check your conf file\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
243 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
244 return(\$exact_mass) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
245 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
246 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
247
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
248 =head2 METHOD check_hr_exe
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
249
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
250 ## Description : permit to check the path of hr.exe and its full availability
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
251 ## Input : $hr_path, $hr_version
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
252 ## Output : true/false
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
253 ## Usage : my ( $res ) = check_hr_exe( $hr_path, $hr_version ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
254
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
255 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
256 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
257 sub check_hr_exe {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
258 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
259 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
260 my ( $hr_path, $hr_version ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
261 my $success = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
262 my $check_res = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
263
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
264 ## test path :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
265 if ( ( defined $$hr_path ) and ( defined $$hr_version ) ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
266 if ( defined $$hr_path ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
267 $success = `$$hr_path -version`;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
268 print "$success\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
269 if ($success !~/^$$hr_version/) { warn "You do not use the expected version of hr2 ($$hr_version)\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
270 else { $check_res = 1 ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
271 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
272 else { warn "Can't use HR because the binary file doesn't exist at the specified path ($$hr_path)\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
273
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
274 } ## END IF
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
275 else { warn "No HR path or Hr version defined\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
276
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
277 return($check_res) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
278 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
279 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
280
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
281 =head2 METHOD config_hr_exe
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
282
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
283 ## Description : builds hr execute line with needed params
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
284 ## Input : $hr_path, $hr_delta, $mass, $has_goldenrules, $atoms_and_ranks
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
285 ## Output : var2
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
286 ## Usage : my ( var2 ) = config_hr_exe( $hr_path, $hr_delta, $mass, $has_goldenrules, $atoms_and_ranks ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
287
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
288 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
289 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
290 sub config_hr_exe {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
291 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
292 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
293 my ( $hr_path, $hr_delta, $mass, $has_goldenrules, $atoms_and_ranks ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
294 my $hr_cmd = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
295
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
296 if ( ( defined $$hr_path ) and ( defined $$hr_delta ) and ( defined $$mass ) and ( defined $$atoms_and_ranks ) ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
297 $hr_cmd = $$hr_path.' -t '.$$hr_delta.' -m '.$$mass.' '.$$atoms_and_ranks ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
298 if ( defined $$has_goldenrules ) { $$hr_cmd .= ' -g ' ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
299 } ## END IF
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
300 else { warn "Some argvts are missing to build the current hr exec line\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
301
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
302 return(\$hr_cmd) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
303 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
304 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
305
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
306 =head2 METHOD threading_hr_exe
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
307
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
308 ## Description : prepare 5 threads for hr executing
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
309 ## Input : $method, $list
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
310 ## Output : $results
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
311 ## Usage : my ( $results ) = threading_hr_exe( $method, $list ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
312
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
313 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
314 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
315 sub threading_hr_exe {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
316 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
317 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
318 my ( $method, $list ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
319
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
320 my @results = () ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
321
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
322 if ( ( defined $list ) and ( defined $method )) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
323
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
324 for (my $i = 0; $i < (scalar @{$list}); $i+=6 ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
325 my $thr1 = threads->create($method, $self, $list->[$i]) if $list->[$i] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
326 my $thr2 = threads->create($method, $self, $list->[$i+1]) if $list->[$i+1] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
327 my $thr3 = threads->create($method, $self, $list->[$i+2]) if $list->[$i+2] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
328 my $thr4 = threads->create($method, $self, $list->[$i+3]) if $list->[$i+3] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
329 my $thr5 = threads->create($method, $self, $list->[$i+4]) if $list->[$i+4] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
330 my $thr6 = threads->create($method, $self, $list->[$i+5]) if $list->[$i+5] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
331 push ( @results, $thr1->join ) if $list->[$i] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
332 push ( @results, $thr2->join ) if $list->[$i+1] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
333 push ( @results, $thr3->join ) if $list->[$i+2] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
334 push ( @results, $thr4->join ) if $list->[$i+3] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
335 push ( @results, $thr5->join ) if $list->[$i+4] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
336 push ( @results, $thr6->join ) if $list->[$i+5] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
337 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
338 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
339 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
340 warn "Your input list or your method is undefined\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
341 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
342
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
343 return(\@results) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
344 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
345 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
346
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
347 =head2 METHOD hr_exe
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
348
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
349 ## Description : hr_exe launches hr and catches result
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
350 ## Input : $cmd
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
351 ## Output : $res
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
352 ## Usage : my ( $res ) = hr_exe( $cmd ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
353
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
354 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
355 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
356 sub hr_exe {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
357 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
358 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
359 my ( $cmd ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
360 my $res = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
361
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
362 if (defined $cmd){
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
363 #print "\n--CMD used : $cmd\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
364 $res = `$cmd` ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
365 sleep(0.5) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
366 #print "Results : $res\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
367 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
368
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
369 return (\$res) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
370 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
371 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
372
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
373
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
374 =head2 METHOD hr_out_parser
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
375
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
376 ## Description : parse output of hr and return a hash of features
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
377 ## Input : $res
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
378 ## Output : $parsed_res
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
379 ## Usage : my ( $parsed_res ) = hr_out_parser( $res ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
380
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
381 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
382 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
383 sub hr_out_parser {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
384 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
385 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
386 my ( $res ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
387
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
388 my %parsed_res = () ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
389 my ( @formula, @rings_and_double_bond_equivalents, @formula_mz, @mmus ) = ( (), (), (), () ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
390 my ( $formula_nb, $formula_total, $time ) = ( undef, undef, undef ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
391
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
392 if ( defined $$res ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
393 # foreach line
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
394 foreach my $line (split(/\n/,$$res)){
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
395 ## v1.02 - parse result line "C7.H17.N5. 2.0 171.1484 +17.2 mmu"
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
396 ## v1.03 - parse result line "C10.H25.N5.O5.P2.S2. C10H25N5O5P2S2 8.00 421.0772333 0 0 +0.40"
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
397 ## $1 = "C10.H25.N5.O5.P2.S2. " $2 = "C10H25N5O5P2S2" $3 = "8.00" $4="421.0772333" $5="0" $6="0" $7="+0.40"
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
398 ## if ( $line =~ /([\w|\.]+)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+([+|-]\d+.?\d*)\s+(.*)/ ) { ## for hr2 1.02
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
399
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
400 if ( $line =~ /([\w|\.]+)\s+(\w+)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+(\d+.?\d*)\s+([+|-]\d+.?\d*)/ ) { # for hr2 1.03
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
401 my ( $formula, $cleanformula, $rings_and_double_bond_equivalent, $formula_mz, $abscharge, $nadd, $mmu_value ) = ( $1, $2, $3, $4, $5, $6, $7 ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
402
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
403 if (defined $formula ) { $formula =~ s/\.//g ; push (@formula, $formula) ; } # clean \.
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
404 if (defined $rings_and_double_bond_equivalent ) { push (@rings_and_double_bond_equivalents, $rings_and_double_bond_equivalent) ; } #
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
405 if (defined $formula_mz ) { push (@formula_mz, $formula_mz) ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
406 if (defined $mmu_value ) { $mmu_value =~ s/\+// ; push (@mmus, $mmu_value) ; } # clean (+)
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
407 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
408 elsif ( $line =~ /(\d+)\s+formulas.+\s+(\d+)\s+seconds.+\s+(\d+)\s+formulae/ ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
409 ( $formula_nb, $time, $formula_total ) = ( $1, $2, $3 ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
410 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
411 else { next; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
412 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
413 # build parser
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
414 if ( scalar(@formula) > 0 ){
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
415 $parsed_res{'ENTRY_FORMULA'} = \@formula ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
416 $parsed_res{'rings_and_double_bond_equivalents'} = \@rings_and_double_bond_equivalents ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
417 $parsed_res{'ENTRY_CPD_MZ'} = \@formula_mz ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
418 $parsed_res{'ENTRY_DELTA'} = \@mmus ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
419 $parsed_res{'MASSES_TOTAL'} = \$formula_nb ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
420 $parsed_res{'time'} = \$time ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
421 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
422 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
423 return(\%parsed_res) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
424 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
425 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
426
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
427
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
428 =head2 METHOD set_html_tbody_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
429
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
430 ## Description : initializes and build the tbody object (perl array) need to html template
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
431 ## Input : $nb_pages, $nb_items_per_page
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
432 ## Output : $tbody_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
433 ## Usage : my ( $tbody_object ) = set_html_tbody_object($nb_pages, $nb_items_per_page) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
434
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
435 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
436 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
437 sub set_html_tbody_object {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
438 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
439 my ( $nb_pages, $nb_items_per_page ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
440
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
441 my ( @tbody_object ) = ( ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
442
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
443 for ( my $i = 1 ; $i <= $nb_pages ; $i++ ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
444
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
445 my %pages = (
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
446 # tbody feature
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
447 PAGE_NB => $i,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
448 MASSES => [], ## end MASSES
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
449 ) ; ## end TBODY N
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
450 push (@tbody_object, \%pages) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
451 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
452 return(\@tbody_object) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
453 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
454 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
455
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
456 =head2 METHOD add_mz_to_tbody_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
457
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
458 ## Description : initializes and build the mz object (perl array) need to html template
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
459 ## Input : $tbody_object, $nb_items_per_page, $mz_list
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
460 ## Output : $tbody_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
461 ## Usage : my ( $tbody_object ) = add_mz_to_tbody_object( $tbody_object, $nb_items_per_page, $mz_list ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
462
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
463 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
464 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
465 sub add_mz_to_tbody_object {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
466 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
467 my ( $tbody_object, $nb_items_per_page, $mz_list, $ids_list, $totals ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
468
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
469 my ( $current_page, $mz_index ) = ( 0, 0 ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
470
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
471 foreach my $page ( @{$tbody_object} ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
472
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
473 my @colors = ('white', 'green') ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
474 my ( $current_index, , $icolor ) = ( 0, 0 ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
475
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
476 for ( my $i = 1 ; $i <= $nb_items_per_page ; $i++ ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
477 #
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
478 if ( $current_index > $nb_items_per_page ) { ## manage exact mz per html page
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
479 $current_index = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
480 last ; ##
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
481 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
482 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
483 $current_index++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
484 if ( $icolor > 1 ) { $icolor = 0 ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
485
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
486 if ( exists $mz_list->[$mz_index] ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
487 my $total = \0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
488 if ( $totals->[$mz_index]{'MASSES_TOTAL'} ) { $total = $totals->[$mz_index]{'MASSES_TOTAL'} }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
489
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
490 my %mz = (
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
491 # mass feature
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
492 MASSES_ID_QUERY => $ids_list->[$mz_index],
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
493 MASSES_MZ_QUERY => $mz_list->[$mz_index],
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
494 MZ_COLOR => $colors[$icolor],
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
495 MASSES_NB => $mz_index+1,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
496 MASSES_TOTAL => $$total ,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
497 ENTRIES => [] ,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
498 ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
499 push ( @{ $tbody_object->[$current_page]{MASSES} }, \%mz ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
500 # Html attr for mass
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
501 $icolor++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
502 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
503 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
504 $mz_index++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
505 } ## foreach mz
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
506
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
507 $current_page++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
508 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
509 return($tbody_object) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
510 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
511 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
512
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
513 =head2 METHOD add_entries_to_tbody_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
514
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
515 ## Description : initializes and build the mz object (perl array) need to html template
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
516 ## Input : $tbody_object, $nb_items_per_page, $mz_list, $entries
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
517 ## Output : $tbody_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
518 ## Usage : my ( $tbody_object ) = add_entries_to_tbody_object( $tbody_object, $nb_items_per_page, $mz_list, $entries ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
519
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
520 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
521 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
522 sub add_entries_to_tbody_object {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
523 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
524 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
525 my ( $tbody_object, $results ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
526
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
527 my $index_page = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
528 my $index_mz_continous = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
529
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
530 foreach my $page (@{$tbody_object}) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
531
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
532 my $index_mz = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
533
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
534 foreach my $mz (@{ $tbody_object->[$index_page]{MASSES} }) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
535
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
536 my $index_res = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
537 if ( $results->[$index_mz_continous]{ENTRY_FORMULA} ){
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
538
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
539 my $entry_nb = scalar( @{ $results->[$index_mz_continous]{ENTRY_FORMULA} } ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
540 for( my $i = 0 ; $i<$entry_nb; $i++ ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
541 my %entry = (
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
542 ENTRY_COLOR => $tbody_object->[$index_page]{MASSES}[$index_mz]{MZ_COLOR},
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
543 ENTRY_FORMULA => $results->[$index_mz_continous]->{ENTRY_FORMULA}[$i],
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
544 ENTRY_CPD_MZ => $results->[$index_mz_continous]->{ENTRY_CPD_MZ}[$i],
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
545 ENTRY_DELTA => $results->[$index_mz_continous]->{ENTRY_DELTA}[$i]
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
546 ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
547 push ( @{ $tbody_object->[$index_page]{MASSES}[$index_mz]{ENTRIES} }, \%entry) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
548 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
549 $index_res++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
550 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
551 $index_mz ++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
552 $index_mz_continous ++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
553 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
554 $index_page++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
555 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
556 return($tbody_object) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
557 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
558 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
559
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
560 =head2 METHOD write_html_skel
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
561
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
562 ## Description : prepare and write the html output file
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
563 ## Input : $html_file_name, $html_object, $html_template
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
564 ## Output : $html_file_name
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
565 ## Usage : my ( $html_file_name ) = write_html_skel( $html_file_name, $html_object ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
566
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
567 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
568 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
569 sub write_html_skel {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
570 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
571 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
572 my ( $html_file_name, $html_object, $pages , $search_condition, $html_template, $js_path, $css_path ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
573
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
574 my $html_file = $$html_file_name ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
575
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
576 if ( defined $html_file ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
577 open ( HTML, ">$html_file" ) or die "Can't create the output file $html_file " ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
578
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
579 if (-e $html_template) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
580 my $ohtml = HTML::Template->new(filename => $html_template);
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
581 $ohtml->param( JS_GALAXY_PATH => $js_path, CSS_GALAXY_PATH => $css_path ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
582 $ohtml->param( CONDITIONS => $search_condition ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
583 $ohtml->param( PAGES_NB => $pages ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
584 $ohtml->param( PAGES => $html_object ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
585 print HTML $ohtml->output ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
586 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
587 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
588 croak "Can't fill any html output : No template available ($html_template)\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
589 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
590
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
591 close (HTML) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
592 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
593 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
594 croak "No output file name available to write HTML file\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
595 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
596 return(\$html_file) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
597 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
598 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
599
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
600 =head2 METHOD write_csv_one_mass
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
601
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
602 ## Description : print a csv file
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
603 ## Input : $masses, $ids, $results, $file
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
604 ## Output : N/A
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
605 ## Usage : write_csv_one_mass( $ids, $results, $file ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
606
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
607 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
608 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
609 sub write_csv_one_mass {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
610 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
611 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
612 my ( $masses, $ids, $results, $file, ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
613
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
614 open(CSV, '>:utf8', "$file") or die "Cant' create the file $file\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
615 print CSV "ID\tMASS_SUBMIT\tCPD_FORMULA\tCPD_MW\tDELTA\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
616
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
617 my $i = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
618
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
619 foreach my $id (@{$ids}) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
620 my $mass = $masses->[$i] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
621
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
622 if ( $results->[$i] ) { ## an requested id has a result in the list of hashes $results.
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
623
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
624 my $entry_nb = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
625
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
626 ## in case of no results -- Hr_parsed Results : $VAR1 = [ { 'ENTRY_FORMULA' => [] } ];
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
627 if ( !$results->[$i]{'ENTRY_FORMULA'} ) { print CSV "$id\t$mass\tN/A\t0.0\t0.0\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
628
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
629 foreach (@{$results->[$i]{'ENTRY_FORMULA'}}) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
630
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
631 print CSV "$id\t$mass\t" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
632 ## print cpd formula
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
633 if ( $results->[$i]{'ENTRY_FORMULA'}[$entry_nb] ) { print CSV "$results->[$i]{'ENTRY_FORMULA'}[$entry_nb]\t" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
634 else { print CSV "N/A\t" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
635 ## print cpd name
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
636 if ( $results->[$i]{'ENTRY_CPD_MZ'}[$entry_nb] ) { print CSV "$results->[$i]{'ENTRY_CPD_MZ'}[$entry_nb]\t" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
637 else { print CSV "0.0\t" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
638 ## print delta
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
639 if ( $results->[$i]{'ENTRY_DELTA'}[$entry_nb] ) { print CSV "$results->[$i]{'ENTRY_DELTA'}[$entry_nb]\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
640 else { print CSV "0.0\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
641 $entry_nb++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
642 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
643 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
644 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
645 print CSV "$id\t$mass\tN/A\t0.0\t0.0\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
646 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
647 $i++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
648 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
649 close(CSV) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
650 return() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
651 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
652 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
653
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
654 =head2 METHOD add_hr_matrix_to_input_matrix
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
655
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
656 ## Description : build a full matrix (input + lm column)
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
657 ## Input : $input_matrix_object, $lm_matrix_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
658 ## Output : $output_matrix_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
659 ## Usage : my ( $output_matrix_object ) = add_hr_matrix_to_input_matrix( $input_matrix_object, $hr_matrix_object ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
660
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
661 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
662 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
663 sub add_hr_matrix_to_input_matrix {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
664 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
665 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
666 my ( $input_matrix_object, $hr_matrix_object ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
667
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
668 my @output_matrix_object = () ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
669 my $index_row = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
670
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
671 foreach my $row ( @{$input_matrix_object} ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
672 my @init_row = @{$row} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
673
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
674 if ( $hr_matrix_object->[$index_row] ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
675 my $dim = scalar(@{$hr_matrix_object->[$index_row]}) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
676
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
677 if ($dim > 1) { warn "the add method can't manage more than one column\n" ;}
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
678 my $lm_col = $hr_matrix_object->[$index_row][$dim-1] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
679
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
680 push (@init_row, $lm_col) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
681 $index_row++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
682 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
683 push (@output_matrix_object, \@init_row) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
684 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
685 return(\@output_matrix_object) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
686 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
687 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
688
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
689 =head2 METHOD write_csv_skel
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
690
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
691 ## Description : prepare and write csv output file
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
692 ## Input : $csv_file, $rows
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
693 ## Output : $csv_file
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
694 ## Usage : my ( $csv_file ) = write_csv_skel( $csv_file, $rows ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
695
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
696 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
697 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
698 sub write_csv_skel {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
699 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
700 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
701 my ( $csv_file, $rows ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
702
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
703 my $ocsv = lib::csv::new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
704 my $csv = $ocsv->get_csv_object("\t") ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
705 $ocsv->write_csv_from_arrays($csv, $$csv_file, $rows) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
706
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
707 return($csv_file) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
708 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
709 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
710
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
711 =head2 METHOD set_hr_matrix_object
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
712
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
713 ## Description : build the hr_row under its ref form
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
714 ## Input : $header, $init_mzs, $entries
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
715 ## Output : $hr_matrix
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
716 ## Usage : my ( $hmdb_matrix ) = set_hr_matrix_object( $header, $init_mzs, $entries ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
717
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
718 =cut
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
719 ## START of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
720 sub set_hr_matrix_object {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
721 ## Retrieve Values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
722 my $self = shift ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
723 my ( $header, $init_mzs, $entries ) = @_ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
724
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
725 my @hr_matrix = () ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
726
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
727 if ( defined $header ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
728 my @headers = () ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
729 push @headers, $header ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
730 push @hr_matrix, \@headers ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
731 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
732
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
733 my $index_mz = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
734
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
735 foreach my $mz ( @{$init_mzs} ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
736
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
737 my $index_entries = 0 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
738 my @clusters = () ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
739 my $cluster_col = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
740
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
741 my $nb_entries = $entries->[$index_mz]{MASSES_TOTAL} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
742
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
743 foreach (@{$entries->[$index_mz]{'ENTRY_FORMULA'}}) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
744
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
745 my $delta = $entries->[$index_mz]{'ENTRY_DELTA'}[$index_entries] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
746 my $hr_formula = $entries->[$index_mz]{'ENTRY_FORMULA'}[$index_entries] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
747 my $hr_mz = $entries->[$index_mz]{'ENTRY_CPD_MZ'}[$index_entries] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
748
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
749
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
750 ## METLIN data display model
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
751 ## entry1=VAR1::VAR2::VAR3::VAR4|entry2=VAR1::VAR2::VAR3::VAR4|...
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
752 # manage final pipe
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
753 if ($index_entries < $$nb_entries-1 ) { $cluster_col .= $delta.'::('.$hr_formula.')::'.$hr_mz.'|' ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
754 else { $cluster_col .= $delta.'::('.$hr_formula.')::'.$hr_mz ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
755
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
756 $index_entries++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
757 } ## end foreach
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
758 if ( !defined $cluster_col ) { $cluster_col = 'No_result_found_with HR' ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
759 push (@clusters, $cluster_col) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
760 push (@hr_matrix, \@clusters) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
761 $index_mz++ ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
762 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
763 return(\@hr_matrix) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
764 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
765 ## END of SUB
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
766
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
767
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
768
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
769 1 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
770
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
771
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
772 __END__
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
773
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
774 =head1 SUPPORT
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
775
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
776 You can find documentation for this module with the perldoc command.
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
777
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
778 perldoc hr.pm
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
779
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
780 =head1 Exports
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
781
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
782 =over 4
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
783
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
784 =item :ALL is manageAtomsConf manage_atoms_and_ranges check_hr_exe manage_tolerance manage_mode config_hr_exe
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
785
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
786 =back
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
787
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
788 =head1 AUTHOR
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
789
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
790 Franck Giacomoni E<lt>franck.giacomoni@clermont.inra.frE<gt>
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
791
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
792 =head1 LICENSE
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
793
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
794 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
795
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
796 =head1 VERSION
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
797
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
798 version 1 : 02 / 20 / 2014
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
799
3
78afd7f439f3 master branch Updating with tag :CI_COMMIT_TAG - - Fxx
fgiacomoni
parents: 2
diff changeset
800 version 2 : 02/ 15 / 2023 - Add personal max value for each atom manager methods, remove deprecated methods
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
801
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
802 =cut