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