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