view t/wsdl_lmTest.t @ 2:1276908e8fc4 draft

Master branch Updating - - Fxx
author fgiacomoni
date Mon, 20 Aug 2018 09:17:05 -0400
parents e8bd49794291
children
line wrap: on
line source

#! perl
use diagnostics;
use warnings;
no warnings qw/void/;
use strict;
no strict "refs" ;
use Test::More qw( no_plan );
#use Test::More tests => 29 ;
use FindBin ;

## Specific Modules
use lib $FindBin::Bin ;
my $binPath = $FindBin::Bin ;
use lib::lmTest qw( :ALL ) ;

my $current_test = 0 ;

print "\n\t\t\t\t  * * * * * * \n" ;
print "\t  * * * - - - Test LiPIDMAPS Main script - - - * * * \n\n" ;
	
print "\n** Test $current_test build_lm_mass_query with no fam/class/subcl **\n" ; $current_test++;
	
is( build_lm_mass_queryTest('0.5', 'NA', 'NA_1', 'NA_101'),'http://www.lipidmaps.org/data/structure/LMSDSearch.php?Mode=ProcessTextSearch&OutputColumnHeader=No&OutputMode=File&OutputType=TSV&ExactMassOffSet=0.5&ExactMass=', 'Works with no cat, no class and no subcl argvt' ) ;

print "\n** Test $current_test build_lm_mass_query with a fam but no class/subcl **\n" ; $current_test++;
is( build_lm_mass_queryTest('0.5', 1, 'NA_1', 'NA_101'),'http://www.lipidmaps.org/data/structure/LMSDSearch.php?Mode=ProcessTextSearch&OutputColumnHeader=No&OutputMode=File&OutputType=TSV&CoreClass=1&ExactMassOffSet=0.5&ExactMass=', 'Works with a cat, but no class and no subcl argvt' ) ;

print "\n** Test $current_test build_lm_mass_query with a fam/class but no subcl **\n" ; $current_test++;
is( build_lm_mass_queryTest('0.5', 1, 101, 'NA_101'),'http://www.lipidmaps.org/data/structure/LMSDSearch.php?Mode=ProcessTextSearch&OutputColumnHeader=No&OutputMode=File&OutputType=TSV&CoreClass=1&MainClass=101&ExactMassOffSet=0.5&ExactMass=', 'Works with a cat, a class but no subcl argvt' ) ;

print "\n** Test $current_test build_lm_mass_query with a fam/class/subcl **\n" ; $current_test++;
is( build_lm_mass_queryTest('0.5', 1, 101, 10101),'http://www.lipidmaps.org/data/structure/LMSDSearch.php?Mode=ProcessTextSearch&OutputColumnHeader=No&OutputMode=File&OutputType=TSV&CoreClass=1&MainClass=101&SubClass=10101&ExactMassOffSet=0.5&ExactMass=', 'Works with a cat, a class and a subcl argvt' ) ;

print "\n** Test $current_test round_nums with a list of float and a decimal reduction of 1 **\n" ; $current_test++;
is_deeply( round_numsTest(
		['175.01', '238.19', '420.16', '780.32', '956.25', '1100.45' ], 1 ), 
		['175.0', '238.2', '420.2', '780.3', '956.2', '1100.5' ], 
		'Method \'round_nums\' works with a list of float and return a well rounded list');
		
print "\n** Test $current_test round_nums with a list of float and a decimal reduction of 0 **\n" ; $current_test++;
is_deeply( round_numsTest(
		['175.01', '238.19', '420.16', '780.32', '956.25', '1100.45', '111.6' ], 0 ), 
		['175', '238', '420', '780', '956', '1100', '112' ], 
		'Method \'round_nums\' works with a list of float and return a well rounded list');


