Mercurial > repos > fgiacomoni > golm_ws_lib_search
comparison t/lib/golm_ws_api_test.pm @ 0:e3d43b8c987b draft
Init repository with last tool-bank-golm-lib_search master version
| author | fgiacomoni |
|---|---|
| date | Mon, 05 Dec 2016 08:32:04 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:e3d43b8c987b |
|---|---|
| 1 package lib::golm_ws_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( keep_only_max_massesTest keep_only_max_intensitiesTest test_query_golmTest connectWSlibrarySearchGolmTest LibrarySearchTest encode_spectrum_for_queryTest get_mzsTest get_intensitiesTest get_masses_from_stringTest get_intensities_from_stringTest sorting_descending_intensities1Test sorting_descending_intensities2Test remove_redundants1Test remove_redundants2Test filter_scores_golm_resultsTest filter_replica_resultsTest apply_relative_intensityTest); | |
| 14 our %EXPORT_TAGS = ( ALL => [qw( keep_only_max_massesTest keep_only_max_intensitiesTest test_query_golmTest connectWSlibrarySearchGolmTest LibrarySearchTest encode_spectrum_for_queryTest get_mzsTest get_intensitiesTest get_masses_from_stringTest get_intensities_from_stringTest sorting_descending_intensities1Test sorting_descending_intensities2Test remove_redundants1Test remove_redundants2Test filter_scores_golm_resultsTest filter_replica_resultsTest apply_relative_intensityTest)] ); | |
| 15 | |
| 16 | |
| 17 use lib::golm_ws_api qw( :ALL ) ; | |
| 18 use lib::msp qw( :ALL ) ; | |
| 19 use lib::output qw( :ALL ) ; | |
| 20 | |
| 21 ### Test API module ### | |
| 22 | |
| 23 sub test_query_golmTest { | |
| 24 my ($ws_url, $ws_proxy) = @_; | |
| 25 my $oBih = lib::golm_ws_api->new() ; | |
| 26 my ($status) = $oBih->test_query_golm($ws_url, $ws_proxy) ; | |
| 27 return ($status) ; | |
| 28 } | |
| 29 | |
| 30 | |
| 31 sub connectWSlibrarySearchGolmTest { | |
| 32 my ($ws_url, $ws_proxy) = @_ ; | |
| 33 my $oBih = lib::golm_ws_api->new() ; | |
| 34 my ($soap) = $oBih->connectWSlibrarySearchGolm($ws_url, $ws_proxy) ; | |
| 35 return ($soap) ; | |
| 36 } | |
| 37 | |
| 38 | |
| 39 sub LibrarySearchTest { | |
| 40 my ($ri, $riWindow, $gcColumn, $spectrum, $maxHits, $JaccardDistanceThreshold, | |
| 41 $s12GowerLegendreDistanceThreshold,$DotproductDistanceThreshold,$HammingDistanceThreshold, | |
| 42 $EuclideanDistanceThreshold,$ws_url, $ws_proxy,$default_ri, $default_ri_window, $default_gc_column) = @_ ; | |
| 43 my $oBih = lib::golm_ws_api->new() ; | |
| 44 my ($limited_hits) =$oBih->LibrarySearch($ri, $riWindow, $gcColumn, $spectrum, $maxHits, $JaccardDistanceThreshold, | |
| 45 $s12GowerLegendreDistanceThreshold,$DotproductDistanceThreshold,$HammingDistanceThreshold, | |
| 46 $EuclideanDistanceThreshold,$ws_url, $ws_proxy,$default_ri, $default_ri_window, $default_gc_column) ; | |
| 47 return ($limited_hits) ; | |
| 48 } | |
| 49 | |
| 50 | |
| 51 sub filter_scores_golm_resultsTest { | |
| 52 my ($results,$JaccardDistanceThreshold,$s12GowerLegendreDistanceThreshold, | |
| 53 $DotproductDistanceThreshold,$HammingDistanceThreshold,$EuclideanDistanceThreshold) = @_ ; | |
| 54 my $oBih = lib::golm_ws_api->new() ; | |
| 55 my ($filtered_res_before_hits_limited) = $oBih->filter_scores_golm_results($results,$JaccardDistanceThreshold,$s12GowerLegendreDistanceThreshold, | |
| 56 $DotproductDistanceThreshold,$HammingDistanceThreshold,$EuclideanDistanceThreshold) ; | |
| 57 return ($filtered_res_before_hits_limited) ; | |
| 58 } | |
| 59 | |
| 60 | |
| 61 sub filter_replica_resultsTest { | |
| 62 my ($results) = @_ ; | |
| 63 my $oBih = lib::golm_ws_api->new() ; | |
| 64 my ($sortAnalytes) = $oBih->filter_replica_results($results) ; | |
| 65 return ($sortAnalytes) ; | |
| 66 } | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 ### Test MSP module ### | |
| 72 | |
| 73 sub get_mzsTest { | |
| 74 my ($inputSpectra, $mzRes) = @_; | |
| 75 my $omsp = lib::msp->new(); | |
| 76 my $mzs = $omsp->get_mzs ($inputSpectra, $mzRes) ; | |
| 77 return($mzs) ; | |
| 78 } | |
| 79 | |
| 80 | |
| 81 sub get_intensitiesTest { | |
| 82 my ($inputSpectra) = @_; | |
| 83 my $omsp = lib::msp->new(); | |
| 84 my $intensities = $omsp->get_intensities($inputSpectra) ; | |
| 85 return($intensities) ; | |
| 86 } | |
| 87 | |
| 88 | |
| 89 sub get_masses_from_stringTest { | |
| 90 my ($inputSpectra, $mzRes) = @_; | |
| 91 my $omsp = lib::msp->new(); | |
| 92 my ($ref_mzs_res) = $omsp->get_masses_from_string($inputSpectra, $mzRes) ; | |
| 93 return($ref_mzs_res) ; | |
| 94 } | |
| 95 | |
| 96 | |
| 97 sub get_intensities_from_stringTest { | |
| 98 my ($inputSpectra) = @_; | |
| 99 my $omsp = lib::msp->new(); | |
| 100 my ($ref_ints_res) = $omsp->get_intensities_from_string($inputSpectra) ; | |
| 101 return($ref_ints_res) ; | |
| 102 } | |
| 103 | |
| 104 | |
| 105 sub keep_only_max_massesTest { | |
| 106 my ($ref_mzs_res, $maxIons) = @_; | |
| 107 my $omsp = lib::msp->new(); | |
| 108 my ($mzs_res_sorted) = $omsp->keep_only_max_masses($ref_mzs_res, $maxIons) ; | |
| 109 return($mzs_res_sorted) ; | |
| 110 } | |
| 111 | |
| 112 | |
| 113 sub keep_only_max_intensitiesTest { | |
| 114 my ($ref_ints_res, $maxIons) = @_; | |
| 115 my $omsp = lib::msp->new(); | |
| 116 my ($ints_res_sorted) = $omsp->keep_only_max_intensities($ref_ints_res, $maxIons) ; | |
| 117 return($ints_res_sorted) ; | |
| 118 } | |
| 119 | |
| 120 | |
| 121 sub sorting_descending_intensities1Test { | |
| 122 my ($uniq_total_masses, $uniq_total_intensities) = @_; | |
| 123 my $omsp = lib::msp->new(); | |
| 124 my ($mzs_res_sorted, $ints_res_sorted) = $omsp->sorting_descending_intensities($uniq_total_masses, $uniq_total_intensities) ; | |
| 125 return($mzs_res_sorted) ; | |
| 126 } | |
| 127 | |
| 128 | |
| 129 sub sorting_descending_intensities2Test { | |
| 130 my ($uniq_total_masses, $uniq_total_intensities) = @_; | |
| 131 my $omsp = lib::msp->new(); | |
| 132 my ($mzs_res_sorted, $ints_res_sorted) = $omsp->sorting_descending_intensities($uniq_total_masses, $uniq_total_intensities) ; | |
| 133 return($ints_res_sorted) ; | |
| 134 } | |
| 135 | |
| 136 | |
| 137 sub encode_spectrum_for_queryTest { | |
| 138 my ($mzs_res_sorted, $relative_ints_res) = @_; | |
| 139 my $omsp = lib::msp->new(); | |
| 140 my $encoded_spectra = $omsp->encode_spectrum_for_query($mzs_res_sorted, $relative_ints_res) ; | |
| 141 return ($encoded_spectra) ; | |
| 142 } | |
| 143 | |
| 144 | |
| 145 sub remove_redundants1Test { | |
| 146 my ($ref_mzs_res, $ref_ints_res) = @_; | |
| 147 my $omsp = lib::msp->new(); | |
| 148 my ($uniq_masses , $uniq_intensities) = $omsp->remove_redundants($ref_mzs_res, $ref_ints_res, $ref_mzs_res, $ref_ints_res) ; | |
| 149 return ($uniq_masses ) ; | |
| 150 } | |
| 151 | |
| 152 | |
| 153 sub remove_redundants2Test { | |
| 154 my ($ref_mzs_res, $ref_ints_res) = @_; | |
| 155 my $omsp = lib::msp->new(); | |
| 156 my ($uniq_masses , $uniq_intensities) = $omsp->remove_redundants($ref_mzs_res, $ref_ints_res, $ref_mzs_res, $ref_ints_res) ; | |
| 157 return ($uniq_intensities) ; | |
| 158 } | |
| 159 | |
| 160 | |
| 161 sub apply_relative_intensityTest { | |
| 162 my ($uniq_total_intensities) = @_; | |
| 163 my $omsp = lib::msp->new(); | |
| 164 my ($relative_ints_res) = $omsp->apply_relative_intensity($uniq_total_intensities) ; | |
| 165 return ($relative_ints_res) ; | |
| 166 } | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 1 ; |
