annotate wsdl_lipidmaps.pl @ 3:f4e6b77c46e3 draft default tip

Master branch Updating - - Fxx
author fgiacomoni
date Wed, 03 Oct 2018 05:47:14 -0400
parents 1276908e8fc4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
1 #! perl
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
2
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
3 use strict ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
4 no strict "refs" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
5 use warnings ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
6 use Carp qw (cluck croak carp confess) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
7 use Exporter ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
8 use diagnostics ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
9
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
10 use Data::Dumper ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
11 use POSIX ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
12 use XML::Twig;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
13 use Getopt::Long ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
14 use Time::HiRes;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
15
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
16
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
17 ## Permet de localisez le repertoire du script perl d'origine
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
18 use FindBin;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
19 ## permet de definir la localisation des .pm et .conf
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
20 use lib $FindBin::Bin ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
21 #my $libPath = $FindBin::Bin."/lib";
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
22 my $binPath = $FindBin::Bin ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
23
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
24 ## dedicated lib
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
25
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
26 use lib::lipidmaps ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
27 use lib::parser ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
28 use lib::writer ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
29 # more inra lib
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
30 use lib::conf qw( :ALL ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
31 use lib::csv qw( :ALL ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
32 use lib::operations qw( :ALL ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
33
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
34 ## Initialized values
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
35 #
2
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
36 #my $version = '1.2';
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
37 my $version = '1.2.1'; # add a output to summaries results.
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
38
0
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
39 my ( $help, $input_file, $line_header, $col_mass, $col_rt, $decimal, $round_type, $delta, $mode ) = ( undef, undef, undef, undef, undef, undef, undef, undef, undef ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
40 my ( $list_oxidation, $list_neutral_loss ) = ( undef, undef ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
41 my ( $col_classif_id, $selected_cat, $selected_cl, $selected_subcl ) = ( undef, undef, undef, undef ) ;
2
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
42 my ( $output_csv_file, $output_html_file, $output_summary_file ) = ( undef, undef, undef ) ;
0
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
43
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
44 ## Verbose levels (1 OR 3)
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
45 my $verbose = 3 ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
46
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
47
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
48 &GetOptions ( "help|h" => \$help, # HELP
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
49 "input|i:s" => \$input_file, # path for input file (CSV format) -- Mandatory
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
50 "lineheader:i" => \$line_header, ## header presence in tabular file
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
51 "colmass:i" => \$col_mass, # Input file Column containing Masses for query -- Mandatory
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
52 # "colrt:i" => \$col_rt, # Input file Column containing Retention time
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
53 "decimal:i" => \$decimal , # Significante decimal on mass -- Mandatory
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
54 "listoxidation:s" => \$list_oxidation, ## option : liste des atomes a gerer sur les masses experimentales
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
55 "listneutralloss:s" => \$list_neutral_loss, ## option : liste des atomes a gerer sur les masses experimentales
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
56 "round:s" => \$round_type, # Type of truncation -- Mandatory
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
57 "delta:f" => \$delta, # delta of mass -- Mandatory
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
58 "cat:s" => \$selected_cat, # Number corresponding to the main category in LIPIDMAPS -- Optional
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
59 "class:s" => \$selected_cl, # Number corresponding to the main classe in LIPIDMAPS -- Optional
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
60 "subclass:s" => \$selected_subcl, # Number corresponding to the sub class in LIPIDMAPS -- Optional
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
61 "output:s" => \$output_csv_file, # File+Path for the results (CVS) -- Mandatory
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
62 "view:s" => \$output_html_file, # File+Path for the view results (HTML) -- Mandatory
2
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
63 "summary:s" => \$output_summary_file,# File+Path for the result summary (CSV) -- OPTIONNAL (test metabo.tsv with Galaxy)
0
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
64 "colclassif:i" => \$col_classif_id, # Input file Column containing LM classes ID for query -- Optional
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
65 "mode:s" => \$mode, # mode of the initial data
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
66 ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
67
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
68 #=============================================================================
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
69 # EXCEPTIONS
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
70 #=============================================================================
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
71 $help and &help ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
72
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
73 ## --------------- Global parameters ---------------- :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
74 my $nb_pages_for_html_out = 1 ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
75
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
76 ## Conf file
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
77 my ( $CONF, %RULES, %RECIPES, %TRANSFO ) = ( undef, (), (), () ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
78 foreach my $conf ( <$binPath/*.conf> ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
79 my $oConf = lib::conf::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
80 $CONF = $oConf->as_conf($conf) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
81 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
82
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
83 ## -------------- HTML template file ------------------------ :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
84 foreach my $html_template ( <$binPath/*.tmpl> ) { $CONF->{'HTML_TEMPLATE'} = $html_template ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
85
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
86 ## work with it :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
87 ## get RULES lists :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
88 foreach (keys (%$CONF)) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
89 if( $_ =~/^RULE/ ) { $RULES{$_} = $CONF->{$_} ; } ## rules for clustering
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
90 elsif( $_ =~/^RECIPE/ ) { $RECIPES{$_} = $CONF->{$_} ; } ## fields retrieved with each rule
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
91 elsif( $_ =~/^ANNOT/ ) { $TRANSFO{$_} = $CONF->{$_} ; } ## Transformation annotation in output files
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
92 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
93
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
94 ## Init var
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
95 my ( $init_csv_rows, $init_mzs, $init_rts, $classif_ids, $round_init_mzs ) = ( undef, undef, undef, undef, undef ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
96 my ( @ox_or_loss_names, @ox_or_loss_values, @transfo_init_mzs, @transfo_annotations, @transfo_init_mz_queries, @transfo_init_mz_results, @entries_results, @clusters_results, @entries_total_nb ) = ( (), (), (), (), (), (), (), (), () ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
97 my ( $ox_names, $ox_values, $loss_names, $loss_values ) = ( [], [], [], [] ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
98 my ( $is_header, $tbody_object) = (undef, undef) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
99
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
100
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
101 print "-----------**********START of MAIN LIPIDMAPS -- version $version *********-------------\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
102
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
103 #### --------------------------------- 01 :: Prepare all and Parsing steps on inputs -------------------------------------
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
104
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
105 ## Open CVS FILE / Extract and transform Masses
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
106 if ( ( defined $input_file ) and ( -e $input_file ) ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
107 print "\n[INFO] Open input file and get values...\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
108 ## parse all csv for later : output csv build
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
109 my $ocsv_input = lib::csv->new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
110 my $csv = $ocsv_input->get_csv_object( "\t" ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
111 $init_csv_rows = $ocsv_input->parse_csv_object($csv, \$input_file) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
112
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
113
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
114 if ( ( defined $line_header ) and ( $line_header > 0 ) ) { $is_header = 'yes' ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
115
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
116 ## parse masses
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
117 if ( defined $col_mass ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
118 print "[INFO] Get masses from input file $input_file ...\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
119 # print "[INFO] Get RT from input file $input_file ...\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
120 my $ocsv = lib::csv->new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
121 my $csv = $ocsv->get_csv_object( "\t" ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
122 $init_mzs = $ocsv->get_value_from_csv_multi_header( $csv, $input_file, $col_mass, $is_header, $line_header ) ; ## retrieve mz values on csv
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
123 # $init_rts = $ocsv->get_value_from_csv_multi_header( $csv, $input_file, $col_rt, $is_header, $line_header ) ; ## retrieve rt values on csv
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
124 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
125
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
126 ## Adjust the mz to the instrument mode (POS/NEG)
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
127 if ( ( defined $mode ) and ( ($mode eq 'POS') or ($mode eq 'NEG') ) ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
128 print "\t [INFO] Apply mass mode transforming (POS to NEU or NEG to NEU) ...\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
129 my @mode_init_mzs = () ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
130 my $omode = lib::operations::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
131 foreach my $mz (@$init_mzs) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
132 push (@mode_init_mzs, ${$omode->manage_mode(\$mode, \1, \0.0005486, \1.007825, \$mz)} ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
133 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
134
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
135 if ( (scalar @$init_mzs) == (scalar @mode_init_mzs) ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
136 $init_mzs = \@mode_init_mzs ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
137 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
138 else {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
139 carp "[ERROR] The mode managing process failed and init mzs have been corrompted\n"
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
140 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
141 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
142 else {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
143 print "\t [INFO] Apply no mass mode transforming\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
144 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
145
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
146 ## round masses
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
147 if ( ( defined $round_type ) and ( defined $decimal ) ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
148 print "\t [INFO] Apply mass rounding ...\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
149 my $oround = lib::operations::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
150 if ( $round_type eq 'truncation' ) { $round_init_mzs = $oround->truncate_nums( $init_mzs, $decimal ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
151 elsif ( $round_type eq 'round' ) { $round_init_mzs = $oround->round_nums( $init_mzs, $decimal ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
152 else { croak "The selected option for data transformation is unknown !\n" ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
153 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
154 ## parse classif ids -- optionnal
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
155 if ( defined $col_classif_id ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
156 print "\t [INFO] Get LM classification IDS from input file $input_file ...\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
157 my $ocsv = lib::csv::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
158 my $csv = $ocsv->get_csv_object( "\t" ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
159 $classif_ids = $ocsv->get_value_from_csv( $csv, $input_file, $col_classif_id, $is_header, $line_header ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
160 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
161
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
162
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
163
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
164 ## Uses N mz and theirs entries per page (see config file).
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
165 # how many pages you need with your input mz list?
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
166 # $nb_pages_for_html_out = ceil( scalar(@{$init_mzs} ) / $CONF->{HTML_ENTRIES_PER_PAGE} ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
167 # print "[INFO] Your analysis will generate $nb_pages_for_html_out pages of results...\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
168
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
169 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
170 else {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
171 print "[ERROR] Can't find any input file $input_file\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
172 croak "Can't find any input file $input_file\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
173 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
174
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
175 #### ------------------- 02 :: optionnal work on masses with neutral loss and/or oxydation == modif : -------------------
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
176
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
177 # get and merge ox and neutral loss envt :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
178 my $oparser = lib::parser::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
179 if ( ( defined $list_oxidation ) and ( defined $CONF ) ) { ( $ox_names, $ox_values ) = $oparser->get_oxidation_ref( $CONF, $list_oxidation ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
180 if ( @{$ox_values} ) { push( @ox_or_loss_values, @{$ox_values} ) ; push( @ox_or_loss_names, @{$ox_names} ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
181 if ( ( defined $list_neutral_loss ) and ( defined $CONF ) ) { ( $loss_names, $loss_values ) = $oparser->get_neutral_loss_ref( $CONF, $list_neutral_loss ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
182 if ( @{$loss_values} ) { push( @ox_or_loss_values, @{$loss_values} ) ; push( @ox_or_loss_names, @{$loss_names} ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
183
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
184 # prepare a list of masses indpt of modif (ox/neutral loss) presence.
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
185 my $init_mz_index = 0 ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
186 my $i = 0 ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
187
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
188 foreach my $init_mz (@{$round_init_mzs}) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
189
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
190 my @transfo_values_list = () ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
191 my @transfo_name_list = () ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
192 my $init_annot = 'Init_MZ' ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
193
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
194 push ( @transfo_values_list, \$init_mz ) ; ## the submitted init mass
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
195 ## work on values
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
196 if ( @ox_or_loss_values ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
197 my $oround = lib::operations::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
198 my $round_transfo_mzs = $oround->round_nums( \@ox_or_loss_values, $decimal ) ; ## We choose to around the number.
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
199 foreach my $transfo_mz ( @{$round_transfo_mzs} ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
200 my $osub = lib::operations::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
201 my $transfo_init_mz = $osub->subtract_num( $init_mz, $transfo_mz ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
202 push ( @transfo_values_list, $transfo_init_mz ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
203 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
204 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
205
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
206 ## work on annotation for output
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
207 push ( @transfo_name_list, \$init_annot) ; ## init annot
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
208 if ( @ox_or_loss_names ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
209 foreach my $ox_or_loss_name (@ox_or_loss_names) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
210 if ( $TRANSFO{'ANNOT_'.$ox_or_loss_name} ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
211 my $transfo = $TRANSFO{'ANNOT_'.$ox_or_loss_name} ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
212 push ( @transfo_name_list, \$transfo ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
213 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
214 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
215
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
216 ## push final arrays
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
217 push ( @transfo_init_mzs, \@transfo_values_list ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
218 push ( @transfo_annotations, \@transfo_name_list ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
219
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
220 ## foreach transfo mass (round and/or modif)
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
221
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
222 my ( @queries, @query_results, @query_result_entries, @query_result_entry_nbs, @query_result_clusters ) = ( (), (), (), (), () ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
223
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
224 foreach my $transfo_mz ( @{$transfo_init_mzs[$init_mz_index]} ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
225 print "[INFO] Prepare the $i.th query with the mz: $$transfo_mz... \n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
226 ## LM recommandation : If you write a script to automate calls to LMSD,
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
227 # please be kind and do not hit our server more often than once per 20 seconds.
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
228 # We may have to kill scripts that hit our server more frequently.
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
229 Time::HiRes::sleep(0.1); #.1 seconds
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
230 my ( $cat, $cl, $subcl ) = ( undef, undef, undef ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
231 # if ( $i >= ( scalar( @transfos_values )-1 ) ) { $i = 0 ; } ## manage the modif for each masses.
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
232
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
233 ## get the classif level :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
234 if ( defined $classif_ids ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
235
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
236 if ( $classif_ids->[$i] ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
237 my $olevel = lib::parser::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
238 $cat = $olevel->set_category( $classif_ids->[$i] ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
239 $cl = $olevel->set_class( $classif_ids->[$i] ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
240 $subcl = $olevel->set_subclass( $classif_ids->[$i] ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
241 # ( $cat, $cl, $subcl ) = ( $$cat, $$cl, $$subcl ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
242 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
243 else { croak "This information is not available in your parsing ids\n" ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
244 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
245 else {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
246 if ( ( defined $selected_subcl) or ( defined $selected_cl ) or ( defined $selected_cat ) ) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
247 if ( ( $selected_cat !~ /^NA/ ) ) { ( $cat ) = ( \$selected_cat ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
248 if ( ( $selected_cl !~ /^NA(.*)/ ) ) { ( $cl ) = ( \$selected_cl ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
249 if ( ( $selected_subcl !~ /^NA(.*)/ ) ) { ( $subcl ) = ( \$selected_subcl ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
250 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
251 else { croak "No selected category or classification ids list\n" ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
252 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
253
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
254 ## buid and get http query :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
255 my $oquery = lib::lipidmaps::new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
256 my $ref_http_query = $oquery->build_lm_mass_query( \$CONF->{'SEARCH_URL'}, \$delta, $cat, $cl, $subcl ) ; ## build the query for LM WS, return a list of http, get method
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
257 print "\t[INFO] Exec $$ref_http_query \n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
258
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
259 ## set entries clusters
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
260 my ( $http_result_mz, $http_query_mz ) = $oquery->get_lm_mass_query($ref_http_query, $transfo_mz) ; ## execute the query, return a list of non-splited lm_entries.
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
261 my ( $mz_entries_results, $mz_entries_nb, $mz_clusters_results ) = ( undef, undef, undef ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
262 if ( (defined $http_result_mz) and ( $$http_result_mz ne '' ) ) { # avoid empty LM results
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
263 ( $mz_entries_results, $mz_entries_nb ) = $oquery->get_lm_entry_object($http_result_mz, $transfo_mz) ; ## get all features of each entry and return a list of features keept in a hash
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
264 $mz_clusters_results = $oquery->get_cluster_object($mz_entries_results, \%RULES, \%RECIPES) ; ## clustering all entries and return a list of clusters keept in a hash
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
265 print "\t[INFO] The query return $$mz_entries_nb entries\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
266 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
267 else { # manage empty LM results
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
268 ( $mz_entries_results, $mz_entries_nb, $mz_clusters_results ) = ( [], \0, [] ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
269 print "\t[INFO] The query return none entry with LM\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
270 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
271
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
272 push( @queries, $http_query_mz ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
273 push( @query_results, $http_result_mz ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
274 push( @query_result_entries, $mz_entries_results ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
275 push( @query_result_entry_nbs, $mz_entries_nb ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
276 push( @query_result_clusters, $mz_clusters_results ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
277
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
278 } ## end foreach transfo_mz
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
279
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
280 $i++ ; # implem the mz rank
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
281
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
282 push( @transfo_init_mz_queries, \@queries ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
283 push( @transfo_init_mz_results, \@query_results ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
284 push( @entries_results, \@query_result_entries ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
285 push( @entries_total_nb, \@query_result_entry_nbs ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
286 push( @clusters_results, \@query_result_clusters ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
287
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
288 $init_mz_index++ ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
289 } ## end foreach init_mz
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
290
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
291
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
292 #### -------------------------------- 05 :: Writes LM results --------------------------------------------
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
293
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
294 # prepare data and write html output :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
295 if ( defined $output_html_file) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
296 ## Adjust html output with only mz with records
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
297 my ($nb_pages, $total_entries) = (0, 0) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
298 foreach (@entries_total_nb) {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
299 foreach my $nb ( @{$_} ) { $total_entries += $$nb ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
300 if ($total_entries > 0) { $nb_pages++ ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
301 $total_entries = 0 ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
302 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
303
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
304 $nb_pages_for_html_out = ceil( $nb_pages / $CONF->{HTML_ENTRIES_PER_PAGE} ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
305 print "[INFO] write HTML output file containing $nb_pages_for_html_out pages\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
306
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
307 my $ohtml = lib::writer->new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
308 $tbody_object = $ohtml->set_html_tbody_object( $nb_pages_for_html_out ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
309 $tbody_object = $ohtml->add_mz_to_tbody_object( $tbody_object, $CONF->{HTML_ENTRIES_PER_PAGE}, $init_mzs, \@entries_total_nb) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
310 $tbody_object = $ohtml->add_transformation_to_tbody_object( \@transfo_init_mzs, \@transfo_annotations, $tbody_object ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
311 $tbody_object = $ohtml->add_cluster_to_tbody_object( \@transfo_init_mzs, \@clusters_results, $tbody_object ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
312 $tbody_object = $ohtml->add_entry_to_tbody_object( \@transfo_init_mzs, \@clusters_results, \@entries_results, $tbody_object ) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
313
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
314 $tbody_object = $ohtml->sort_tbody_object($tbody_object) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
315
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
316 my $output_html = $ohtml->write_html_skel(\$output_html_file, $tbody_object, $nb_pages_for_html_out, $CONF->{'HTML_TEMPLATE'}, $CONF->{'JS_GALAXY_PATH'}, $CONF->{'CSS_GALAXY_PATH'}) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
317 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
318
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
319
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
320 #write csv ouput : add 'lipidmaps' column to input file
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
321 my $lm_matrix = undef ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
322 my $ocsv = lib::writer->new() ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
323 if ( defined $is_header ) { $lm_matrix = $ocsv->set_lm_matrix_object('LIPIDMAPS(score::name::mz::formula::adduct::id)', $init_mzs, \@transfo_annotations, \@clusters_results ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
324 else { $lm_matrix = $ocsv->set_lm_matrix_object( undef, $init_mzs, \@transfo_annotations, \@clusters_results ) ; }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
325
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
326
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
327 $lm_matrix = $ocsv->add_lm_matrix_to_input_matrix($init_csv_rows, $lm_matrix) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
328 $ocsv->write_csv_skel(\$output_csv_file, $lm_matrix) ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
329 print "[INFO] write CSV output file\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
330
2
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
331 my $lm_sum_matrix = undef ;
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
332 if (defined $output_summary_file) {
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
333 $lm_sum_matrix = $ocsv->convert_tbody_to_globalmatrix(undef, $tbody_object) ;
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
334 $ocsv->write_csv_skel(\$output_summary_file, $lm_sum_matrix) ;
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
335 print "[INFO] write CSV SUMMARY output file\n" if ($verbose == 3);
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
336 }
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
337
0
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
338 print "-----------**********END of MAIN LIPIDMAPS -- version $version *********-------------\n" if ($verbose == 3);
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
339
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
340 #print "-----------**********RETURNS*********-------------\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
341 #print "\n----- Init Input Data in CSV -----\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
342 #print Dumper $init_csv_rows ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
343 #print "\n---- Init masses parsed ...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
344 #print Dumper $init_mzs ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
345 #print "\n---- Init rts parsed ...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
346 #print Dumper $init_rts ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
347 #print "\n---- Init masses arounded ...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
348 #print Dumper $round_init_mzs ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
349 #print "\n---- Ox ...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
350 #print Dumper $ox_names ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
351 #print Dumper $ox_values ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
352 #print "\n---- Neutral loss ...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
353 #print Dumper $loss_names ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
354 #print Dumper $loss_values ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
355 #print "\n---- Applied transformations ('\@ox_or_loss_values') ...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
356 #print Dumper @ox_or_loss_values ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
357 #print "\n---- Masses modif ('\@transfo_init_mzs') ...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
358 #print Dumper @transfo_init_mzs ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
359 #print "\n---- Transfo annotation ('\@transfo_annotations') ...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
360 #print Dumper @transfo_annotations ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
361 #print "\n---- Queries ('\@transfo_init_mz_queries')...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
362 #print Dumper @transfo_init_mz_queries ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
363 #print "\n---- WS Results ('@transfo_init_mz_results')...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
364 #print Dumper @transfo_init_mz_results ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
365 #print "\n---- Entries results ('\@entries_results')...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
366 #print Dumper @entries_results ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
367 #print "\n---- Entries results numbers ('\@entries_total_nb')...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
368 #print Dumper @entries_total_nb ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
369 #print "\n---- Clusters results ('\@clusters_results')...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
370 #print Dumper @clusters_results ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
371 #print "\n---- Data model filed...\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
372 #print "...with csv->\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
373 #print Dumper $lm_matrix ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
374 #print "...with html->\n" ;
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
375 #print Dumper $tbody_object ;
2
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
376 #print "...with SUMMARY csv->\n" ;
1276908e8fc4 Master branch Updating - - Fxx
fgiacomoni
parents: 0
diff changeset
377 #print Dumper $lm_sum_matrix ;
0
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
378
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
379
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
380 #====================================================================================
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
381 # Help subroutine called with -h option
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
382 # number of arguments : 0
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
383 # Argument(s) :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
384 # Return : 1
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
385 #====================================================================================
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
386 sub help {
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
387 print STDERR "
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
388
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
389 # wsdl_lipidmaps
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
390 # Input :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
391 # Author : Franck GIACOMONI and Marion LANDI
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
392 # Email : fgiacomoni\@clermont.inra.fr
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
393 # Version : $version
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
394 # Created : 16/07/2012
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
395 # Updated: 09/06/2016 - REST implem
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
396 USAGE :
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
397 wsdl_lipidmaps.pl -help
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
398 wsdl_lipidmaps.pl
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
399 -input \$file_input -colmass \$col_mass -colrt \$col_rt -decimal \$decimal -round \$round_type -delta \$tolerance
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
400 -output \$output_result -view \$output_view
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
401 -cat -class -subclass OR -colclassif
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
402 -listneutralloss \$neutral_loss -listoxidation \$oxidation [optionnal]
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
403 ";
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
404 }
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
405
e8bd49794291 Init repository with last lipidmaps_textsearch master version
fgiacomoni
parents:
diff changeset
406