annotate lib/hmdb.pm @ 23:2d8a310e86ce draft

Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
author fgiacomoni
date Thu, 19 May 2022 13:43:09 +0000
parents 453fbe98925a
children d8e2ede293a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1 package lib::hmdb ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
2
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
3 use strict;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
4 use warnings ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
5 use Exporter ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
6 use Carp ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
7
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
8 use LWP::Simple;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
9 use LWP::UserAgent;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
10 use WWW::Mechanize qw();
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
11 use URI::URL;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
12 use SOAP::Lite;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
13 use Encode qw(encode_utf8);
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
14 use HTML::Template ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
15 use XML::Twig ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
16 use Text::CSV ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
17
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
18 use Data::Dumper ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
19
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
20 use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS);
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
21
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
22 our $VERSION = "1.0";
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
23 our @ISA = qw(Exporter);
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
24 our @EXPORT = qw( parseHmdb5CSVResults getMatchesFromHmdb5WithUA map_suppl_data_on_hmdb_results get_unik_ids_from_results get_hmdb_metabocard_from_id extract_sub_mz_lists test_matches_from_hmdb_ua prepare_multi_masses_query get_matches_from_hmdb_ua parse_hmdb_csv_results set_html_tbody_object add_mz_to_tbody_object add_entries_to_tbody_object write_html_skel set_lm_matrix_object set_hmdb_matrix_object_with_ids add_lm_matrix_to_input_matrix write_csv_skel write_csv_one_mass );
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
25 our %EXPORT_TAGS = ( ALL => [qw( parseHmdb5CSVResults getMatchesFromHmdb5WithUA map_suppl_data_on_hmdb_results get_unik_ids_from_results get_hmdb_metabocard_from_id extract_sub_mz_lists test_matches_from_hmdb_ua prepare_multi_masses_query get_matches_from_hmdb_ua parse_hmdb_csv_results set_html_tbody_object add_mz_to_tbody_object add_entries_to_tbody_object write_html_skel set_lm_matrix_object set_hmdb_matrix_object_with_ids add_lm_matrix_to_input_matrix write_csv_skel write_csv_one_mass )] );
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
26
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
27 =head1 NAME
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
28
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
29 My::Module - An example module
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
30
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
31 =head1 SYNOPSIS
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
32
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
33 use My::Module;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
34 my $object = My::Module->new();
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
35 print $object->as_string;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
36
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
37 =head1 DESCRIPTION
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
38
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
39 This module does not really exist, it
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
40 was made for the sole purpose of
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
41 demonstrating how POD works.
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
42
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
43 =head1 METHODS
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
44
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
45 Methods are :
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
46
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
47 =head2 METHOD new
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
48
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
49 ## Description : new
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
50 ## Input : $self
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
51 ## Ouput : bless $self ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
52 ## Usage : new() ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
53
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
54 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
55
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
56 sub new {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
57 ## Variables
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
58 my $self={};
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
59 bless($self) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
60 return $self ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
61 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
62 ### END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
63
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
64
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
65 =head2 METHOD extract_sub_mz_lists
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
66
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
67 ## Description : extract a couples of sublist from a long mz list (more than $HMDB_LIMITS)
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
68 ## Input : $HMDB_LIMITS, $masses
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
69 ## Output : $sublists
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
70 ## Usage : my ( $sublists ) = extract_sub_mz_lists( $HMDB_LIMITS, $masses ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
71
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
72 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
73 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
74 sub extract_sub_mz_lists {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
75 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
76 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
77 my ( $masses, $HMDB_LIMITS ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
78
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
79 my ( @sublists, @sublist ) = ( (), () ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
80 my $nb_mz = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
81 my $nb_total_mzs = scalar(@{$masses}) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
82
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
83 if ($nb_total_mzs == 0) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
84 die "The provided mzs list is empty" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
85 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
86
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
87 for ( my $current_pos = 0 ; $current_pos < $nb_total_mzs ; $current_pos++ ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
88
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
89 if ( $nb_mz < $HMDB_LIMITS ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
90 if ( $masses->[$current_pos] ) { push (@sublist, $masses->[$current_pos]) ; $nb_mz++ ; } # build sub list
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
91 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
92 elsif ( $nb_mz == $HMDB_LIMITS ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
93 my @tmp = @sublist ; push (@sublists, \@tmp) ; @sublist = () ; $nb_mz = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
94 $current_pos-- ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
95 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
96 if ($current_pos == $nb_total_mzs-1) { my @tmp = @sublist ; push (@sublists, \@tmp) ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
97 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
98 return(\@sublists) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
99 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
100 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
101
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
102 =head2 METHOD prepare_multi_masses_query
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
103
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
104 ## Description : Generate the adapted format of the mz list for HMDB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
105 ## Input : $masses
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
106 ## Output : $hmdb_masses
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
107 ## Usage : my ( $hmdb_masses ) = prepare_multi_masses_query( $masses ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
108
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
109 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
110 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
111 sub prepare_multi_masses_query {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
112 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
113 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
114 my ( $masses ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
115
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
116 my $hmdb_masses = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
117 my $sep = '%0D%0A' ; ## retour chariot encode
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
118 my ($nb_masses, $i) = (0, 0) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
119
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
120 if ( defined $masses ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
121 my @masses = @{$masses} ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
122 my $nb_masses = scalar ( @masses ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
123 if ( $nb_masses == 0 ) { croak "The input method parameter mass list is empty" ; }
6
7ed37640fe2a planemo upload commit 4c72059b94b27eda2c0ee89bfc5f9bf4e3425dc5
fgiacomoni
parents: 4
diff changeset
124 elsif ( $nb_masses >= 700 ) { croak "Your mass list is too long : HMDB allows maximum 700 query masses per request \n" ; } ## Del it --- temporary patch
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
125
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
126 foreach my $mass (@masses) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
127
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
128 if ($i < $nb_masses) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
129 $hmdb_masses .= $mass.$sep ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
130 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
131 elsif ( $i == $nb_masses ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
132 $hmdb_masses .= $mass ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
133 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
134 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
135 last ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
136 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
137 $i ++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
138 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
139 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
140 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
141 croak "No mass list found \n" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
142 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
143 return($hmdb_masses, $nb_masses) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
144 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
145 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
146
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
147
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
148 =head2 METHOD prepareAdductListFormat
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
149
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
150 ## Description : prepare a adduct list well formatted for https queries
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
151 ## Input : $adductString
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
152 ## Output : $formattedAdductString
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
153 ## Usage : my ( $formattedAdductString ) = prepareAdductListFormat ( $adductString ) ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
154
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
155 =cut
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
156 ## START of SUB
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
157 sub prepareAdductListFormat {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
158 ## Retrieve Values
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
159 my $self = shift ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
160 my ( $adductString ) = @_;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
161 my ( $formattedAdductString, $nbAdducts ) = ( undef, 0 ) ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
162
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
163 ## Formatting is converting [+] in %2B, [-] as - and [,] in converted space as 'M%2BH%202M%2BH' for 'M+H,2M+2H'
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
164 # print "\t$adductString ..." ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
165
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
166 if (defined $adductString) {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
167
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
168 ## counting selected adducts
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
169 $nbAdducts = scalar( my @adducts = ( split (/,/, $adductString) ) ) ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
170
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
171 ## Converting string into http post format
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
172 $adductString =~ s/\+/%2B/g ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
173 $adductString =~ s/,/%20/g ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
174 $formattedAdductString = $adductString ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
175 }
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
176 else {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
177 warn "\t[WARN]the adduct type is not defined...It will set to 'Unknown'\n" ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
178 }
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
179
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
180 # print "->$formattedAdductString\n" ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
181
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
182 return ($formattedAdductString, $nbAdducts) ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
183 }
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
184 ### END of SUB
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
185
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
186 =head2 METHOD test_matches_from_hmdb_ua DEPRECATED
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
187
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
188 ## Description : [DEPRECATED]test a single query with tests parameters on hmdb - get the status of the complete server infra.
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
189 ## Input : none
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
190 ## Output : $status_line
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
191 ## Usage : my ( $status_line ) = test_matches_from_hmdb_ua( ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
192
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
193 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
194 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
195 sub test_matches_from_hmdb_ua {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
196 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
197 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
198
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
199 my @page = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
200
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
201 my $ua = new LWP::UserAgent;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
202 $ua->agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:64.0) Gecko/20100101 Firefox/64.0");
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
203
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
204 my $url = 'http://specdb.wishartlab.com/ms/search.csv';
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
205 my $header = ['Connection' => 'keep-alive', 'Content-Type' => 'application/x-www-form-urlencoded', 'Referer' => 'http://www.hmdb.ca/spectra/ms/search', 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'];
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
206
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
207 my $req = HTTP::Request->new('POST', $url, $header);
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
208 # print Dumper $req ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
209
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
210 ## Query format for HMDB 4.0
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
211 #"utf8=✓&authenticity_token=K1Ys7oyMKmVNm9n8p0jiTxBlh4G4OO0cqKZYnQKDCw0pM6zmm/CiBxv+/cXhuRsVFV98LLeAMJRN5dCyhIWlAA==&query_masses=175.01 238.19 420.16 780.32 956.25 1100.45&ms_search_ion_mode=positive&adduct_type[]=Unknown&tolerance=0.05&tolerance_units=Da&commit=Search"
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
212
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
213 $req->content('utf8=TRUE&mode=positive&query_masses=420.159317&tolerance=0.000001&database=HMDB&commit=Download Results As CSV');
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
214 # print Dumper $req ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
215 my $res = $ua->request($req);
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
216
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
217 print $res->as_string;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
218 my $status_line = $res->status_line ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
219 ($status_line) = ($status_line =~ /(\d+)/);
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
220
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
221 return (\$status_line) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
222 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
223 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
224
22
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
225
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
226 =head2 METHOD checkHmdbUrlEntries
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
227
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
228 ## Description : check a list of HMDB_IDs by testing what is the status of their uri (HTTP 200 or not)
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
229 ## Input : $urlRoot, $entries
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
230 ## Output : $validEntries
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
231 ## Usage : my ( $validEntries ) = checkHmdbUrlEntries ( $entries ) ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
232
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
233 =cut
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
234 ## START of SUB
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
235 sub checkHmdbUrlEntries {
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
236 ## Retrieve Values
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
237 my $self = shift ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
238 my ( $urlRoot, $clusters, $maxQuery ) = @_;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
239 my ( @ValidResults, @validFeature ) = ( (), () ) ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
240
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
241 foreach my $resultsByMass (@{$clusters}) {
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
242 my $currentQuery = 0 ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
243 foreach my $feature (@{$resultsByMass}) {
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
244
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
245 if ($feature->{ENTRY_ENTRY_ID}) {
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
246
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
247 my $url = $urlRoot.$feature->{ENTRY_ENTRY_ID} ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
248 if ( get($url)) {
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
249 $currentQuery ++ ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
250 if ($currentQuery > $maxQuery) {
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
251 last ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
252 }
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
253 else {
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
254 push (@validFeature, $feature) ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
255 # print "Url is valid ($url) - - add to final results\n" ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
256 }
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
257 }
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
258 else {
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
259 # print "Url is NOT valid ($url) - - Deleting to final results\n" ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
260 next ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
261 }
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
262 }
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
263 } # END FOREACH FEATURE
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
264 my @tmp = @validFeature ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
265 push (@ValidResults, \@tmp) ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
266 @validFeature = () ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
267 } # END FOREACH RESULTS
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
268
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
269 return (\@ValidResults) ;
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
270 }
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
271 ### END of SUB
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
272
453fbe98925a " master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
fgiacomoni
parents: 21
diff changeset
273
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
274 =head2 METHOD testMatchesFromHmdbWithUA
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
275
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
276 ## Description : [DEPRECATED] test a single query with tests parameters on hmdb - get the status of the complete server infra.
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
277 ## Input : none
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
278 ## Output : $status_line
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
279 ## Usage : my ( $status_line ) = testMatchesFromHmdbWithUA( ) ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
280
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
281 =cut
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
282 ## START of SUB
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
283 sub testMatchesFromHmdbWithUA {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
284 ## Retrieve Values
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
285 my $self = shift ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
286
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
287 my @page = () ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
288 #based on https://stackoverflow.com/questions/17732916/perl-post-automation-and
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
289
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
290 my $mech = WWW::Mechanize->new(
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
291 # agent => 'wonderbot for W4M 1.01',
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
292 agent => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:93.0) Gecko/20100101 Firefox/93.0' ,
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
293 autocheck => 0,
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
294 );
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
295
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
296 my $statusGetLine = 0 ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
297 my $statusPostLine = 0 ;
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
298 my $csrftoken = undef ;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
299
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
300 #receiving cookies and authentication token (CFRS)
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
301 my $reqInit = $mech->get("http://www.hmdb.ca/spectra/ms/search");
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
302 $statusGetLine = $mech->status() ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
303
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
304 if ($statusGetLine == 200 ) {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
305 die 'no CSRF_REQUEST_TOKEN_VALUE in page found'
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
306 unless ($reqInit->decoded_content =~ /\"csrf-token\"\s+content=\"(.*)\"/) ;
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
307 $csrftoken = $1;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
308 print "\nTOKEN: $csrftoken\n" ;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
309 $mech->add_header("X-CSRFToken", $csrftoken);
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
310 $mech->add_header('Host', 'specdb.wishartlab.com');
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
311 $mech->add_header('Connection', 'keep-alive');
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
312 $mech->add_header('Upgrade-Insecure-Requests', '1');
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
313 $mech->add_header('Content-Type', 'application/x-www-form-urlencoded');
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
314 $mech->add_header('Accept-Language', 'en-US,en;q=0.5');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
315 $mech->add_header('Accept-Encoding', 'gzip, deflate');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
316 # $mech->add_header('Content-Length', "300");
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
317 $mech->add_header('Origin', 'null');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
318 $mech->add_header('DNT', '1');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
319 $mech->add_header('Referer', 'https://hmdb.ca/spectra/ms/search');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
320 # $mech->add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
321 $mech->add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
322
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
323
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
324 }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
325
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
326 ## POST test
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
327 my $top = 1 ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
328 while ($statusPostLine != 200 ) {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
329
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
330 # Fix a limit at 3 tries...
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
331 if ($top < 4) {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
332 print "\tTesting HMDB server connexion ($top time(s) )...\n" ;
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
333 eval {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
334 $mech->post(
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
335 "http://specdb.wishartlab.com/ms/search.csv",
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
336 Content => 'utf8=TRUE&authenticity_token='.$csrftoken.'&mode=positive&adduct_type=M%2BH%202M%2BH&query_masses=125.0089&tolerance=0.001&database=HMDB&commit=Download Results As CSV'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
337 );
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
338 } ;
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
339 # print Dumper $mech ;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
340 $statusPostLine = $mech->status() ;
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
341 print "Status: $statusPostLine" ;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
342 }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
343 else {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
344 last ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
345 }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
346 $top++ ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
347 }## End While
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
348 return (\$statusPostLine) ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
349 }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
350 ## END of SUB
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
351
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
352
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
353 =head2 METHOD testMatchesFromHmdb5WithUA
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
354
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
355 ## Description : test a single query with tests parameters on hmdb - get the status of the complete server infra (API V5.0 compliant).
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
356 ## Input : none
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
357 ## Output : $status_line
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
358 ## Usage : my ( $status_line ) = testMatchesFromHmdb5WithUA( ) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
359
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
360 =cut
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
361 ## START of SUB
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
362 sub testMatchesFromHmdb5WithUA {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
363 ## Retrieve Values
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
364 my $self = shift ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
365
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
366 my $mech = WWW::Mechanize->new(
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
367 agent => 'wonderbot for W4M 3.0',
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
368 autocheck => 1,
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
369 timeout => 2400,
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
370 );
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
371
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
372 my $statusGetLine = 0 ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
373 my $statusPostLine = 0 ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
374
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
375 #receiving cookies and authentication token (CFRS)
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
376 my $reqInit = $mech->get("https://www.hmdb.ca/spectra/ms/search");
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
377 $statusGetLine = $mech->status() ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
378
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
379 if ($statusGetLine == 200 ) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
380 die 'no CSRF_REQUEST_TOKEN_VALUE in page found'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
381 unless ($reqInit->decoded_content =~ /\"csrf-token\"\s+content=\"(.*)\"/) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
382 my $csrftoken = $1;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
383 # print "\nTOKEN: $csrftoken\n" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
384 $mech->add_header("X-CSRFToken", $csrftoken);
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
385 $mech->add_header('Connection', 'keep-alive');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
386 $mech->add_header('Content-Type', 'application/x-www-form-urlencoded');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
387 $mech->add_header('Referer', 'https://www.hmdb.ca/spectra/ms/search');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
388 $mech->add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
389 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
390
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
391
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
392 ## POST test
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
393 my $top = 1 ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
394 while ($statusPostLine != 200 ) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
395
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
396 # Fix a limit at 3 tries...
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
397 if ($top < 4) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
398 print "\tTesting HMDB server connexion ($top time(s) )...\n" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
399 eval {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
400 my $res = $mech->get(
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
401 'https://hmdb.ca/spectra/ms/generate_csv.csv?'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
402 .'results%5Baction%5D=search'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
403 .'&results%5Badduct_type%5D%5B%5D=M%2BH%202M%2BH'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
404 #.'&results%5Bauthenticity_token%5D='
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
405 .'&results%5Bccs_predictors%5D='
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
406 .'&results%5Bccs_tolerance%5D='
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
407 .'&results%5Bcommit%5D=Search'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
408 .'&results%5Bcontroller%5D=specdb%2Fms'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
409 .'&results%5Bms_search_ion_mode%5D=positive'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
410 .'&results%5Bquery_masses%5D=125.0089'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
411 .'&results%5Btolerance%5D=0.001'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
412 .'&results%5Btolerance_units%5D=Da'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
413 .'&results%5Butf8%5D=%E2%9C%93'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
414
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
415 );
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
416 } ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
417 # print Dumper $mech ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
418 $statusPostLine = $mech->status() ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
419 print "Status: $statusPostLine" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
420 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
421 else {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
422 last ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
423 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
424 $top++ ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
425 }## End While
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
426 return (\$statusPostLine) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
427 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
428 ## END of SUB
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
429
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
430 =head2 METHOD check_state_from_hmdb_ua
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
431
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
432 ## Description : check the thhp status of hmdb and kill correctly the script if necessary.
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
433 ## Input : $status
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
434 ## Output : none
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
435 ## Usage : check_state_from_hmdb_ua($status) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
436
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
437 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
438 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
439 sub check_state_from_hmdb_ua {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
440 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
441 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
442 my ($status) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
443
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
444 if (!defined $$status) {
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
445 croak "No https status is defined for the distant server" ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
446 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
447 else {
14
625fa968d99a Master branch Updating - - Fxx
fgiacomoni
parents: 9
diff changeset
448 unless ( $$status == 200 ) {
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
449 if ( $$status == 502 ) { croak "Bad Gateway (502): The HMDB server, while acting as a gateway or proxy, received an invalid response from the upstream server. The Hmdb tool is stopped with error." ; }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
450 if ( $$status == 504 ) { croak "Gateway Timeout (504): The HMDB server was acting as a gateway or proxy and did not receive a timely response from the upstream server. The Hmdb tool is stopped with error." ; }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
451 if ( $$status == 500 ) { croak "Internal Server Error (500): The HMDB server returns an unexpected internal server error. The Hmdb tool is stopped with error." ; }
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
452 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
453 ## None supported http code error ##
14
625fa968d99a Master branch Updating - - Fxx
fgiacomoni
parents: 9
diff changeset
454 croak "Internal Server Error $$status..." ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
455 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
456 }
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
457 if ( $$status == 200 ) {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
458 print "\tThe HMDB server returns that your request (connexion test) was fulfilled\n" ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
459 print "\tAll searches should be sent successfully to HMDB...(Set verbose to \"High\" for more information!)\n" ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
460 }
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
461 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
462
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
463 return (1) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
464 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
465 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
466
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
467 =head2 METHOD get_matches_from_hmdb_ua DEPRECATED
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
468
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
469 ## Description : [DEPRECATED]HMDB querying via an user agent with parameters : mz, delta and molecular species (neutral, pos, neg)
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
470 ## Input : $mass, $delta, $mode
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
471 ## Output : $results
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
472 ## Usage : my ( $results ) = get_matches_from_hmdb( $mass, $delta, $mode ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
473
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
474 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
475 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
476 sub get_matches_from_hmdb_ua {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
477 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
478 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
479 my ( $masses, $delta, $mode ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
480
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
481 ## Added May, 2022
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
482 warn "[DEPRECATED Methode] method get_matches_from_hmdb_ua is deprecated and not compatible with HMDB 4.0" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
483 return ([], 500) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
484
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
485 my @page = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
486
8
97788e4bf3fc planemo upload commit d1a5cd8f1baf00879ffa44649883f91c64f43392-dirty
fgiacomoni
parents: 6
diff changeset
487 my $ua = LWP::UserAgent->new( keep_alive => 10 );
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
488 $ua->agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:64.0) Gecko/20100101 Firefox/64.0");
9
c32280662103 Master branch Updating - - Fxx
fgiacomoni
parents: 8
diff changeset
489 $ua->timeout(2400) ;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
490
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
491 # Cookies
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
492 # my $cookie = new HTTP::Cookies( ignore_discard => 1 );
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
493 # $ua->cookie_jar( $cookie );
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
494
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
495 # my $req = HTTP::Request->new(
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
496 # POST => 'http://specdb.wishartlab.com/ms/search.csv');
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
497
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
498 my $url = 'http://specdb.wishartlab.com/ms/search.csv';
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
499 my $header = ['Content-Type' => 'application/x-www-form-urlencoded', 'Referer' => 'http://www.hmdb.ca/spectra/ms/search', 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'];
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
500 my $data = {mode => $mode, query_masses => $masses, 'tolerance' => $delta, database => 'HMDB', commit => 'Download Results As CSV'};
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
501 my $encoded_data = encode_utf8($data);
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
502
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
503 my $req = HTTP::Request->new('POST', $url, $header, $encoded_data);
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
504
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
505 # $req->content_type('application/x-www-form-urlencoded');
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
506 $req->content('utf8=TRUE&mode='.$mode.'&query_masses='.$masses.'&tolerance='.$delta.'&database=HMDB&commit=Download Results As CSV');
14
625fa968d99a Master branch Updating - - Fxx
fgiacomoni
parents: 9
diff changeset
507 # print Dumper $req ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
508 my $res = $ua->request($req);
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
509 my $status_line = undef ;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
510 print $res->as_string;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
511 if ($res->is_success) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
512 @page = split ( /\n/, $res->decoded_content ) ;
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
513 $status_line = 'OK' ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
514 } else {
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
515 $status_line = $res->status_line ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
516 ($status_line) = ($status_line =~ /(\d+)/);
17
49f87ddb2c78 Master branch Updating - - Fxx
fgiacomoni
parents: 15
diff changeset
517 warn "\t[HMDB service issue !! the server returned a $status_line HTTP error]" ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
518 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
519
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
520
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
521 return (\@page, $status_line) ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
522 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
523 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
524
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
525 =head2 METHOD getMatchesFromHmdbWithUA
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
526
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
527 ## Description : HMDB querying via an user agent with parameters : mz, delta and molecular species (neutral, pos, neg)
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
528 ## Input : $mass, $delta, $mode, adducts
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
529 ## Output : $results
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
530 ## Usage : my ( $results ) = getMatchesFromHmdbWithUA( $mass, $delta, $mode ) ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
531
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
532 =cut
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
533 ## START of SUB
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
534 sub getMatchesFromHmdbWithUA {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
535 ## Retrieve Values
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
536 my $self = shift ;
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
537 my ( $masses, $delta, $mode, $adducts ) = @_ ;
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
538
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
539 ## Added May, 2022
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
540 warn "[DEPRECATED Methode] method getMatchesFromHmdbWithUA is deprecated and not compatible with HMDB 5.0" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
541 return ([], 500) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
542
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
543 my @page = () ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
544
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
545 #based on https://stackoverflow.com/questions/17732916/perl-post-automation-and
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
546
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
547 my $mech = WWW::Mechanize->new(
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
548 agent => 'wonderbot for W4M 1.01',
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
549 autocheck => 1,
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
550 timeout => 2400,
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
551 );
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
552
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
553 my $statusGetLine = 0 ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
554 my $statusPostLine = 0 ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
555
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
556 #receiving cookies and authentication token (CFRS)
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
557 my $reqInit = $mech->get("http://www.hmdb.ca/spectra/ms/search");
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
558 $statusGetLine = $mech->status() ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
559
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
560 if ($statusGetLine == 200 ) {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
561 die 'no CSRF_REQUEST_TOKEN_VALUE in page found'
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
562 unless ($reqInit->decoded_content =~ /\"csrf-token\"\s+content=\"(.*)\"/) ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
563 my $csrftoken = $1;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
564 # print "\nTOKEN: $csrftoken\n" ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
565 $mech->add_header("X-CSRFToken", $csrftoken);
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
566 $mech->add_header('Connection', 'keep-alive');
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
567 $mech->add_header('Content-Type', 'application/x-www-form-urlencoded');
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
568 $mech->add_header('Referer', 'http://www.hmdb.ca/spectra/ms/search');
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
569 $mech->add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
570 }
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
571 ## adduct format is adduct_type=M%2BH%202M%2BH
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
572
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
573 if ( (!defined $adducts) or ( $adducts eq '') ) {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
574 $adducts = 'Unknown' ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
575 }
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
576
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
577 my $res = $mech->post(
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
578 "http://specdb.wishartlab.com/ms/search.csv",
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
579 Content => 'utf8=TRUE&mode='
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
580 .$mode.'&adduct_type='
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
581 .$adducts.'&query_masses='
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
582 .$masses.'&tolerance='
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
583 .$delta.'&database=HMDB&commit=Download Results As CSV'
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
584 );
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
585
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
586 if ($mech->success) {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
587 @page = split ( /\n/, $res->decoded_content ) ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
588 $statusPostLine = 'OK' ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
589 }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
590 else {
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
591 $statusPostLine = $mech->status() ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
592 warn "\t[HMDB service issue !! the server returned a $statusPostLine HTTP error]" ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
593 }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
594
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
595 # print Dumper $res->decoded_content ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
596
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
597 return (\@page, $statusPostLine) ;
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
598 }
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
599 ## END of SUB
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
600
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
601 =head2 METHOD getMatchesFromHmdb5WithUA
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
602
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
603 ## Description : HMDB v5.0 querying via an user agent with parameters : mz, delta and molecular species (neutral, pos, neg)
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
604 ## Input : $mass, $delta, $mode, adducts
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
605 ## Output : $results
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
606 ## Usage : my ( $results ) = getMatchesFromHmdbWithUA( $mass, $delta, $mode ) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
607
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
608 =cut
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
609 ## START of SUB
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
610 sub getMatchesFromHmdb5WithUA {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
611 ## Retrieve Values
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
612 my $self = shift ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
613 my ( $masses, $delta, $mode, $adducts ) = @_ ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
614
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
615 my @page = () ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
616
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
617 #based on https://stackoverflow.com/questions/17732916/perl-post-automation-and
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
618
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
619 my $mech = WWW::Mechanize->new(
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
620 agent => 'wonderbot for W4M 3.0',
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
621 autocheck => 1,
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
622 timeout => 2400,
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
623 );
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
624
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
625 my $statusGetLine = 0 ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
626 my $statusPostLine = 0 ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
627
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
628 #receiving cookies and authentication token (CFRS)
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
629 my $reqInit = $mech->get("https://www.hmdb.ca/spectra/ms/search");
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
630 $statusGetLine = $mech->status() ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
631
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
632 if ($statusGetLine == 200 ) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
633 die 'no CSRF_REQUEST_TOKEN_VALUE in page found'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
634 unless ($reqInit->decoded_content =~ /\"csrf-token\"\s+content=\"(.*)\"/) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
635 my $csrftoken = $1;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
636 # print "\nTOKEN: $csrftoken\n" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
637 $mech->add_header("X-CSRFToken", $csrftoken);
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
638 $mech->add_header('Connection', 'keep-alive');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
639 $mech->add_header('Content-Type', 'application/x-www-form-urlencoded');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
640 $mech->add_header('Referer', 'https://www.hmdb.ca/spectra/ms/search');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
641 $mech->add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
642 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
643 ## adduct format is adduct_type=M%2BH%202M%2BH
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
644
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
645 if ( (!defined $adducts) or ( $adducts eq '') ) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
646 $adducts = 'Unknown' ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
647 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
648
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
649 my $res = $mech->get(
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
650 'https://hmdb.ca/spectra/ms/generate_csv.csv?'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
651 .'results%5Baction%5D=search'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
652 .'&results%5Badduct_type%5D%5B%5D='.$adducts
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
653 #.'&results%5Bauthenticity_token%5D='
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
654 .'&results%5Bccs_predictors%5D='
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
655 .'&results%5Bccs_tolerance%5D='
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
656 .'&results%5Bcommit%5D=Search'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
657 .'&results%5Bcontroller%5D=specdb%2Fms'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
658 .'&results%5Bms_search_ion_mode%5D='.$mode
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
659 .'&results%5Bquery_masses%5D='.$masses
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
660 .'&results%5Btolerance%5D='.$delta
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
661 .'&results%5Btolerance_units%5D=Da'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
662 .'&results%5Butf8%5D=%E2%9C%93'
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
663
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
664 );
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
665 $statusGetLine = $mech->status() ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
666
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
667 if ($mech->success) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
668 @page = split ( /\n/, $res->decoded_content ) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
669 $statusPostLine = 'OK' ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
670 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
671 else {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
672 $statusPostLine = $mech->status() ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
673 warn "\t[HMDB service issue !! the server returned a $statusPostLine HTTP error]" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
674 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
675
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
676 # print Dumper $res->decoded_content ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
677
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
678 return (\@page, $statusPostLine) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
679 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
680 ## END of SUB
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
681
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
682
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
683 =head2 METHOD parseHmdb5CSVResults
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
684
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
685 ## Description : parse the csv results and get data - API 5.0 compliant
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
686 ## Input : $csv
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
687 ## Output : $results
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
688 ## Usage : my ( $results ) = parseHmdb5CSVResults( $csv ) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
689
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
690 =cut
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
691 ## START of SUB
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
692 sub parseHmdb5CSVResults {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
693 ## Retrieve Values
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
694 my $self = shift ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
695 my ( $csv, $masses, $max_query ) = @_ ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
696
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
697 my $test = 0 ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
698 my ($query_mass,$compound_id,$formula,$compound_mass,$adduct,$adduct_type,$adduct_mass,$delta) = (0, undef, undef, undef, undef, undef, undef, undef) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
699
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
700 my %result_by_entry = () ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
701 my %features = () ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
702
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
703 # print Dumper $csv ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
704 # print Dumper $masses ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
705 # print Dumper $max_query ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
706
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
707 foreach my $line (@{$csv}) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
708 ## NEW HMDB format V5.0 - May2022
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
709 if ($line !~ /query_mass,compound_id,compound_name,formula,monoisotopic_mass,adduct,adduct_type,adduct_m\/z,"delta\(ppm\),",ccs_value/) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
710 #query_mass,compound_id,compound_name,formula,monoisotopic_mass,adduct,adduct_type,adduct_m/z,"delta(ppm),",ccs_value',
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
711
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
712 if ( $line =~ /(\d+\.\d+),(\w+),(.*),(\w+),(\d+\.\d+),([\w|n\/a|\s+]+)\s*,(\+|\-),(\d+\.\d+),(\d+),(\d*)/ ) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
713 print "$line\n" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
714 #if ( $line =~ /(\d+\.\d+),(\w+),(.*),([\w|n\/a|\s+]+)\s*,(\w+),(\d+\.\d+),(.*),(\+|\-),(\d+\.\d+),(\d+)/ ) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
715 my @entry = ("$1","$2","$3","$4","$5","$6","$7","$8","$9","$10") ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
716
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
717 if ( !exists $result_by_entry{$entry[0]} ) { $result_by_entry{$entry[0]} = [] ; }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
718
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
719 $features{ENTRY_ENTRY_ID} = $entry[1] ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
720 $features{ENTRY_ENTRY_NAME} = $entry[2] ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
721 $features{ENTRY_FORMULA} = $entry[3] ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
722 $features{ENTRY_CPD_MZ} = $entry[4] ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
723 $features{ENTRY_ADDUCT} = $entry[5] ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
724 $features{ENTRY_ADDUCT_TYPE} = $entry[6] ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
725 $features{ENTRY_ADDUCT_MZ} = $entry[7] ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
726 $features{ENTRY_DELTA} = $entry[8] ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
727
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
728 my %temp = %features ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
729 push (@{$result_by_entry{$entry[0]} }, \%temp) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
730 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
731 # elsif ($line =~ /(\d+\.\d+)/) { #
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
732 # ## 288.082286511284,HMDB0002255,R-Methylmalonyl-CoA, C01213 ,C25H40N7O19P3S,867.131252359,M-3H,-,288.036475,159
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
733 # ## 283.108004472276,"Bicyclo_3,1,1heptane-2,3-diol,2,6,6_trimethyl","2,3-Pinanediol",n/a,C10H18O2,170.13067982,M+TFA-H,-,283.116266,29
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
734 # ## 174.034120330029,HMDB0011723,2-Methylhippuric acid, C01586,C10H11NO3,193.073893223,M-H20-H,-,174.055503,123
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
735 # ## 193.139160745841,HMDB0012109,"7-[(1R,2R,3R,5S)-3,5-Dihydroxy-2-[(1E,3S)-3-hydroxyoct-1-en-1-yl]cyclopentyl]-5,6-dihydroxyheptanoic acid", C06475,C20H36O7,388.246103506,M-2H,-,193.115776,121
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
736 # ## 214.018826827064,HMDB0011723,2-Methylhippuric acid, C01586,C10H11NO3,193.073893223,M+Na-2H,-,214.048559,139
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
737 # }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
738 # else {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
739 #
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
740 # warn "The parsed line ($line) does not match your pattern\n " ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
741 # }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
742 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
743 else {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
744 print "Header detected...Parsing is starting...\n" ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
745 next ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
746 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
747 } ## end foreach
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
748
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
749 ## manage per query_mzs (keep query masses order by array)
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
750 my @results = () ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
751 foreach (@{$masses}) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
752 if ($result_by_entry{$_}) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
753
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
754 ## cut all entries > $max_query - all entries were already sorted...by hmdb
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
755 my @temp_entries = @{$result_by_entry{$_}} ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
756 my @temp_cut = () ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
757 my $current_query = 0 ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
758 foreach (@temp_entries) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
759 $current_query ++ ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
760 if ($current_query > $max_query) {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
761 last ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
762 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
763 else {
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
764 push (@temp_cut, $_) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
765 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
766 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
767 push (@results, \@temp_cut) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
768 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
769 else { push (@results, [] ) ; } ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
770
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
771 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
772 return(\@results) ;
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
773 }
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
774 ## END of SUB
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
775
20
b5a1d5e43685 Master branch Updating - - Fxx
fgiacomoni
parents: 17
diff changeset
776
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
777 =head2 METHOD parse_hmdb_csv_results
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
778
23
2d8a310e86ce Prod branch Updating with v.:CI_COMMIT_TAG- - Fxx
fgiacomoni
parents: 22
diff changeset
779 ## Description : [DEPRECATED] parse the csv results and get data
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
780 ## Input : $csv
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
781 ## Output : $results
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
782 ## Usage : my ( $results ) = parse_hmdb_csv_results( $csv ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
783
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
784 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
785 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
786 sub parse_hmdb_csv_results {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
787 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
788 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
789 my ( $csv, $masses, $max_query ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
790
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
791 my $test = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
792 my ($query_mass,$compound_id,$formula,$compound_mass,$adduct,$adduct_type,$adduct_mass,$delta) = (0, undef, undef, undef, undef, undef, undef, undef) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
793
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
794 my %result_by_entry = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
795 my %features = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
796
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
797 # print Dumper $csv ;
14
625fa968d99a Master branch Updating - - Fxx
fgiacomoni
parents: 9
diff changeset
798 # print Dumper $masses ;
625fa968d99a Master branch Updating - - Fxx
fgiacomoni
parents: 9
diff changeset
799 # print Dumper $max_query ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
800
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
801 foreach my $line (@{$csv}) {
4
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
802 ## NEW HMDB format V4.0 - dec2017
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
803 if ($line !~ /query_mass,compound_id,compound_name,kegg_id,formula,monoisotopic_mass,adduct,adduct_type,adduct_m\/z,delta\(ppm\)/) {
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
804
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
805 if ( $line =~ /(\d+\.\d+),(\w+),(.*),([\w|n\/a|\s+]+)\s*,(\w+),(\d+\.\d+),(.*),(\+|\-),(\d+\.\d+),(\d+)/ ) {
4
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
806 my @entry = ("$1","$2","$3","$4","$5","$6","$7","$8","$9","$10") ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
807
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
808 if ( !exists $result_by_entry{$entry[0]} ) { $result_by_entry{$entry[0]} = [] ; }
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
809
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
810 $features{ENTRY_ENTRY_ID} = $entry[1] ;
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
811 $features{ENTRY_ENTRY_NAME} = $entry[2] ;
4
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
812 $features{ENTRY_FORMULA} = $entry[4] ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
813 $features{ENTRY_CPD_MZ} = $entry[5] ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
814 $features{ENTRY_ADDUCT} = $entry[6] ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
815 $features{ENTRY_ADDUCT_TYPE} = $entry[7] ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
816 $features{ENTRY_ADDUCT_MZ} = $entry[8] ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
817 $features{ENTRY_DELTA} = $entry[9] ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
818
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
819 my %temp = %features ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
820 push (@{$result_by_entry{$entry[0]} }, \%temp) ;
6091a80df951 planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
fgiacomoni
parents: 1
diff changeset
821 }
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
822 # elsif ($line =~ /(\d+\.\d+)/) { #
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
823 # ## 288.082286511284,HMDB0002255,R-Methylmalonyl-CoA, C01213 ,C25H40N7O19P3S,867.131252359,M-3H,-,288.036475,159
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
824 # ## 283.108004472276,"Bicyclo_3,1,1heptane-2,3-diol,2,6,6_trimethyl","2,3-Pinanediol",n/a,C10H18O2,170.13067982,M+TFA-H,-,283.116266,29
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
825 # ## 174.034120330029,HMDB0011723,2-Methylhippuric acid, C01586,C10H11NO3,193.073893223,M-H20-H,-,174.055503,123
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
826 # ## 193.139160745841,HMDB0012109,"7-[(1R,2R,3R,5S)-3,5-Dihydroxy-2-[(1E,3S)-3-hydroxyoct-1-en-1-yl]cyclopentyl]-5,6-dihydroxyheptanoic acid", C06475,C20H36O7,388.246103506,M-2H,-,193.115776,121
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
827 # ## 214.018826827064,HMDB0011723,2-Methylhippuric acid, C01586,C10H11NO3,193.073893223,M+Na-2H,-,214.048559,139
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
828 # }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
829 # else {
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
830 #
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
831 # warn "The parsed line ($line) does not match your pattern\n " ;
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
832 # }
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
833 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
834 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
835 next ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
836 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
837 } ## end foreach
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
838
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
839 ## manage per query_mzs (keep query masses order by array)
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
840 my @results = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
841 foreach (@{$masses}) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
842 if ($result_by_entry{$_}) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
843
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
844 ## cut all entries > $max_query - all entries were already sorted...by hmdb
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
845 my @temp_entries = @{$result_by_entry{$_}} ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
846 my @temp_cut = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
847 my $current_query = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
848 foreach (@temp_entries) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
849 $current_query ++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
850 if ($current_query > $max_query) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
851 last ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
852 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
853 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
854 push (@temp_cut, $_) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
855 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
856 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
857 push (@results, \@temp_cut) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
858 }
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
859 else { push (@results, [] ) ; } ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
860
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
861 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
862 return(\@results) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
863 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
864 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
865
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
866 =head2 METHOD parse_hmdb_page_results
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
867
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
868 ## Description : [DEPRECATED] old HMDB html page parser
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
869 ## Input : $page
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
870 ## Output : $results
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
871 ## Usage : my ( $results ) = parse_hmdb_page_result( $pages ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
872
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
873 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
874 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
875 sub parse_hmdb_page_results {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
876 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
877 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
878 my ( $page ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
879
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
880 my @results = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
881 my ($catch_table, $catch_name) = (0, 0) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
882 my ($name, $adduct, $adduct_mw, $cpd_mw, $delta) = (undef, undef, undef, undef, undef) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
883
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
884 if ( defined $page ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
885
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
886 my @page = @{$page} ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
887 my $ID = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
888 my @result_by_mz = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
889 my %result_by_entry = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
890
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
891 foreach my $line (@page) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
892
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
893 #Section de la page contenant les resultat
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
894 if( $line =~/<table>/ ) { $catch_table = 1 ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
895
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
896 ## Si il existe un resultat :
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
897 if($catch_table == 1) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
898
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
899 #Id de la molecule, et creation du lien
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
900 if( $line =~ /<a href=\"\/metabolites\/(\w+)\" (.*)>/ ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
901 $ID = $1 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
902 $catch_name = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
903 next ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
904 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
905 #Nom de la molecule ONLY!!
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
906 if ( $catch_name == 0 ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
907
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
908 if( $line =~ /<td>(.+)<\/td>/ ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
909
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
910 if ( !defined $name ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
911 $name = $1 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
912 $result_by_entry{'ENTRY_ENTRY_ID'} = $ID ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
913 $result_by_entry{'ENTRY_NAME'} = $name ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
914 next ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
915 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
916 if ( !defined $adduct ) { $adduct = $1 ; $result_by_entry{'ENTRY_ADDUCT'} = $adduct ; next ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
917 if ( !defined $adduct_mw ) { $adduct_mw = $1 ; $result_by_entry{'ENTRY_ADDUCT_MZ'} = $adduct_mw ; next ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
918 if ( !defined $cpd_mw ) { $cpd_mw = $1 ; $result_by_entry{'ENTRY_CPD_MZ'} = $cpd_mw ; next ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
919 if ( !defined $delta ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
920 $delta = $1 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
921 $result_by_entry{'ENTRY_DELTA'} = $delta ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
922 $catch_name = 1 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
923 my %tmp = %result_by_entry ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
924 push (@result_by_mz, \%tmp) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
925 %result_by_entry = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
926 ( $name, $cpd_mw, $delta, $adduct, $adduct_mw ) = ( undef, undef, undef, undef, undef ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
927 next ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
928 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
929 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
930 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
931 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
932 #Fin de la section contenant les resultats
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
933 if( $line =~ /<\/table>/ ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
934 $catch_table = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
935 my @Tmp = @result_by_mz ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
936 push(@results, \@Tmp) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
937 @result_by_mz = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
938 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
939 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
940 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
941 return(\@results) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
942 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
943 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
944
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
945
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
946 =head2 METHOD get_unik_ids_from_results
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
947
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
948 ## Description : get all unik ids from the hmdb result object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
949 ## Input : $results
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
950 ## Output : $ids, $idsNumber
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
951 ## Usage : my ( $ids ) = get_unik_ids_from_results ( $results ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
952
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
953 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
954 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
955 sub get_unik_ids_from_results {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
956 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
957 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
958 my ( $results ) = @_;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
959 my ( %ids ) = ( () ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
960
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
961 foreach my $result (@{$results}) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
962
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
963 foreach my $entries (@{$result}) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
964
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
965 if ( ($entries->{'ENTRY_ENTRY_ID'}) and ($entries->{'ENTRY_ENTRY_ID'} ne '' ) ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
966 $ids{$entries->{'ENTRY_ENTRY_ID'}} = 1 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
967 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
968 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
969 }
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
970 my $idsNumber = keys %ids ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
971 return (\%ids, $idsNumber) ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
972 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
973 ### END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
974
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
975
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
976
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
977 =head2 METHOD get_hmdb_metabocard_from_id
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
978
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
979 ## Description : get a metabocard (xml format from an ID on HMDB)
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
980 ## Input : $ids
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
981 ## Output : $metabocard_features
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
982 ## Usage : my ( $metabocard_features ) = get_hmdb_metabocard_from_id ( $ids ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
983
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
984 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
985 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
986 sub get_hmdb_metabocard_from_id {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
987 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
988 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
989 my ( $ids, $hmdb_url ) = @_;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
990 my ( %metabocard_features ) = ( () ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
991 my $query = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
992
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
993 ## structure %metabocard_features
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
994 # metabolite_id = (
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
995 # 'metabolite_name' => '__name__',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
996 # 'metabolite_inchi' => '__inchi__',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
997 # 'metabolite_logp' => '__logp-ALOGPS__',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
998 #
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
999 # )
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1000
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1001
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1002 if( (defined $ids) and ($ids > 0 ) ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1003
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1004 foreach my $id (keys %{$ids}) {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1005 print "$id...\n" ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1006 my $twig = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1007
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1008 if (defined $hmdb_url) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1009 $query = $hmdb_url.$id.'.xml' ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1010
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1011 ## test the header if exists
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1012 my $response = head($query) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1013
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1014 if (!defined $response) {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1015 $metabocard_features{$id}{'STATUS'} = 'NOT_EXISTING' ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1016 $metabocard_features{$id}{'metabolite_name'} = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1017 $metabocard_features{$id}{'metabolite_inchi'} = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1018 $metabocard_features{$id}{'metabolite_logp'} = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1019 ## Need to be improve to manage http 404 or other response diff than 200
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1020 } ## IF error
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1021 elsif ( $response->is_success ) {
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1022
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1023 $twig = XML::Twig->nparse_ppe(
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1024
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1025 twig_handlers => {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1026 # metabolite name
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1027 'metabolite/name' => sub { $metabocard_features{$id}{'metabolite_name'} = $_ -> text_only ; $metabocard_features{$id}{'STATUS'} = 'EXISTING' ; } ,
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1028 # metabolite inchi
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1029 'metabolite/inchi' => sub { $metabocard_features{$id}{'metabolite_inchi'} = $_ -> text_only ; $metabocard_features{$id}{'STATUS'} = 'EXISTING' ;} ,
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1030 ## metabolite logP
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1031 'metabolite/predicted_properties/property' => sub {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1032
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1033 my ($kind, $source, $value ) = ( undef, undef, undef ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1034
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1035 if (defined $_->children ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1036 foreach my $field ($_->children) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1037 if ( $field->name eq 'kind') { $kind = $field->text ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1038 elsif ( $field->name eq 'source') { $source = $field->text ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1039 elsif ( $field->name eq 'value') { $value = $field->text ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1040
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1041 if (defined $source ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1042 if ( ( $kind eq 'logp' ) and ( $source eq 'ALOGPS' ) ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1043 $metabocard_features{$id}{'metabolite_logp'} = $value ;
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1044 $metabocard_features{$id}{'STATUS'} = 'EXISTING' ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1045 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1046 ($kind, $source, $value ) = ( undef, undef, undef ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1047 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1048 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1049 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1050 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1051 },
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1052 pretty_print => 'indented',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1053 error_context => 1, $query
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1054 );
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1055
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1056 # $twig->print;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1057 $twig->purge ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1058
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1059 # if (!$@) {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1060 #
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1061 # }
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1062 # else {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1063 # warn $@ ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1064 # }
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1065 } ## ELSIF success
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1066 } # END if defined URL
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1067 else {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1068 warn "\tThe hmdb metabocard url is not defined\n" ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1069 last;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1070 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1071 }
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1072 } ## End IF defined ids
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1073 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1074 warn "The HMDB ids list from HMDB is empty - No metabocard found\n" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1075 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1076
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1077 # print Dumper %metabocard_features ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1078 return (\%metabocard_features) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1079 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1080 ### END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1081
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1082
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1083 =head2 METHOD map_suppl_data_on_hmdb_results
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1084
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1085 ## Description : map supplementary data with already collected results with hmdb search - delete the entry if hmdb card doesn't exist...
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1086 ## Input : $results, $features
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1087 ## Output : $results
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1088 ## Usage : my ( $results ) = map_suppl_data_on_hmdb_results ( $results, $features ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1089
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1090 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1091 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1092 sub map_suppl_data_on_hmdb_results {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1093 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1094 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1095 my ( $results, $features ) = @_;
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1096 my ( @moreResults ) = ( () ) ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1097
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1098 foreach my $result (@{$results}) {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1099
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1100 my @newResult = () ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1101
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1102 foreach my $entry (@{$result}) {
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1103
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1104 if ( ($entry->{'ENTRY_ENTRY_ID'}) and ($entry->{'ENTRY_ENTRY_ID'} ne '' ) ) {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1105
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1106 my $current_id = $entry->{'ENTRY_ENTRY_ID'} ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1107 my $newCompletedEntry = $entry ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1108
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1109 ## If the id exists in feature hash and its status is not NOT_EXISTING
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1110 if ( ($features->{"$current_id"} ) and ( $features->{"$current_id"}{STATUS} eq 'EXISTING' ) ) {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1111
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1112 ## Metabolite NAME
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1113 if (defined $features->{"$current_id"}{'metabolite_name'} ) {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1114 $newCompletedEntry->{'ENTRY_ENTRY_NAME'} = $features->{"$current_id"}{'metabolite_name'}
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1115 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1116 else {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1117 $newCompletedEntry->{'ENTRY_ENTRY_NAME'} = 'UNKNOWN' ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1118 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1119 ## Metabolite INCHI
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1120 if (defined $features->{"$current_id"}{'metabolite_inchi'} ) {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1121 $newCompletedEntry->{'ENTRY_ENTRY_INCHI'} = $features->{"$current_id"}{'metabolite_inchi'}
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1122 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1123 else {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1124 $newCompletedEntry->{'ENTRY_ENTRY_INCHI'} = 'NA' ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1125 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1126 ## Metabolite LOGP
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1127 if (defined $features->{"$current_id"}{'metabolite_logp'} ) {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1128 $newCompletedEntry->{'ENTRY_ENTRY_LOGP'} = $features->{"$current_id"}{'metabolite_logp'}
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1129 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1130 else {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1131 $newCompletedEntry->{'ENTRY_ENTRY_LOGP'} = 'NA' ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1132 }
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1133 push (@newResult, $newCompletedEntry) ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1134 }
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1135 elsif ( ($features->{"$current_id"} ) and ( $features->{"$current_id"}{STATUS} eq 'NOT_EXISTING' ) ) {
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1136 $newCompletedEntry = undef ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1137 next ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1138
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1139 }
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1140 ## In cas no features are given
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1141 else {
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1142 $newCompletedEntry->{'ENTRY_ENTRY_INCHI'} = 'NONEDATA' ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1143 $newCompletedEntry->{'ENTRY_ENTRY_LOGP'} = 'NONEDATA' ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1144 push (@newResult, $newCompletedEntry) ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1145 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1146 }
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1147 } ## END FOREACH ENTRIES
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1148
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1149 push (@moreResults, \@newResult) ;
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1150
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1151 } ## END FOREACH RESULT
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1152
21
63ba1cb240b7 Prod branch Updating - - Fxx
fgiacomoni
parents: 20
diff changeset
1153 return (\@moreResults) ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1154 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1155 ### END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1156
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1157
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1158 =head2 METHOD set_html_tbody_object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1159
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1160 ## Description : initializes and build the tbody object (perl array) needed to html template
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1161 ## Input : $nb_pages, $nb_items_per_page
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1162 ## Output : $tbody_object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1163 ## Usage : my ( $tbody_object ) = set_html_tbody_object($nb_pages, $nb_items_per_page) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1164
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1165 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1166 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1167 sub set_html_tbody_object {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1168 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1169 my ( $nb_pages, $nb_items_per_page ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1170
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1171 my ( @tbody_object ) = ( ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1172
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1173 for ( my $i = 1 ; $i <= $nb_pages ; $i++ ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1174
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1175 my %pages = (
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1176 # tbody feature
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1177 PAGE_NB => $i,
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1178 MASSES => [], ## end MASSES
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1179 ) ; ## end TBODY N
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1180 push (@tbody_object, \%pages) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1181 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1182 return(\@tbody_object) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1183 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1184 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1185
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1186 =head2 METHOD add_mz_to_tbody_object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1187
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1188 ## Description : initializes and build the mz object (perl array) needed to html template
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1189 ## Input : $tbody_object, $nb_items_per_page, $mz_list
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1190 ## Output : $tbody_object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1191 ## Usage : my ( $tbody_object ) = add_mz_to_tbody_object( $tbody_object, $nb_items_per_page, $mz_list ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1192
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1193 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1194 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1195 sub add_mz_to_tbody_object {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1196 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1197 my ( $tbody_object, $nb_items_per_page, $mz_list, $ids_list ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1198
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1199 my ( $current_page, $mz_index ) = ( 0, 0 ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1200
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1201 foreach my $page ( @{$tbody_object} ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1202
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1203 my @colors = ('white', 'green') ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1204 my ( $current_index, , $icolor ) = ( 0, 0 ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1205
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1206 for ( my $i = 1 ; $i <= $nb_items_per_page ; $i++ ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1207 #
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1208 if ( $current_index > $nb_items_per_page ) { ## manage exact mz per html page
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1209 $current_index = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1210 last ; ##
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1211 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1212 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1213 $current_index++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1214 if ( $icolor > 1 ) { $icolor = 0 ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1215
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1216 if ( exists $mz_list->[$mz_index] ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1217
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1218 my %mz = (
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1219 # mass feature
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1220 MASSES_ID_QUERY => $ids_list->[$mz_index],
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1221 MASSES_MZ_QUERY => $mz_list->[$mz_index],
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1222 MZ_COLOR => $colors[$icolor],
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1223 MASSES_NB => $mz_index+1,
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1224 ENTRIES => [] ,
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1225 ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1226 push ( @{ $tbody_object->[$current_page]{MASSES} }, \%mz ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1227 # Html attr for mass
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1228 $icolor++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1229 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1230 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1231 $mz_index++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1232 } ## foreach mz
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1233
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1234 $current_page++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1235 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1236 return($tbody_object) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1237 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1238 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1239
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1240 =head2 METHOD add_entries_to_tbody_object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1241
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1242 ## Description : initializes and build the entries object (perl array) needed to html template
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1243 ## Input : $tbody_object, $nb_items_per_page, $mz_list, $entries
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1244 ## Output : $tbody_object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1245 ## Usage : my ( $tbody_object ) = add_entries_to_tbody_object( $tbody_object, $nb_items_per_page, $mz_list, $entries ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1246
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1247 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1248 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1249 sub add_entries_to_tbody_object {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1250 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1251 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1252 my ( $tbody_object, $nb_items_per_page, $mz_list, $entries ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1253
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1254 my $index_page = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1255 my $index_mz_continous = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1256
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1257 foreach my $page (@{$tbody_object}) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1258
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1259 my $index_mz = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1260
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1261 foreach my $mz (@{ $tbody_object->[$index_page]{MASSES} }) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1262
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1263 my $index_entry = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1264
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1265 my @anti_redondant = ('N/A') ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1266 my $check_rebond = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1267 my $check_noentry = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1268
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1269 foreach my $entry (@{ $entries->[$index_mz_continous] }) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1270 $check_noentry ++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1271 ## dispo anti doublons des entries
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1272 foreach my $rebond (@anti_redondant) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1273 if ( $rebond eq $entries->[$index_mz_continous][$index_entry]{ENTRY_ENTRY_ID} ) { $check_rebond = 1 ; last ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1274 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1275
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1276 if ( $check_rebond == 0 ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1277
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1278 push ( @anti_redondant, $entries->[$index_mz_continous][$index_entry]{ENTRY_ENTRY_ID} ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1279
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1280 my %entry = (
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1281 ENTRY_COLOR => $tbody_object->[$index_page]{MASSES}[$index_mz]{MZ_COLOR},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1282 ENTRY_ENTRY_NAME => $entries->[$index_mz_continous][$index_entry]{ENTRY_ENTRY_NAME},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1283 ENTRY_ENTRY_ID => $entries->[$index_mz_continous][$index_entry]{ENTRY_ENTRY_ID},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1284 ENTRY_ENTRY_ID2 => $entries->[$index_mz_continous][$index_entry]{ENTRY_ENTRY_ID},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1285 ENTRY_FORMULA => $entries->[$index_mz_continous][$index_entry]{ENTRY_FORMULA},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1286 ENTRY_CPD_MZ => $entries->[$index_mz_continous][$index_entry]{ENTRY_CPD_MZ},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1287 ENTRY_ADDUCT => $entries->[$index_mz_continous][$index_entry]{ENTRY_ADDUCT},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1288 ENTRY_ADDUCT_TYPE => $entries->[$index_mz_continous][$index_entry]{ENTRY_ADDUCT_TYPE},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1289 ENTRY_ADDUCT_MZ => $entries->[$index_mz_continous][$index_entry]{ENTRY_ADDUCT_MZ},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1290 ENTRY_DELTA => $entries->[$index_mz_continous][$index_entry]{ENTRY_DELTA},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1291 ENTRY_ENTRY_INCHI => $entries->[$index_mz_continous][$index_entry]{ENTRY_ENTRY_INCHI},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1292 ENTRY_ENTRY_LOGP => $entries->[$index_mz_continous][$index_entry]{ENTRY_ENTRY_LOGP},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1293 ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1294
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1295 push ( @{ $tbody_object->[$index_page]{MASSES}[$index_mz]{ENTRIES} }, \%entry) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1296 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1297 $check_rebond = 0 ; ## reinit double control
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1298 $index_entry++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1299 } ## end foreach
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1300 if ($check_noentry == 0 ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1301 my %entry = (
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1302 ENTRY_COLOR => $tbody_object->[$index_page]{MASSES}[$index_mz]{MZ_COLOR},
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1303 ENTRY_ENTRY_NAME => 'UNKNOWN',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1304 ENTRY_ENTRY_ID => 'NONE',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1305 ENTRY_ENTRY_ID2 => '',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1306 ENTRY_FORMULA => 'n/a',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1307 ENTRY_CPD_MZ => 'n/a',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1308 ENTRY_ADDUCT => 'n/a',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1309 ENTRY_ADDUCT_TYPE => 'n/a',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1310 ENTRY_ADDUCT_MZ => 'n/a',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1311 ENTRY_DELTA => 0,
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1312 ENTRY_ENTRY_INCHI => 'n/a',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1313 ENTRY_ENTRY_LOGP => 'n/a',
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1314 ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1315 push ( @{ $tbody_object->[$index_page]{MASSES}[$index_mz]{ENTRIES} }, \%entry) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1316 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1317 $index_mz ++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1318 $index_mz_continous ++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1319 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1320 $index_page++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1321 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1322 return($tbody_object) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1323 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1324 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1325
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1326 =head2 METHOD write_html_skel
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1327
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1328 ## Description : prepare and write the html output file
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1329 ## Input : $html_file_name, $html_object, $html_template
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1330 ## Output : $html_file_name
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1331 ## Usage : my ( $html_file_name ) = write_html_skel( $html_file_name, $html_object ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1332
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1333 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1334 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1335 sub write_html_skel {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1336 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1337 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1338 my ( $html_file_name, $html_object, $pages , $search_condition, $html_template, $js_path, $css_path ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1339
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1340 my $html_file = $$html_file_name ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1341
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1342 if ( defined $html_file ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1343 open ( HTML, ">$html_file" ) or die "Can't create the output file $html_file " ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1344
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1345 if (-e $html_template) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1346 my $ohtml = HTML::Template->new(filename => $html_template);
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1347 $ohtml->param( JS_GALAXY_PATH => $js_path, CSS_GALAXY_PATH => $css_path ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1348 $ohtml->param( CONDITIONS => $search_condition ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1349 $ohtml->param( PAGES_NB => $pages ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1350 $ohtml->param( PAGES => $html_object ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1351 print HTML $ohtml->output ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1352 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1353 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1354 croak "Can't fill any html output : No template available ($html_template)\n" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1355 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1356
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1357 close (HTML) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1358 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1359 else {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1360 croak "No output file name available to write HTML file\n" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1361 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1362 return(\$html_file) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1363 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1364 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1365
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1366 =head2 METHOD set_lm_matrix_object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1367
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1368 ## Description : build the hmdb_row under its ref form
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1369 ## Input : $header, $init_mzs, $entries
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1370 ## Output : $hmdb_matrix
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1371 ## Usage : my ( $hmdb_matrix ) = set_lm_matrix_object( $header, $init_mzs, $entries ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1372
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1373 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1374 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1375 sub set_lm_matrix_object {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1376 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1377 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1378 my ( $header, $init_mzs, $entries ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1379
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1380 my @hmdb_matrix = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1381
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1382 if ( defined $header ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1383 my @headers = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1384 push @headers, $header ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1385 push @hmdb_matrix, \@headers ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1386 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1387
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1388 my $index_mz = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1389
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1390 foreach my $mz ( @{$init_mzs} ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1391
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1392 my $index_entries = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1393 my @clusters = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1394 my $cluster_col = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1395
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1396 my @anti_redondant = ('N/A') ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1397 my $check_rebond = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1398
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1399 my $nb_entries = scalar (@{ $entries->[$index_mz] }) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1400
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1401 foreach my $entry (@{ $entries->[$index_mz] }) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1402
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1403 ## dispo anti doublons des entries
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1404 foreach my $rebond (@anti_redondant) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1405 if ( $rebond eq $entries->[$index_mz][$index_entries]{ENTRY_ENTRY_ID} ) { $check_rebond = 1 ; last ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1406 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1407
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1408 if ( $check_rebond == 0 ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1409
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1410 push ( @anti_redondant, $entries->[$index_mz][$index_entries]{ENTRY_ENTRY_ID} ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1411
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1412 my $delta = $entries->[$index_mz][$index_entries]{ENTRY_DELTA} ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1413 my $formula = $entries->[$index_mz][$index_entries]{ENTRY_FORMULA} ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1414 my $hmdb_id = $entries->[$index_mz][$index_entries]{ENTRY_ENTRY_ID} ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1415
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1416 ## METLIN data display model
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1417 ## entry1=VAR1::VAR2::VAR3::VAR4|entry2=VAR1::VAR2::VAR3::VAR4|...
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1418 # manage final pipe
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1419 if ($index_entries < $nb_entries-1 ) { $cluster_col .= $delta.'::('.$formula.')::'.$hmdb_id.'|' ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1420 else { $cluster_col .= $delta.'::('.$formula.')::'.$hmdb_id ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1421
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1422 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1423 $check_rebond = 0 ; ## reinit double control
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1424 $index_entries++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1425 } ## end foreach
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1426 if ( !defined $cluster_col ) { $cluster_col = 'NONE' ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1427 push (@clusters, $cluster_col) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1428 push (@hmdb_matrix, \@clusters) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1429 $index_mz++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1430 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1431 return(\@hmdb_matrix) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1432 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1433 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1434
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1435 =head2 METHOD set_hmdb_matrix_object_with_ids
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1436
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1437 ## Description : build the hmdb_row under its ref form (IDS only)
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1438 ## Input : $header, $init_mzs, $entries
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1439 ## Output : $hmdb_matrix
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1440 ## Usage : my ( $hmdb_matrix ) = set_hmdb_matrix_object_with_ids( $header, $init_mzs, $entries ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1441
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1442 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1443 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1444 sub set_hmdb_matrix_object_with_ids {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1445 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1446 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1447 my ( $header, $init_mzs, $entries ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1448
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1449 # print Dumper $entries ;
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1450
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1451 my @hmdb_matrix = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1452
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1453 if ( defined $header ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1454 my @headers = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1455
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1456 ## redefined the header hmdb(delta::name::mz::formula::adduct::id)
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1457 $header = 'hmdb(delta::name::mz::formula::adduct::id)' ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1458 push @headers, $header ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1459 push @hmdb_matrix, \@headers ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1460 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1461
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1462 my $index_mz = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1463
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1464 foreach my $mz ( @{$init_mzs} ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1465
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1466 my $index_entries = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1467 my @clusters = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1468 my $cluster_col = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1469
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1470 my @anti_redondant = ('N/A') ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1471 my $check_rebond = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1472
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1473 my $nb_entries = scalar (@{ $entries->[$index_mz] }) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1474
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1475 foreach my $entry (@{ $entries->[$index_mz] }) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1476
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1477 ## dispo anti doublons des entries
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1478 foreach my $rebond (@anti_redondant) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1479 if ( $rebond eq $entries->[$index_mz][$index_entries]{ENTRY_ENTRY_ID} ) { $check_rebond = 1 ; last ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1480 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1481
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1482 if ( $check_rebond == 0 ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1483
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1484 push ( @anti_redondant, $entries->[$index_mz][$index_entries]{ENTRY_ENTRY_ID} ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1485 ##
15
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1486
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1487 my ($hmdb_name, $hmdb_id, $hmdb_formula, $hmdb_cpd_mz, $hmdb_adduct, $hmdb_delta) = (undef, undef, undef, undef, undef, undef) ;
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1488
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1489 if ($entries->[$index_mz][$index_entries]{ENTRY_ENTRY_NAME} ) { $hmdb_name = $entries->[$index_mz][$index_entries]{ENTRY_ENTRY_NAME} ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1490 else { $hmdb_name = 'UNKNOWN' ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1491
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1492 if ($entries->[$index_mz][$index_entries]{ENTRY_ENTRY_ID} ) { $hmdb_id = $entries->[$index_mz][$index_entries]{ENTRY_ENTRY_ID} ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1493 else { $hmdb_id = 0 ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1494
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1495 if ($entries->[$index_mz][$index_entries]{ENTRY_FORMULA} ) { $hmdb_formula = $entries->[$index_mz][$index_entries]{ENTRY_FORMULA} ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1496 else { $hmdb_formula = 'N/A' ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1497
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1498 if ($entries->[$index_mz][$index_entries]{ENTRY_CPD_MZ} ) { $hmdb_cpd_mz = $entries->[$index_mz][$index_entries]{ENTRY_CPD_MZ} ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1499 else { $hmdb_cpd_mz = 'N/A' ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1500
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1501 if ($entries->[$index_mz][$index_entries]{ENTRY_ADDUCT} ) { $hmdb_adduct = $entries->[$index_mz][$index_entries]{ENTRY_ADDUCT} ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1502 else { $hmdb_adduct = 'N/A' ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1503
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1504 if ($entries->[$index_mz][$index_entries]{ENTRY_DELTA} ) { $hmdb_delta = $entries->[$index_mz][$index_entries]{ENTRY_DELTA} ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1505 else { $hmdb_delta = 0 ; }
beb9619263b0 Master branch Updating - - Fxx
fgiacomoni
parents: 14
diff changeset
1506
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1507
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1508 ## METLIN data display model
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1509 ## entry1= ENTRY_DELTA::ENTRY_ENTRY_NAME::ENTRY_CPD_MZ::ENTRY_FORMULA::ENTRY_ADDUCT::ENTRY_ENTRY_ID | entry2=VAR1::VAR2::VAR3::VAR4|...
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1510 my $entry = $hmdb_delta.'::['."$hmdb_name".']::'.$hmdb_cpd_mz.'::'.$hmdb_formula.'::['.$hmdb_adduct.']::'.$hmdb_id ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1511
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1512 # manage final pipe
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1513 if ($index_entries < $nb_entries-1 ) { $cluster_col .= $entry.' | ' ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1514 else { $cluster_col .= $entry ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1515
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1516 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1517 $check_rebond = 0 ; ## reinit double control
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1518 $index_entries++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1519 } ## end foreach
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1520 if ( !defined $cluster_col ) { $cluster_col = 'NONE' ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1521 push (@clusters, $cluster_col) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1522 push (@hmdb_matrix, \@clusters) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1523 $index_mz++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1524 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1525 return(\@hmdb_matrix) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1526 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1527 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1528
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1529 =head2 METHOD add_lm_matrix_to_input_matrix
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1530
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1531 ## Description : build a full matrix (input + lm column)
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1532 ## Input : $input_matrix_object, $lm_matrix_object, $nb_header
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1533 ## Output : $output_matrix_object
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1534 ## Usage : my ( $output_matrix_object ) = add_lm_matrix_to_input_matrix( $input_matrix_object, $lm_matrix_object, $nb_header ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1535
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1536 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1537 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1538 sub add_lm_matrix_to_input_matrix {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1539 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1540 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1541 my ( $input_matrix_object, $lm_matrix_object, $nb_header ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1542
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1543 my @output_matrix_object = () ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1544 my $index_row = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1545 my $line = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1546
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1547 foreach my $row ( @{$input_matrix_object} ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1548 my @init_row = @{$row} ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1549 $line++;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1550
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1551 if ( ( defined $nb_header ) and ( $line <= $nb_header) ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1552 push (@output_matrix_object, \@init_row) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1553 next ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1554 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1555
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1556 if ( $lm_matrix_object->[$index_row] ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1557 my $dim = scalar(@{$lm_matrix_object->[$index_row]}) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1558
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1559 if ($dim > 1) { warn "the add method can't manage more than one column\n" ;}
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1560 my $lm_col = $lm_matrix_object->[$index_row][$dim-1] ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1561
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1562 push (@init_row, $lm_col) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1563 $index_row++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1564 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1565 push (@output_matrix_object, \@init_row) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1566 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1567 return(\@output_matrix_object) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1568 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1569 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1570
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1571 =head2 METHOD write_csv_skel
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1572
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1573 ## Description : prepare and write csv output file
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1574 ## Input : $csv_file, $rows
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1575 ## Output : $csv_file
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1576 ## Usage : my ( $csv_file ) = write_csv_skel( $csv_file, $rows ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1577
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1578 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1579 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1580 sub write_csv_skel {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1581 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1582 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1583 my ( $csv_file, $rows ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1584
14
625fa968d99a Master branch Updating - - Fxx
fgiacomoni
parents: 9
diff changeset
1585 # my $ocsv = lib::csv::new( {is_binary => 1 , quote_binary => 0, quote_char => undef }) ;
625fa968d99a Master branch Updating - - Fxx
fgiacomoni
parents: 9
diff changeset
1586 my $ocsv = lib::csv::new() ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1587 my $csv = $ocsv->get_csv_object("\t") ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1588 $ocsv->write_csv_from_arrays($csv, $$csv_file, $rows) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1589
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1590 return($csv_file) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1591 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1592 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1593
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1594 =head2 METHOD write_csv_one_mass
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1595
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1596 ## Description : print a cvs file
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1597 ## Input : $masses, $ids, $results, $file
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1598 ## Output : N/A
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1599 ## Usage : write_csv_one_mass( $ids, $results, $file ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1600
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1601 =cut
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1602 ## START of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1603 sub write_csv_one_mass {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1604 ## Retrieve Values
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1605 my $self = shift ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1606 my ( $masses, $ids, $results, $file, ) = @_ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1607
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1608 open(CSV, '>:utf8', "$file") or die "Cant' create the file $file\n" ;
14
625fa968d99a Master branch Updating - - Fxx
fgiacomoni
parents: 9
diff changeset
1609 print CSV "ID\tQuery(Da)\tDelta(ppm)\tMetabolite_Name\tCpd_MW(Da)\tFormula\tAdduct\tAdduct_MW(Da)\tHMDB_ID\n" ;
1
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1610
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1611 my $i = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1612
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1613 foreach my $id (@{$ids}) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1614 my $mass = undef ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1615 if ( $masses->[$i] ) { $mass = $masses->[$i] ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1616 else { last ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1617
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1618 if ( $results->[$i] ) { ## an requested id has a result in the list of hashes $results.
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1619
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1620 my @anti_redondant = ('N/A') ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1621 my $check_rebond = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1622 my $check_noentry = 0 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1623
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1624 foreach my $entry (@{$results->[$i]}) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1625 $check_noentry ++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1626 ## dispo anti doublons des entries
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1627 foreach my $rebond (@anti_redondant) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1628 if ( $rebond eq $entry->{ENTRY_ENTRY_ID} ) { $check_rebond = 1 ; last ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1629 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1630 # print "\n-----------------------" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1631 # print Dumper $entry->{ENTRY_ENTRY_ID} ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1632 # print "-------------------------$check_rebond\n" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1633 # print Dumper @anti_redondant ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1634 if ( $check_rebond == 0 ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1635
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1636 push ( @anti_redondant, $entry->{ENTRY_ENTRY_ID} ) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1637
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1638 print CSV "$id\t$mass\t" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1639
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1640 ## print delta
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1641 if ( $entry->{ENTRY_DELTA} ) { print CSV "$entry->{ENTRY_DELTA}\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1642 else { print CSV "0\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1643
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1644 ## print cpd name
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1645 if ( $entry->{ENTRY_ENTRY_NAME} ) { print CSV "[$entry->{ENTRY_ENTRY_NAME}]\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1646 else { print CSV "UNKNOWN\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1647
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1648 ## print cpd mz
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1649 if ( $entry->{ENTRY_CPD_MZ} ) { print CSV "$entry->{ENTRY_CPD_MZ}\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1650 else { print CSV "N/A\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1651
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1652 ## print cpd formula
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1653 if ( $entry->{ENTRY_FORMULA} ) { print CSV "$entry->{ENTRY_FORMULA}\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1654 else { print CSV "N/A\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1655
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1656 ## print adduct
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1657 if ( $entry->{ENTRY_ADDUCT} ) { print CSV "[$entry->{ENTRY_ADDUCT}]\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1658 else { print CSV "N/A\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1659
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1660 ## print adduct mz
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1661 if ( $entry->{ENTRY_ADDUCT_MZ} ) { print CSV "$entry->{ENTRY_ADDUCT_MZ}\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1662 else { print CSV "N/A\t" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1663
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1664 ## print cpd id
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1665 if ( $entry->{ENTRY_ENTRY_ID} ) { print CSV "$entry->{ENTRY_ENTRY_ID}\n" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1666 else { print CSV "N/A\n" ; }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1667 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1668 $check_rebond = 0 ; ## reinit double control
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1669 } ## end foreach
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1670 if ($check_noentry == 0 ) {
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1671 print CSV "$id\t$mass\t0\tUNKNOWN\tN/A\tN/A\tN/A\tN/A\tN/A\n" ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1672 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1673 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1674 $i++ ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1675 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1676 close(CSV) ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1677 return() ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1678 }
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1679 ## END of SUB
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1680
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1681 1 ;
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1682
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1683
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1684 __END__
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1685
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1686 =head1 SUPPORT
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1687
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1688 You can find documentation for this module with the perldoc command.
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1689
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1690 perldoc hmdb.pm
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1691
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1692 =head1 Exports
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1693
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1694 =over 4
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1695
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1696 =item :ALL is ...
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1697
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1698 =back
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1699
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1700 =head1 AUTHOR
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1701
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1702 Franck Giacomoni E<lt>franck.giacomoni@clermont.inra.frE<gt>
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1703
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1704 =head1 LICENSE
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1705
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1706 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1707
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1708 =head1 VERSION
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1709
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1710 version 1 : 06 / 06 / 2013
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1711
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1712 version 2 : 27 / 01 / 2014
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1713
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1714 version 3 : 19 / 11 / 2014
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1715
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1716 version 4 : 28 / 01 / 2016
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1717
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1718 version 5 : 02 / 11 /2016
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1719
6d0a0f8f672a planemo upload commit f67323ae4fa7fdbd9f4518ede105a7d7cd44b471
fgiacomoni
parents:
diff changeset
1720 =cut