Mercurial > repos > fgiacomoni > massbank_ws_searchspectrum
annotate lib/threader.pm @ 0:023c380900ef draft default tip
Init repository with last massbank_ws_searchspectrum master version
author | fgiacomoni |
---|---|
date | Wed, 19 Apr 2017 11:31:58 -0400 |
parents | |
children |
rev | line source |
---|---|
0
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
1 package lib::threader ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
2 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
3 use strict; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
4 use warnings ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
5 use Exporter ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
6 use Carp ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
7 use threads; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
8 use threads::shared; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
9 use Thread::Queue; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
10 use diagnostics ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
11 use Data::Dumper ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
12 use Carp qw (cluck croak carp) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
13 use LWP::UserAgent; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
14 use LWP::Simple ; ## Lib de protocole HTTP de download |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
15 use SOAP::Lite + trace => qw(fault); ## SOAP for web service version 0.67 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
16 import SOAP::Data qw(name); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
17 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
18 use Data::Dumper ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
19 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
20 use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
21 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
22 our $VERSION = "1.0"; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
23 our @ISA = qw(Exporter); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
24 our @EXPORT = qw(threading_getRecordInfo); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
25 our %EXPORT_TAGS = ( ALL => [qw(threading_getRecordInfo )] ); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
26 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
27 =head1 NAME |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
28 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
29 My::Module - An example module |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
30 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
31 =head1 SYNOPSIS |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
32 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
33 use My::Module; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
34 my $object = My::Module->new(); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
35 print $object->as_string; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
36 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
37 =head1 DESCRIPTION |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
38 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
39 This module does not really exist, it |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
40 was made for the sole purpose of |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
41 demonstrating how POD works. |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
42 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
43 =head1 METHODS |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
44 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
45 Methods are : |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
46 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
47 =head2 METHOD new |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
48 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
49 ## Description : new |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
50 ## Input : $self |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
51 ## Ouput : bless $self ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
52 ## Usage : new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
53 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
54 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
55 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
56 sub new { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
57 ## Variables |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
58 my $self={}; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
59 bless($self) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
60 return $self ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
61 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
62 ### END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
63 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
64 =head2 METHOD searchSpectrumWorker |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
65 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
66 ## Description : work with searchSpectrum method in threading mode |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
67 ## Input : $Qworks |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
68 ## Output : $results |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
69 ## Usage : my ( $results ) = searchSpectrumWorker( $Qworks ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
70 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
71 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
72 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
73 sub searchSpectrumWorker { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
74 my $self = shift; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
75 my ($Qworks, $server, $ion_mode, $instruments, $max, $unit, $tol, $cutoff) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
76 my @results = () ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
77 my @fake = () ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
78 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
79 my $omassbank = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
80 my $soap = $omassbank->selectMassBank($server) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
81 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
82 while(my $pcgroup = $Qworks->dequeue) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
83 # print Dumper $pcgroup ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
84 my $oquery= lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
85 my ($result, $num) = eval{$oquery->searchSpectrum($soap, $pcgroup->{'id'}, $pcgroup->{'mzmed'}, $pcgroup->{'into'}, $ion_mode, $instruments, $max, $unit, $tol, $cutoff) ; } or die; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
86 # print "The query send to massbank return $num entries...\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
87 # print Dumper $result ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
88 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
89 if (!defined $num) { $num = 0 ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
90 if ($num >= 0 ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
91 push @results, $result ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
92 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
93 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
94 push @fake, $pcgroup ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
95 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
96 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
97 return (@results) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
98 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
99 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
100 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
101 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
102 =head2 METHOD threading_getRecordInfo |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
103 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
104 ## Description : prepare parallel threads - DEPRECATED |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
105 ## Input : $soap, $list |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
106 ## Output : $results |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
107 ## Usage : my ( $results ) = threading_getRecordInfo( $soap, $list ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
108 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
109 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
110 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
111 sub threading_getRecordInfo { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
112 ## Retrieve Values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
113 my $self = shift ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
114 my ( $osoap, $list ) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
115 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
116 my @results = () ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
117 my $i = 0 ; # position in the ids list |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
118 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
119 if ( ( defined $list ) ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
120 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
121 my $oquery = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
122 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
123 for (my $i = 0; $i < (scalar @{$list}); $i++ ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
124 my $thr = threads->create( sub { $oquery->getRecordInfo($osoap, $list->[$i]) } ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
125 push ( @results, $thr->join ) if $list->[$i] ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
126 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
127 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
128 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
129 warn "Your input list of ids is undefined\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
130 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
131 return(\@results) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
132 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
133 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
134 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
135 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
136 =head2 METHOD threading_searchSpectrum |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
137 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
138 ## Description : prepare parallel threads - DEPRECATED |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
139 ## Input : $soap, |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
140 ## Output : $results |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
141 ## Usage : my ( $results ) = threading_searchSpectrum( $soap, ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
142 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
143 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
144 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
145 sub threading_searchSpectrum { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
146 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
147 ## http://www.perlmonks.org/?node_id=735923 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
148 ## http://www.nntp.perl.org/group/perl.ithreads/2003/05/msg696.html |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
149 ## http://stackoverflow.com/questions/15222480/web-service-using-perl-wsdl-and-multi-threading-does-not-working |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
150 ## Retrieve Values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
151 my $self = shift ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
152 my ( $osoap, $pcgroup_list, $pcgroups, $ion_mode, $instruments, $max, $unit, $tol, $cutoff ) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
153 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
154 my @results = () ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
155 my $n = 6 ; # position in the ids list |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
156 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
157 if ( ( defined $pcgroups ) ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
158 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
159 print Dumper $pcgroups ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
160 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
161 my $oquery = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
162 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
163 foreach my $pc (@{$pcgroup_list}) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
164 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
165 print "\t---> Create a thread for pcgroup n-$pc\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
166 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
167 my $thr = threads->create( |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
168 sub { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
169 $oquery->searchSpectrum($osoap, $pcgroups->{$pc}{'mzmed'}, $pcgroups->{$pc}{'into'}, $ion_mode, $instruments, $max, $unit, $tol, $cutoff) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
170 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
171 ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
172 push ( @results, $thr->join ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
173 } ## end foreach |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
174 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
175 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
176 warn "Your input list of ids is undefined\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
177 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
178 return(\@results) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
179 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
180 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
181 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
182 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
183 =head2 METHOD thread_and_queue_searchSpectrum |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
184 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
185 ## Description : prepare parallel and queuing threads - DEPRECATED |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
186 ## Input : $soap, |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
187 ## Output : $results |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
188 ## Usage : my ( $results ) = thread_and_queue_searchSpectrum( $soap, ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
189 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
190 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
191 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
192 sub thread_and_queue_searchSpectrum { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
193 # my $self = shift; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
194 # my ( ) = @_; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
195 # |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
196 # our $THREADS = 10; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
197 # my $Qwork = new Thread::Queue; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
198 # my $Qresults = new Thread::Queue; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
199 # |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
200 # ## Create the pool of workers |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
201 # my @pool = map{ |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
202 # threads->create( \&worker, $Qwork, $Qresults ) |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
203 # } 1 .. $THREADS; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
204 # |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
205 # ## Get the work items (from somewhere) |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
206 # ## and queue them up for the workers |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
207 # while( my $workItem = getWorkItems() ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
208 # $Qwork->enqueue( $workItem ); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
209 # } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
210 # |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
211 # ## Tell the workers there are no more work items |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
212 # $Qwork->enqueue( (undef) x $THREADS ); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
213 # |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
214 # ## Process the results as they become available |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
215 # ## until all the workers say they are finished. |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
216 # for ( 1 .. $THREADS ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
217 # while( my $result = $Qresults->dequeue ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
218 # |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
219 # ## Do something with the result ## |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
220 # print $result; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
221 # } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
222 # } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
223 # |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
224 # ## Clean up the threads |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
225 # $_->join for @pool; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
226 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
227 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
228 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
229 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
230 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
231 1 ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
232 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
233 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
234 __END__ |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
235 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
236 =head1 SUPPORT |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
237 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
238 You can find documentation for this module with the perldoc command. |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
239 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
240 perldoc XXX.pm |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
241 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
242 =head1 Exports |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
243 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
244 =over 4 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
245 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
246 =item :ALL is ... |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
247 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
248 =back |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
249 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
250 =head1 AUTHOR |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
251 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
252 Franck Giacomoni E<lt>franck.giacomoni@clermont.inra.frE<gt> |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
253 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
254 =head1 LICENSE |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
255 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
256 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
257 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
258 =head1 VERSION |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
259 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
260 version 1 : xx / xx / 201x |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
261 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
262 version 2 : ?? |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
263 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
264 =cut |