annotate hr2_manager.pl @ 0:86296c048e46 draft

Init repository for [hr2]
author fgiacomoni
date Wed, 05 Jun 2019 09:40:20 -0400
parents
children e2cbcf6fa22e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
1 #!perl
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
2
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
3 ## script : hr2_manager.pl
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
4 ## VERSIONS :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
5 # - 01/03/2019 : Fix P issue, permit more flexible atom settings and add requirements for conda auto managing.
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
6
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
7 #=============================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
8 # Included modules and versions
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
9 #=============================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
10 ## Perl modules
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
11 use strict ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
12 use warnings ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
13 use Carp qw (cluck croak carp) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
14
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
15 use Data::Dumper ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
16 use Getopt::Long ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
17 use POSIX ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
18 use FindBin ; ## Allows you to locate the directory of original perl script
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
19
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
20 ## Dedicate Perl Modules (Home made...)
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
21 use lib $FindBin::Bin ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
22 my $binPath = $FindBin::Bin ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
23 use lib::hr qw( :ALL ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
24 ## PFEM Perl Modules
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
25 use lib::conf qw( :ALL ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
26 use lib::csv qw( :ALL ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
27
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
28 ## Initialized values
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
29 use vars qw(%parametre);
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
30 my $help = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
31 my ( $input_file, $line_header, $col_id, $col_mass ) = ( undef, undef, undef, undef ) ; # manage input option file of masses
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
32 my ( $mass ) = ( undef ) ; # manage input option masses list
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
33 my ( $tolerance, $mode, $charge, $has_golden_rules, $atomes, $atomes_basic ) = ( undef, undef, undef, undef, undef, undef ) ; # manage params
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
34 my ( $output_csv, $output_html ) = ( undef, undef) ; # manage ouputs
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
35 my $verbose = 2 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
36
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
37 #=============================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
38 # Manage EXCEPTIONS
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
39 #=============================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
40 &GetOptions ( "h" => \$help, # HELP
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
41 "input:s" => \$input_file,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
42 "colId:i" => \$col_id,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
43 "nbHeader:i" => \$line_header,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
44 "colmass:i" => \$col_mass,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
45 "masse:s" => \$mass,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
46 "tolerance:f" => \$tolerance,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
47 "mode:s" => \$mode,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
48 "charge:i" => \$charge,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
49 "regleOr:s" => \$has_golden_rules,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
50 "atomes:s" => \$atomes_basic, # [basic atoms like CNOHP]
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
51 "atomessup:s" => \$atomes,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
52 "output1:s" => \$output_csv,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
53 "outputView:s" => \$output_html,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
54 "verbose:i" => \$verbose,
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
55 ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
56
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
57 #=============================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
58 # EXCEPTIONS
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
59 #=============================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
60 $help and &help ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
61
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
62 #=============================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
63 # MAIN SCRIPT
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
64 #=============================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
65 my %atomsConf = () ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
66 $atomsConf{'C'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
67 $atomsConf{ 'H'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
68 $atomsConf{ 'N'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
69 $atomsConf{ 'O'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
70 $atomsConf{ 'P'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
71 $atomsConf{ 'S'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
72 $atomsConf{ 'F'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
73 $atomsConf{ 'L'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
74 $atomsConf{ 'K'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
75 $atomsConf{ 'B'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
76 $atomsConf{ 'A'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
77 $atomsConf{ '1'} = {'min' => 0, 'max' => 0} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
78
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
79 ## -------------- Conf file and verbose ------------------------ :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
80 my ( $CONF ) = ( undef ) ; ## verbose level is 3 for debugg
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
81 my $time_start = time ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
82
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
83 foreach my $conf ( <$binPath/*.cfg> ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
84 my $oConf = lib::conf::new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
85 $CONF = $oConf->as_conf($conf) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
86 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
87 ## --------------- Global parameters ---------------- :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
88 my ( $ids, $masses, $hr_cmds, $results, $parsed_results ) = ( undef, undef, undef, undef, undef ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
89 my $complete_rows = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
90 my ($hr_atoms_list, $hr_atoms_and_ranges, $set_tol, ) = (undef, undef, undef, ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
91
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
92 ## Check and manage params
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
93 my $ohr = lib::hr->new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
94
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
95 ## set tolerance
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
96 $set_tol = $ohr->manage_tolerance( \$tolerance, \$CONF->{'tolerance'} ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
97
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
98 ## check HR exe envt :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
99 my $hr_check = $ohr->check_hr_exe(\$CONF->{'HR2_EXE'}, \$CONF->{'HR2_VERSION'}) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
100 if (!defined $hr_check ) { croak "No hr exe available (wrong path) or wrong version will be used -- end of script\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
101
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
102 ## manage atoms and their ranges
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
103 #$hr_atoms_list = $ohr->manage_atoms(\$atomes, \$CONF->{'DEFAULT_ATOMS'}) ; ## DEPRECATED
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
104
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
105 # manage atoms and their ranges with a hash structure
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
106 my $atomsCurrentConf = $ohr->manage_atoms_and_ranges(\%atomsConf, $CONF, $atomes_basic, $atomes) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
107
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
108 #if ( defined $hr_atoms_list ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
109 # ## implements range foreach atom
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
110 # foreach my $atom ( (split(",", $$hr_atoms_list )) ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
111 # my $range_max = $CONF->{'DEFAULT_MAX'} ; # manage max value in case of
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
112 # if ( exists $CONF->{$atom} ) { $range_max = $CONF->{$atom} ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
113 # my $ref_range = $ohr->manage_atom_and_range(\$atom, \$CONF->{'DEFAULT_MIN'}, \$range_max ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
114 # $hr_atoms_and_ranges .= $$ref_range ; ## concat ranges
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
115 # }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
116 #}
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
117 #else { croak "No atom detected with input params\n" ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
118
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
119 ## Parsing input file with masses/ids or unik mass :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
120 ## manage only one mass
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
121 if ( ( defined $mass ) and ( $mass ne "" ) and ( $mass > 0 ) ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
122 $ids = ['mass_01'] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
123 $masses = [$mass] ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
124
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
125 } ## END IF
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
126 ## manage csv file containing list of masses
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
127 elsif ( ( defined $input_file ) and ( $input_file ne "" ) and ( -e $input_file ) ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
128
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
129 ## parse all csv for later : output csv build
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
130 my $ocsv_input = lib::csv->new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
131 my $complete_csv = $ocsv_input->get_csv_object( "\t" ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
132 $complete_rows = $ocsv_input->parse_csv_object($complete_csv, \$input_file) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
133
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
134 ## parse csv ids and masses
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
135 my $is_header = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
136 my $ocsv = lib::csv->new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
137 my $csv = $ocsv->get_csv_object( "\t" ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
138 if ( ( defined $line_header ) and ( $line_header > 0 ) ) { $is_header = 'yes' ; } else{ $is_header = 'no' ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
139 $masses = $ocsv->get_value_from_csv_multi_header( $csv, $input_file, $col_mass, $is_header, $line_header ) ; ## retrieve mz values on csv
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
140 $ids = $ocsv->get_value_from_csv_multi_header( $csv, $input_file, $col_id, $is_header, $line_header ) ; ## retrieve ids values on csv
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
141
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
142 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
143 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
144 croak "Can't work with HR2 : missing input file or mass (list of masses, ids)\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
145 } ## end ELSE
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
146
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
147 ## check using golden rules
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
148 if ( $has_golden_rules eq 'NO') { $has_golden_rules = undef ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
149
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
150 ## ---------------- launch queries -------------------- :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
151
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
152 ## prepare cmd
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
153 foreach my $mz (@{ $masses }) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
154 ## computes mass
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
155 my $ohr_mode = lib::hr->new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
156 my ( $exact_mass ) = $ohr_mode->manage_mode( \$mode, \$charge, \$CONF->{'electron'}, \$CONF->{'proton'}, \$mz ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
157 print "Current MZ send to HR\n" if $verbose == 3 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
158 print Dumper $exact_mass if $verbose == 3 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
159 ## build exe line
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
160 my $ohr_exe = lib::hr->new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
161 my $hr_cmd = $ohr_exe->config_hr_exe( \$CONF->{'HR2_EXE'}, \$tolerance, $exact_mass, \$has_golden_rules, \$atomsCurrentConf ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
162 print "$hr_cmd\n" if $verbose == 3 ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
163 push(@{$hr_cmds}, $$hr_cmd) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
164 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
165
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
166 ## MultiThreading execution of Hr :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
167 my $threads = lib::hr->new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
168 my $hr_object = lib::hr->new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
169 if ( $hr_object->can('hr_exe') ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
170 my $method = $hr_object->can('hr_exe') ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
171 $results = $threads->threading_hr_exe( $method, $hr_cmds) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
172
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
173 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
174
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
175 ## MultiThreading parsing of Hr outputs :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
176 my $hrres_object = lib::hr->new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
177 if ( $hrres_object->can('hr_out_parser') ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
178 my $method = $hr_object->can('hr_out_parser') ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
179 if ( defined $results ) { $parsed_results = $threads->threading_hr_exe( $method, $results ) ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
180 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
181
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
182 ## -------------- Produce HTML/CSV output ------------------ :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
183 my $search_condition = 'Mode used: '.$mode.' / Charge: +'.$charge.' / Mass tolerance: '.$$set_tol.' / Composition: '.$atomsCurrentConf ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
184 ## Uses N mz and theirs entries per page (see config file).
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
185 # how many pages you need with your input mz list?
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
186 my $nb_pages_for_html_out = ceil( scalar(@{$masses} ) / $CONF->{HTML_ENTRIES_PER_PAGE} ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
187
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
188 if ( ( defined $output_html ) and ( defined $parsed_results ) ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
189 my $oHtml = lib::hr::new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
190 my ($tbody_object) = $oHtml->set_html_tbody_object( $nb_pages_for_html_out, $CONF->{HTML_ENTRIES_PER_PAGE} ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
191 ($tbody_object) = $oHtml->add_mz_to_tbody_object($tbody_object, $CONF->{HTML_ENTRIES_PER_PAGE}, $masses, $ids, $parsed_results ) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
192 ($tbody_object) = $oHtml->add_entries_to_tbody_object($tbody_object, $parsed_results) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
193 my $html_file = $binPath.'/'.$CONF->{'HTML_TEMPLATE'} ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
194 my $output = $oHtml->write_html_skel(\$output_html, $tbody_object, $nb_pages_for_html_out, $search_condition, $html_file, $CONF->{'JS_GALAXY_PATH'}, $CONF->{'CSS_GALAXY_PATH'}) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
195
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
196 } ## END IF
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
197 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
198 croak "Can't create a HTML output for HMDB : no result found or your output file is not defined\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
199 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
200
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
201 if ( ( defined $output_csv ) and ( defined $parsed_results ) ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
202 # produce a csv based on METLIN format
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
203 my $ocsv = lib::hr::new() ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
204 if (defined $input_file) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
205 my $lm_matrix = undef ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
206 if ( ( defined $line_header ) and ( $line_header == 1 ) ) { $lm_matrix = $ocsv->set_hr_matrix_object('hr2', $masses, $parsed_results ) ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
207 elsif ( ( defined $line_header ) and ( $line_header == 0 ) ) { $lm_matrix = $ocsv->set_hr_matrix_object(undef, $masses, $parsed_results ) ; }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
208 $lm_matrix = $ocsv->add_hr_matrix_to_input_matrix($complete_rows, $lm_matrix) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
209 $ocsv->write_csv_skel(\$output_csv, $lm_matrix) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
210 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
211 elsif (defined $mass) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
212 $ocsv->write_csv_one_mass($masses, $ids, $parsed_results, $output_csv) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
213 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
214 } ## END IF
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
215 else {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
216 # croak "Can't create a tabular output for HR2 : no result found or your output file is not defined\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
217 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
218
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
219
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
220
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
221 ### VERBOSE OUTPUTs
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
222 if ( $verbose == 3 ) {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
223 print "-- Conf file contains :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
224 print Dumper $CONF ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
225 print "-- Atoms input list :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
226 print Dumper $atomes_basic ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
227 print "-- Suppl. atoms input list :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
228 print Dumper $atomes ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
229 print "-- HR envt ready :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
230 print Dumper $hr_check ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
231 print "-- Atoms and ranges :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
232 print Dumper $atomsCurrentConf ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
233 print "-- Tolerance :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
234 print Dumper $set_tol ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
235 print "-- Complete input file :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
236 print Dumper $complete_rows ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
237 print "-- Inputs initiales masses :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
238 print Dumper $masses ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
239 print "-- Inputs initiales ids :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
240 print Dumper $ids ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
241 print "-- Hr_Cmds :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
242 print Dumper $hr_cmds ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
243 print "-- Hr_Results :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
244 # print Dumper $results ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
245 print "-- Hr_parsed Results :\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
246 print Dumper $parsed_results ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
247
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
248 my $nb_results = scalar (@{$results}) ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
249 print "-- Hr_Results return : $nb_results\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
250 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
251
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
252 my $time_end = time ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
253 my $seconds = $time_end-$time_start ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
254 print "\n------ Time used in threaded mode by 6 : $seconds seconds --------\n\n" ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
255
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
256
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
257
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
258
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
259
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
260
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
261 #====================================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
262 # Help subroutine called with -h option
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
263 # number of arguments : 0
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
264 # Argument(s) :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
265 # Return : 1
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
266 #====================================================================================
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
267 sub help {
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
268 print STDERR "
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
269 hr2_manager.pl
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
270
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
271 # hr2_manager is a script to elucide chemical formula by their accurate masses. The HiRes program is integrate in this package
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
272 # Input : a accurate mass or a file of masses
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
273 # Author : Franck Giacomoni and Marion Landi
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
274 # Email : fgiacomoni\@clermont.inra.fr or mlandi\@clermont.inra.fr
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
275 # Version : 1.1
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
276 # Created : 01/12/2011
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
277 # Last Update : 09032014
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
278 USAGE :
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
279 hr2_manager.pl -h or
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
280 hr2_manager.pl -input [cvs file of masses] -colId [int] -colmass [int] -nbHeader [int] -tolerance [float] -mode [positive, neutral or negative] -charge [int] -regleOr [yes or no] -atome [P, S, F, Cl, K, B, A, 1 ] -output1 [csv file] -outputView [html file]
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
281 hr2_manager.pl -masse [double] -tolerance [float] -mode [positive, neutral or negative] -charge [int] -regleOr [yes or no] -atome [P, S, F, Cl, K, B, A, 1 ] -output1 [csv file] -outputView [html file]
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
282 " ;
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
283 exit(1);
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
284 }
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
285
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
286 ## END of script - F Giacomoni
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
287
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
288 __END__
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
289
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
290 =head1 NAME
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
291
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
292 hr2_manager.pl -- script for launch / manage hr2 binary
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
293
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
294 =head1 USAGE
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
295
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
296 hr2_manager.pl -h or
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
297 hr2_manager.pl -input [cvs file of masses] -colId [int] -colmass [int] -nbHeader [int] -tolerance [float] -mode [positive, neutral or negative] -charge [int] -regleOr [yes or no] -atome [P, S, F, Cl, K, B, A, 1 ] -output1 [csv file] -outputView [html file]
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
298 hr2_manager.pl -masse [double] -tolerance [float] -mode [positive, neutral or negative] -charge [int] -regleOr [yes or no] -atome [P, S, F, Cl, K, B, A, 1 ] -output1 [csv file] -outputView [html file]
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
299
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
300 =head1 SYNOPSIS
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
301
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
302 This script manages hr2 binary which elucids raw formula with exact masses.
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
303
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
304 =head1 DESCRIPTION
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
305
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
306 This main program is a module to elucidate chemical formula with HiRes program. Source is available on Fiehn lab web.
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
307
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
308 =over 4
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
309
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
310 =item B<function01>
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
311
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
312 =item B<function02>
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
313
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
314 =back
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
315
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
316 =head1 AUTHOR
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
317
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
318 Franck Giacomoni E<lt>franck.giacomoni@clermont.inra.frE<gt>
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
319 Marion Landi E<lt>marion.landi@clermont.inra.frE<gt>
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
320
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
321 =head1 LICENSE
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
322
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
323 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
324
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
325 =head1 VERSION
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
326
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
327 version 1 : 18/07/2012
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
328
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
329 version 2 : 02/10/2013
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
330
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
331 version 3 : 20/02/2014
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
332
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
333 version 4 : 01/03/2019
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
334
86296c048e46 Init repository for [hr2]
fgiacomoni
parents:
diff changeset
335 =cut