Mercurial > repos > fgiacomoni > massbank_ws_searchspectrum
annotate t/lib/massbank_mapper_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_mapper_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( max_from_double_with_deltaTest min_from_double_with_deltaTest get_massbank_records_by_chunkTest compute_ids_from_pcgroups_resTest filter_pcgroup_resTest get_pcgroup_listTest get_pcgroupsTest set_massbank_matrix_objectTest add_massbank_matrix_to_input_matrixTest); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
14 our %EXPORT_TAGS = ( ALL => [qw(max_from_double_with_deltaTest min_from_double_with_deltaTest get_massbank_records_by_chunkTest compute_ids_from_pcgroups_resTest filter_pcgroup_resTest get_pcgroup_listTest get_pcgroupsTest set_massbank_matrix_objectTest add_massbank_matrix_to_input_matrixTest)] ); |
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::mapper qw( :ALL ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
18 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
19 sub get_pcgroupsTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
20 my ( $pcs, $mzs, $ints ) = @_; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
21 my $omap = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
22 my $pcgroups = $omap->get_pcgroups($pcs, $mzs, $ints) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
23 # print Dumper $pcgroups ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
24 return ($pcgroups) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
25 } |
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 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
28 sub get_pcgroup_listTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
29 my ($pcs) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
30 my $omap = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
31 my $pcgroup_list = $omap->get_pcgroup_list($pcs) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
32 # print Dumper $pcgroup_list ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
33 return ($pcgroup_list) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
34 } |
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 sub set_massbank_matrix_objectTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
37 my ($header, $init_pcs, $pcgroups) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
38 my $omap = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
39 my $matrix = $omap->set_massbank_matrix_object($header, $init_pcs, $pcgroups) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
40 # print Dumper $matrix ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
41 return ($matrix) ; |
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 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
44 sub add_massbank_matrix_to_input_matrixTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
45 my ($input_matrix_object, $massbank_matrix_object ) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
46 my $omap = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
47 my $matrix = $omap->add_massbank_matrix_to_input_matrix($input_matrix_object, $massbank_matrix_object ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
48 # print Dumper $matrix ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
49 return ($matrix) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
50 } |
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 ## SUB TEST for filter_pcgroup_res |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
53 sub filter_pcgroup_resTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
54 # get values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
55 my ( $pcgroups, $threshold ) = @_; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
56 my $cleaned_pcgroups = () ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
57 |
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 $omap = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
60 $cleaned_pcgroups = $omap->filter_pcgroup_res($pcgroups, $threshold) ; |
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 return($cleaned_pcgroups) ; |
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 ## End SUB |
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 ## SUB TEST for |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
67 sub compute_ids_from_pcgroups_resTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
68 # get values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
69 my ( $pcgroups ) = @_; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
70 my $ids = () ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
71 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
72 my $var2 = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
73 $ids = $var2->compute_ids_from_pcgroups_res($pcgroups) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
74 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
75 return($ids) ; |
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 ## End SUB |
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 ## ## SUB TEST for |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
80 sub min_from_double_with_deltaTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
81 # get values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
82 my ( $double, $type, $delta ) = @_; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
83 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
84 my $var2 = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
85 my ($min, $max) = $var2->min_and_max_from_double_with_delta($double, $type, $delta) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
86 # print $min ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
87 return($min) ; |
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 ## End SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
90 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
91 ## ## SUB TEST for |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
92 sub max_from_double_with_deltaTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
93 # get values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
94 my ( $double, $type, $delta ) = @_; |
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 my $var2 = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
97 my ($min, $max) = $var2->min_and_max_from_double_with_delta($double, $type, $delta) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
98 # print $max ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
99 return($max) ; |
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 ## End SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
102 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
103 ## SUB TEST for |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
104 sub get_massbank_records_by_chunkTest { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
105 # get values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
106 my ( $server, $ids, $chunk_size ) = @_; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
107 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
108 my $var2 = lib::mapper->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
109 my $records = $var2->get_massbank_records_by_chunk ($server, $ids, $chunk_size) ; |
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 # print Dumper $records ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
112 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
113 return($records) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
114 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
115 ## End SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
116 |
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 1 ; |