print "\n** Test $current_test convert_tbody_to_globalmatrix with a list of hearders and a tbody_object **\n" ; $current_test++;
is_deeply( convert_tbody_to_globalmatrixTest(
		['MASS', 'CLUSTER_DELTA', 'CLUSTER_FORMULA', 'CLUSTER_NAME', 'CLUSTER_TOTAL'],
		[
          {
            'PAGE_NB' => 1,
            'MASSES' => [
                          {
                            'TRANSFORMS' => [
                                              {
                                                'COLOR' => 'grey-bolt',
                                                'TRANSFO_TYPE' => 'Init_MZ',
                                                'CLUSTERS' => [
                                                                {
                                                                  'CLUSTER_FORMULA' => 'C30H59O12P',
                                                                  'NB_ENTRY_BY_MASS' => 0,
                                                                  'NB_CLUSTER_BY_MASS' => 1,
                                                                  'PARENT_ID' => '10_0_0',
                                                                  'COLOR' => 'white',
                                                                  'CLUSTER_NAME' => 'PI_21:0',
                                                                  'CLUSTER_TOTAL' => 1,
                                                                  'NB_MASS' => 10,
                                                                  'CLUSTER_DELTA' => '-0.23',
                                                                  'ENTRIES' => [
                                                                                 {
                                                                                   'COLOR' => 'white',
                                                                                   'ENTRY_FORMULA' => 'C30H59O12P',
                                                                                   'NB_CLUSTER_BY_MASS' => 1,
                                                                                   'NB_ENTRY_BY_MASS' => 1,
                                                                                   'ENTRY_COMMONNAME' => 'PI(21:0/0:0)',
                                                                                   'ENTRY_SYSTNAME' => '1-heneicosanoyl-glycero-3-phospho-(1\'-myo-inositol)',
                                                                                   'LM_ID' => 'LMGP06050025',
                                                                                   'MZ_DELTA' => '-0.23',
                                                                                   'NB_MASS' => 10,
                                                                                   'CLUSTER_ID' => 1
                                                                                 }
                                                                               ]
                                                                }
                                                              ]
                                              }
                                            ],
                            'COLOR' => 'white',
                            'MASS' => '642.5987',
                            'TOTAL' => 1,
                            'NB_ENTRY_BY_MASS' => 0,
                            'NB_CLUSTER_BY_MASS' => 0,
                            'NB_MASS' => 10
                          },
                          {
                            'COLOR' => 'green',
                            'TRANSFORMS' => [
                                              {
                                                'TRANSFO_TYPE' => 'Init_MZ',
                                                'CLUSTERS' => [
                                                                {
                                                                  'ENTRIES' => [
                                                                                 {
                                                                                   'LM_ID' => 'LMGP06050024',
                                                                                   'NB_MASS' => 13,
                                                                                   'CLUSTER_ID' => 1,
                                                                                   'MZ_DELTA' => '-0.18',
                                                                                   'ENTRY_COMMONNAME' => 'PI(22:0/0:0)',
                                                                                   'ENTRY_SYSTNAME' => '1-docosanoyl-glycero-3-phospho-(1\'-myo-inositol)',
                                                                                   'ENTRY_FORMULA' => 'C31H61O12P',
                                                                                   'NB_ENTRY_BY_MASS' => 1,
                                                                                   'NB_CLUSTER_BY_MASS' => 1,
                                                                                   'COLOR' => 'green'
                                                                                 }
                                                                               ],
                                                                  'CLUSTER_DELTA' => '-0.18',
                                                                  'NB_MASS' => 13,
                                                                  'CLUSTER_TOTAL' => 1,
                                                                  'COLOR' => 'green',
                                                                  'CLUSTER_NAME' => 'PI_22:0',
                                                                  'PARENT_ID' => '13_0_0',
                                                                  'NB_CLUSTER_BY_MASS' => 1,
                                                                  'NB_ENTRY_BY_MASS' => 0,
                                                                  'CLUSTER_FORMULA' => 'C31H61O12P'
                                                                }
                                                              ],
                                                'COLOR' => 'green-bolt'
                                              }
                                            ],
                            'MASS' => '656.5718',
                            'NB_MASS' => 13,
                            'TOTAL' => 1,
                            'NB_ENTRY_BY_MASS' => 0,
                            'NB_CLUSTER_BY_MASS' => 0
                          },
                          {
                            'TRANSFORMS' => [
                                              {
                                                'CLUSTERS' => [
                                                                {
                                                                  'ENTRIES' => [
                                                                                 {
                                                                                   'CLUSTER_ID' => 1,
                                                                                   'NB_MASS' => 14,
                                                                                   'MZ_DELTA' => '-0.19',
                                                                                   'LM_ID' => 'LMGP06050024',
                                                                                   'ENTRY_SYSTNAME' => '1-docosanoyl-glycero-3-phospho-(1\'-myo-inositol)',
                                                                                   'ENTRY_COMMONNAME' => 'PI(22:0/0:0)',
                                                                                   'NB_CLUSTER_BY_MASS' => 1,
                                                                                   'NB_ENTRY_BY_MASS' => 1,
                                                                                   'ENTRY_FORMULA' => 'C31H61O12P',
                                                                                   'COLOR' => 'white'
                                                                                 }
                                                                               ],
                                                                  'NB_MASS' => 14,
                                                                  'CLUSTER_DELTA' => '-0.19',
                                                                  'CLUSTER_TOTAL' => 1,
                                                                  'CLUSTER_NAME' => 'PI_22:0',
                                                                  'COLOR' => 'white',
                                                                  'PARENT_ID' => '14_0_0',
                                                                  'NB_CLUSTER_BY_MASS' => 1,
                                                                  'NB_ENTRY_BY_MASS' => 0,
                                                                  'CLUSTER_FORMULA' => 'C31H61O12P'
                                                                }
                                                              ],
                                                'TRANSFO_TYPE' => 'Init_MZ',
                                                'COLOR' => 'grey-bolt'
                                              }
                                            ],
                            'COLOR' => 'white',
                            'NB_CLUSTER_BY_MASS' => 0,
                            'NB_ENTRY_BY_MASS' => 0,
                            'TOTAL' => 1,
                            'NB_MASS' => 14,
                            'MASS' => '656.5802'
                          },
                          {
                            'NB_ENTRY_BY_MASS' => 0,
                            'TOTAL' => 1,
                            'NB_CLUSTER_BY_MASS' => 0,
                            'NB_MASS' => 15,
                            'MASS' => '656.5886',
                            'TRANSFORMS' => [
                                              {
                                                'COLOR' => 'green-bolt',
                                                'TRANSFO_TYPE' => 'Init_MZ',
                                                'CLUSTERS' => [
                                                                {
                                                                  'ENTRIES' => [
                                                                                 {
                                                                                   'ENTRY_FORMULA' => 'C31H61O12P',
                                                                                   'NB_ENTRY_BY_MASS' => 1,
                                                                                   'NB_CLUSTER_BY_MASS' => 1,
                                                                                   'COLOR' => 'green',
                                                                                   'LM_ID' => 'LMGP06050024',
                                                                                   'CLUSTER_ID' => 1,
                                                                                   'NB_MASS' => 15,
                                                                                   'MZ_DELTA' => '-0.20',
                                                                                   'ENTRY_SYSTNAME' => '1-docosanoyl-glycero-3-phospho-(1\'-myo-inositol)',
                                                                                   'ENTRY_COMMONNAME' => 'PI(22:0/0:0)'
                                                                                 }
                                                                               ],
                                                                  'CLUSTER_DELTA' => '-0.20',
                                                                  'NB_MASS' => 15,
                                                                  'CLUSTER_TOTAL' => 1,
                                                                  'CLUSTER_NAME' => 'PI_22:0',
                                                                  'COLOR' => 'green',
                                                                  'PARENT_ID' => '15_0_0',
                                                                  'NB_ENTRY_BY_MASS' => 0,
                                                                  'NB_CLUSTER_BY_MASS' => 1,
                                                                  'CLUSTER_FORMULA' => 'C31H61O12P'
                                                                }
                                                              ]
                                              }
                                            ],
                            'COLOR' => 'green'
                          }
                        ]
          }
        ] ), 
		[
          [
            'MASS',
            'CLUSTER_DELTA',
            'CLUSTER_FORMULA',
            'CLUSTER_NAME',
            'CLUSTER_TOTAL'
          ],
          [
            '642.5987',
            '-0.23',
            'C30H59O12P',
            'PI_21:0',
            1
          ],
          [
            '656.5718',
            '-0.18',
            'C31H61O12P',
            'PI_22:0',
            1
          ],
          [
            '656.5802',
            '-0.19',
            'C31H61O12P',
            'PI_22:0',
            1
          ],
          [
            '656.5886',
            '-0.20',
            'C31H61O12P',
            'PI_22:0',
            1
          ]
        ], 
		'Method \'convert_tbody_to_globalmatrix\' works with a list of headers and a wellformed tbody_object and return a well formed matrix');

print "\n** Test $current_test convert_tbody_to_globalmatrix with no headers but with a tbody_object **\n" ; $current_test++;
is_deeply( convert_tbody_to_globalmatrixTest(
		undef,
		[
          {
            'PAGE_NB' => 1,
            'MASSES' => [
                          {
                            'TRANSFORMS' => [
                                              {
                                                'COLOR' => 'grey-bolt',
                                                'TRANSFO_TYPE' => 'Init_MZ',
                                                'CLUSTERS' => [
                                                                {
                                                                  'CLUSTER_FORMULA' => 'C30H59O12P',
                                                                  'NB_ENTRY_BY_MASS' => 0,
                                                                  'NB_CLUSTER_BY_MASS' => 1,
                                                                  'PARENT_ID' => '10_0_0',
                                                                  'COLOR' => 'white',
                                                                  'CLUSTER_NAME' => 'PI_21:0',
                                                                  'CLUSTER_TOTAL' => 1,
                                                                  'NB_MASS' => 10,
                                                                  'CLUSTER_DELTA' => '-0.23',
                                                                  'ENTRIES' => [
                                                                                 {
                                                                                   'COLOR' => 'white',
                                                                                   'ENTRY_FORMULA' => 'C30H59O12P',
                                                                                   'NB_CLUSTER_BY_MASS' => 1,
                                                                                   'NB_ENTRY_BY_MASS' => 1,
                                                                                   'ENTRY_COMMONNAME' => 'PI(21:0/0:0)',
                                                                                   'ENTRY_SYSTNAME' => '1-heneicosanoyl-glycero-3-phospho-(1\'-myo-inositol)',
                                                                                   'LM_ID' => 'LMGP06050025',
                                                                                   'MZ_DELTA' => '-0.23',
                                                                                   'NB_MASS' => 10,
                                                                                   'CLUSTER_ID' => 1
                                                                                 }
                                                                               ]
                                                                }
                                                              ]
                                              }
                                            ],
                            'COLOR' => 'white',
                            'MASS' => '642.5987',
                            'TOTAL' => 1,
                            'NB_ENTRY_BY_MASS' => 0,
                            'NB_CLUSTER_BY_MASS' => 0,
                            'NB_MASS' => 10
                          },
                          {
                            'COLOR' => 'green',
                            'TRANSFORMS' => [
                                              {
                                                'TRANSFO_TYPE' => 'Init_MZ',
                                                'CLUSTERS' => [
                                                                {
                                                                  'ENTRIES' => [
                                                                                 {
                                                                                   'LM_ID' => 'LMGP06050024',
                                                                                   'NB_MASS' => 13,
                                                                                   'CLUSTER_ID' => 1,
                                                                                   'MZ_DELTA' => '-0.18',
                                                                                   'ENTRY_COMMONNAME' => 'PI(22:0/0:0)',
                                                                                   'ENTRY_SYSTNAME' => '1-docosanoyl-glycero-3-phospho-(1\'-myo-inositol)',
                                                                                   'ENTRY_FORMULA' => 'C31H61O12P',
                                                                                   'NB_ENTRY_BY_MASS' => 1,
                                                                                   'NB_CLUSTER_BY_MASS' => 1,
                                                                                   'COLOR' => 'green'
                                                                                 }
                                                                               ],
                                                                  'CLUSTER_DELTA' => '-0.18',
                                                                  'NB_MASS' => 13,
                                                                  'CLUSTER_TOTAL' => 1,
                                                                  'COLOR' => 'green',
                                                                  'CLUSTER_NAME' => 'PI_22:0',
                                                                  'PARENT_ID' => '13_0_0',
                                                                  'NB_CLUSTER_BY_MASS' => 1,
                                                                  'NB_ENTRY_BY_MASS' => 0,
                                                                  'CLUSTER_FORMULA' => 'C31H61O12P'
                                                                }
                                                              ],
                                                'COLOR' => 'green-bolt'
                                              }
                                            ],
                            'MASS' => '656.5718',
                            'NB_MASS' => 13,
                            'TOTAL' => 1,
                            'NB_ENTRY_BY_MASS' => 0,
                            'NB_CLUSTER_BY_MASS' => 0
                          },
                          {
                            'TRANSFORMS' => [
                                              {
                                                'CLUSTERS' => [
                                                                {
                                                                  'ENTRIES' => [
                                                                                 {
                                                                                   'CLUSTER_ID' => 1,
                                                                                   'NB_MASS' => 14,
                                                                                   'MZ_DELTA' => '-0.19',
                                                                                   'LM_ID' => 'LMGP06050024',
                                                                                   'ENTRY_SYSTNAME' => '1-docosanoyl-glycero-3-phospho-(1\'-myo-inositol)',
                                                                                   'ENTRY_COMMONNAME' => 'PI(22:0/0:0)',
                                                                                   'NB_CLUSTER_BY_MASS' => 1,
                                                                                   'NB_ENTRY_BY_MASS' => 1,
                                                                                   'ENTRY_FORMULA' => 'C31H61O12P',
                                                                                   'COLOR' => 'white'
                                                                                 }
                                                                               ],
                                                                  'NB_MASS' => 14,
                                                                  'CLUSTER_DELTA' => '-0.19',
                                                                  'CLUSTER_TOTAL' => 1,
                                                                  'CLUSTER_NAME' => 'PI_22:0',
                                                                  'COLOR' => 'white',
                                                                  'PARENT_ID' => '14_0_0',
                                                                  'NB_CLUSTER_BY_MASS' => 1,
                                                                  'NB_ENTRY_BY_MASS' => 0,
                                                                  'CLUSTER_FORMULA' => 'C31H61O12P'
                                                                }
                                                              ],
                                                'TRANSFO_TYPE' => 'Init_MZ',
                                                'COLOR' => 'grey-bolt'
                                              }
                                            ],
                            'COLOR' => 'white',
                            'NB_CLUSTER_BY_MASS' => 0,
                            'NB_ENTRY_BY_MASS' => 0,
                            'TOTAL' => 1,
                            'NB_MASS' => 14,
                            'MASS' => '656.5802'
                          },
                          {
                            'NB_ENTRY_BY_MASS' => 0,
                            'TOTAL' => 1,
                            'NB_CLUSTER_BY_MASS' => 0,
                            'NB_MASS' => 15,
                            'MASS' => '656.5886',
                            'TRANSFORMS' => [
                                              {
                                                'COLOR' => 'green-bolt',
                                                'TRANSFO_TYPE' => 'Init_MZ',
                                                'CLUSTERS' => [
                                                                {
                                                                  'ENTRIES' => [
                                                                                 {
                                                                                   'ENTRY_FORMULA' => 'C31H61O12P',
                                                                                   'NB_ENTRY_BY_MASS' => 1,
                                                                                   'NB_CLUSTER_BY_MASS' => 1,
                                                                                   'COLOR' => 'green',
                                                                                   'LM_ID' => 'LMGP06050024',
                                                                                   'CLUSTER_ID' => 1,
                                                                                   'NB_MASS' => 15,
                                                                                   'MZ_DELTA' => '-0.20',
                                                                                   'ENTRY_SYSTNAME' => '1-docosanoyl-glycero-3-phospho-(1\'-myo-inositol)',
                                                                                   'ENTRY_COMMONNAME' => 'PI(22:0/0:0)'
                                                                                 }
                                                                               ],
                                                                  'CLUSTER_DELTA' => '-0.20',
                                                                  'NB_MASS' => 15,
                                                                  'CLUSTER_TOTAL' => 1,
                                                                  'CLUSTER_NAME' => 'PI_22:0',
                                                                  'COLOR' => 'green',
                                                                  'PARENT_ID' => '15_0_0',
                                                                  'NB_ENTRY_BY_MASS' => 0,
                                                                  'NB_CLUSTER_BY_MASS' => 1,
                                                                  'CLUSTER_FORMULA' => 'C31H61O12P'
                                                                }
                                                              ]
                                              }
                                            ],
                            'COLOR' => 'green'
                          }
                        ]
          }
        ] ), 
		[
          [
            'MASS',
            'CLUSTER_DELTA',
            'CLUSTER_FORMULA',
            'CLUSTER_NAME',
            'CLUSTER_TOTAL'
          ],
          [
            '642.5987',
            '-0.23',
            'C30H59O12P',
            'PI_21:0',
            1
          ],
          [
            '656.5718',
            '-0.18',
            'C31H61O12P',
            'PI_22:0',
            1
          ],
          [
            '656.5802',
            '-0.19',
            'C31H61O12P',
            'PI_22:0',
            1
          ],
          [
            '656.5886',
            '-0.20',
            'C31H61O12P',
            'PI_22:0',
            1
          ]
        ], 
		'Method \'convert_tbody_to_globalmatrix\' works with no given list of headers and a wellformed tbody_object and return a well formed matrix');