Mercurial > repos > fgiacomoni > massbank_ws_searchspectrum
annotate t/lib/massbank_api_Test.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::massbank_api_Test ; |
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 diagnostics; # this gives you more debugging information |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
4 use warnings; # this warns you of bad practices |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
5 use strict; # this prevents silly errors |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
6 use Exporter ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
7 use Carp ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
8 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
9 use Data::Dumper ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
10 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
11 our $VERSION = "1.0"; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
12 our @ISA = qw(Exporter); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
13 our @EXPORT = qw( initRecordObjectTest threading_methods_getRecordInfoTest connectMassBankTest connectMassBankJPTest connectMassBankDETest getInstrumentTypesTest getRecordInfoTest searchSpectrumTest searchSpectrumNBTest getPeakTest); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
14 our %EXPORT_TAGS = ( ALL => [qw( initRecordObjectTest threading_methods_getRecordInfoTest connectMassBankTest connectMassBankJPTest connectMassBankDETest getInstrumentTypesTest getRecordInfoTest searchSpectrumTest searchSpectrumNBTest getPeakTest)] ); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
15 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
16 use lib '/Users/fgiacomoni/Inra/labs/perl/galaxy_tools/massbank_ws_searchspectrum' ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
17 use lib::massbank_api qw( :ALL ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
18 use lib::threader qw( :ALL ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
19 use lib::mapper qw( :ALL ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
20 |
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 my $server = 'JP' ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
23 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
24 sub connectMassBankTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
25 my ($uri, $proxy) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
26 my $oBih = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
27 my ($soap) = $oBih->connectMassBank($uri, $proxy) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
28 return ($soap) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
29 } |
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 sub connectMassBankJPTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
32 my $oBih = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
33 my ($soap) = $oBih->connectMassBankJP() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
34 return ($soap) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
35 } |
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 sub connectMassBankDETest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
38 my $oBih = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
39 my ($soap) = $oBih->connectMassBankDE() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
40 return ($soap) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
41 } |
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 sub getInstrumentTypesTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
44 my ($server) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
45 my $osoap = undef ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
46 my $oBih = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
47 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
48 if ($server eq 'JP') { ($osoap) = $oBih->connectMassBankJP() ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
49 elsif ($server eq 'EU') { ($osoap) = $oBih->connectMassBankDE() ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
50 else { croak "Can't call an unknown server through MassBank API\n" ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
51 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
52 my $res = $oBih->getInstrumentTypes($osoap) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
53 return ($res) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
54 } |
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 getRecordInfoTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
57 my ($server, $ids) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
58 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
59 my $oBih = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
60 my ($osoap) = $oBih->selectMassBank($server) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
61 my ($res) = $oBih->getRecordInfo($osoap, $ids) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
62 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
63 return($res) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
64 } |
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 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
67 sub searchSpectrumTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
68 my ($mzs, $intensities, $ion, $instruments, $max, $unit, $tol, $cutoff) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
69 my $pcgroup_id = 1 ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
70 my $oBih = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
71 my ($osoap) = $oBih->selectMassBank($server) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
72 my ($res, $num) = $oBih->searchSpectrum($osoap, $pcgroup_id, $mzs, $intensities, $ion, $instruments, $max, $unit, $tol, $cutoff) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
73 print Dumper $res ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
74 return($res) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
75 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
76 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
77 sub searchSpectrumNBTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
78 my ($mzs, $intensities, $ion, $instruments, $max, $unit, $tol, $cutoff) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
79 my $pcgroup_id = 1 ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
80 my $oBih = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
81 my ($osoap) = $oBih->selectMassBank($server) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
82 my ($res, $num) = $oBih->searchSpectrum($osoap, $pcgroup_id, $mzs, $intensities, $ion, $instruments, $max, $unit, $tol, $cutoff) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
83 return($num) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
84 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
85 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
86 sub getPeakTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
87 my ($ids) = @_ ; |
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 my $oBih = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
90 my ($osoap) = $oBih->selectMassBank($server) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
91 my ($res) = $oBih->getPeak($osoap, $ids) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
92 return($res) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
93 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
94 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
95 sub threading_methods_getRecordInfoTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
96 my ($ids) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
97 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
98 my $results = undef ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
99 my $othreads = lib::threader->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
100 my $oquery = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
101 my ($osoap) = $oquery->selectMassBank($server) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
102 $results = $othreads->threading_getRecordInfo($osoap, $ids) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
103 return($results) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
104 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
105 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
106 ## SUB TEST for initRecordObject |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
107 sub initRecordObjectTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
108 # get values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
109 my ( $string ) = @_; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
110 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
111 my $omassbank = lib::massbank_api->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
112 my $record = $omassbank->initRecordObject($string) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
113 # print Dumper $record ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
114 return($record) ; |
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 ## End SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
117 |
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 1 ; |