Bio-NEXUS

 view release on metacpan or  search on metacpan

t/charactersblock_methods-02.t  view on Meta::CPAN

		if ($otu->get_name() eq 'taxon_2') {
				$has_otu= 1;
				last;
		}
}
is ($has_otu, 1, "Renaming successful: taxon_2 is in the set");

# 	charstatelabels 1 hair/absent present, 2 color/red blue, 3 size/small big;

my $labels = $char_block->get_charstatelabels(); 

print "Checking processing of labels from charstatelabels command . . . \n"; 
is ( $$labels[0]{'charlabel'}, 'hair', "Label 'hair' for first character");  
my $states = $$labels[0]{'states'}; 
is ( $$states{'0'}, 'absent', "Label 'absent' for state 0 of first character");  
is ( $$states{'1'}, 'present', "Label 'present' for state 1 of first character");  

is ( $$labels[1]{'charlabel'}, 'color', "Label 'color' for second character");  
$states = $$labels[1]{'states'}; 
is ( $$states{'0'}, 'red', "Label 'red' for state 0 of second character");  

is ( $$labels[2]{'charlabel'}, 'size', "Label 'size' for third char");  
$states = $$labels[2]{'states'}; 
is ( $$states{'1'}, 'big', "Label 'big' for state 1 of third character");  


# Another set of more challenging tests, based on file 04_characterstatelabels_05.nex
# 
# Unfinished! 
# 
# To do: 
#    * determine whether std requires that charstatelabel list order be sequential
#    * if needed, modify CharactersBlock code to allow nonsequential charstatelabel items
#    * implement test for list contents below
#    * ideally, use deep compare method (Test::Deep?)
# 
$nexus_file= "t/data/compliant/04_characterstatelabels_05.nex";

eval {
	$nex_obj = new Bio::NEXUS($nexus_file);
	$char_block = $nex_obj->get_block("characters");
};
is ($@, '', 'Parsing successful');

$labels = $char_block->get_charstatelabels(); 

my @true_charstatelabels = [ 
	{ 
		'id' => '1',
	  	'char_label' => 'DTC_migration_pattern', 
	  	'states' => {
	    	'1' => 'out,_dorsal,_back', 
	  		'2' => 'out,_dorsal,_back,_ventral', 
	  		'3' => 'out,_dorsal,_back,_ventral,_second_turn' 
	  	}
	},
	{ 
		'id' => '3',
	  	'char_label' => 'P6.p_requirement_for_late_induction', 
	  	'states' => {
	    	'1' => 'not_required', 
	  		'2' => 'required', 
	  		'3' => '(not_applicable)' 
	  	}
	}	
];

#   	2  Dependence_on_gonadal_induction_before_VPCs_divide / no_gonad_requirement dependent_on_gonad,
#   	4  Source_of_first_induction_signal / gonad AC gonad_independent,
#   	8  'B: P5.pap/P7.ppa division' / U L T O,
#   	9  'C: P5.ppa/P7.pap division' / U L T,
#   	10  'D: P5.ppp/P7.paa division' / U L T,
#   	11  P4.p_lineage_pattern / 'S_(no_division)' 'SS_(1_division)' 'Sss_(2_divisions;_inner_daughter_divides_again)' 'SSSS_(3_divisions)' '(SSLL)_(5_divisions;_inner_granddaughters_divide_L)' 'LLLL_(7_divisions;_8_cells)',
#   	12  P8.p_lineage_pattern / 'S_(no_division)' 'SS_(1_division)' 'ssS_(2_divisions)' 'SSSS_(3_divisions)' 'LLSS_(5_divisions)' 'LLLL_(7_divisions)',
#   	20  P3.p_division_frequency / in_less_than_20%_of_cells more_than_20%_of_cells 
#   	5  P6.p_lineage_pattern / TTTT TUUT UTTU UUTT UTTT,
#   	6  'P (5,7).p lineage pattern' / UUUU LUUU LLUU LLLU LLTU LULU LOTU sUUU UULL,
#   	7  'A: P5.paa/P7.ppp division' / U L T O,
# 


#Added by Vivek (14-Dec- 2006) Based on the BUG submitted by John Bradley
#select_columns && get_nchar methods

$char_block->select_columns([1]);

is ($char_block->get_nchar, 1, "Get nchar successful: When one column is selected");
my $otu_set = $char_block->get_otuset();
is ($char_block->get_nchar, $otu_set->get_nchar, " The nchar in Characters block and no. of characters in MATRIX are equal: When one column is selected");


=methods not tested

# add_states_to_charstates
# create_charstates
# set_otuset
# set_charstatelabels
# set_charlabels
# set_statelabels

=cut



( run in 1.003 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )