annotate t/lib/bihTest.pm @ 0:be582bcd6585 draft

Master branch Updating - - Fxx
author fgiacomoni
date Thu, 04 Oct 2018 10:37:14 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
1 package lib::bihTest ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
2
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
3 use diagnostics; # this gives you more debugging information
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
4 use warnings; # this warns you of bad practices
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
5 use strict; # this prevents silly errors
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
6 use Exporter ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
7 use Carp ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
8 use Data::Dumper ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
9
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
10 our $VERSION = "1.0";
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
11 our @ISA = qw(Exporter);
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
12 our @EXPORT = qw( map_pfjson_bankobject_Test parse_bank_interest_Test db_pforest_get_clean_range_Test check_interval_Test format_manual_list_values_Testvalues format_manual_list_values_Testids manage_mode_TestvalH manage_mode_Testionization mz_delta_conversion_Testmin mz_delta_conversion_Testmax dichotomi_search_Test );
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
13 our %EXPORT_TAGS = ( ALL => [qw( map_pfjson_bankobject_Test parse_bank_interest_Test db_pforest_get_clean_range_Test check_interval_Test format_manual_list_values_Testvalues format_manual_list_values_Testids manage_mode_TestvalH manage_mode_Testionization mz_delta_conversion_Testmin mz_delta_conversion_Testmax dichotomi_search_Test )] );
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
14
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
15 use lib '/Users/fgiacomoni/Inra/labs/perl/galaxy_tools/tool-bank_inhouse' ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
16 use lib::bih qw( :ALL ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
17 use lib::json qw( :ALL ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
18 use lib::csv qw( :ALL ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
19
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
20 sub check_interval_Test {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
21 my ( $value, $min, $max ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
22 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
23 my ($message) = $oBih->check_interval($value, $min, $max) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
24 return($message) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
25 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
26
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
27 sub format_manual_list_values_Testvalues {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
28 my ( $value, $sep ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
29 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
30 my ($values, $ids) = $oBih->format_manual_list_values($value, $sep) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
31 return ($values) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
32 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
33
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
34 sub format_manual_list_values_Testids {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
35 my ( $value, $sep ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
36 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
37 my ($values, $ids) = $oBih->format_manual_list_values($value, $sep) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
38 return ($ids) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
39 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
40
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
41 sub mz_delta_conversion_Testmin {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
42 my ( $mass, $delta_type, $mz_delta ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
43 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
44 my ($min, $max) = $oBih->mz_delta_conversion(\$mass, \$delta_type, \$mz_delta) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
45 return($$min) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
46 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
47
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
48 sub mz_delta_conversion_Testmax {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
49 my ( $mass, $delta_type, $mz_delta ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
50 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
51 my ($min, $max) = $oBih->mz_delta_conversion(\$mass, \$delta_type, \$mz_delta) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
52 return($$max) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
53 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
54
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
55 sub dichotomi_search_Test {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
56 my ( $tab, $search ) = @_ ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
57 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
58 my ($position) = $oBih->dichotomi_search($tab, \$search) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
59 return($$position) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
60 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
61
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
62 ## SUB TEST for
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
63 sub db_pforest_get_clean_range_Test {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
64 # get values
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
65 my ( $host, $query, $min, $max, $mode ) = @_;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
66 my $json = undef ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
67
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
68 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
69 $json = $oBih->db_pforest_get_clean_range($host, $query, $min, $max, $mode ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
70
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
71 return($json) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
72 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
73 ## End SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
74
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
75 ## SUB TEST for
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
76 sub parse_bank_interest_Test {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
77 # get values
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
78 my ( $file, $col_interest ) = @_;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
79
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
80 my $ocsv_input = lib::csv->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
81 my $ocsv = $ocsv_input->get_csv_object( "\t" ) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
82
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
83 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
84 my ($bank, $bank_header) = $oBih->parse_bank_interest($ocsv, \$file, $col_interest) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
85
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
86 # print Dumper $bank ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
87
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
88 return($bank) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
89 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
90 ## End SUB
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
91
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
92
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
93 sub map_pfjson_bankobject_Test {
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
94 # get values
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
95 my ( $json ) = @_;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
96
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
97 my ($bank, $headers) = (undef, undef) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
98
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
99 my $oBih = lib::bih->new() ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
100 ($bank, $headers) = $oBih->map_pfjson_bankobject($json) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
101 # print Dumper $headers ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
102 return($bank, $headers) ;
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
103 }
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
104
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
105
be582bcd6585 Master branch Updating - - Fxx
fgiacomoni
parents:
diff changeset
106 1 ;