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