Merge pull request #42 from solgenomics/topic/duplicate_image_warning
[cxgn-corelibs.git] / t / CXGN / Genomic / clonenameparser.t
blobadf2ab21a71c5a48665000d949fcd22eac7c54d1
1 #!/usr/bin/env perl
2 use strict;
3 no strict 'refs';
4 #use UNIVERSAL qw/isa/;
6 BEGIN {
7 our %tests = ( clone_name_with_chromosome => [
8 [ 'SGN12H032K07',
9 { lib => 'LE_HBa',
10 plate => 32,
11 chr => 12,
12 row => 'K',
13 col => 7,
14 clonetype => 'bac',
15 match => 'SGN12H032K07',
16 version => undef,
17 fragment => undef,
20 [ 'C11HBa119D16',
21 { lib => 'LE_HBa',
22 plate => 119,
23 chr => 11,
24 row => 'D',
25 col => 16,
26 clonetype => 'bac',
27 match => 'C11HBa119D16',
28 version => undef,
29 fragment => undef,
32 [ 'C02HBa0155C04',
33 { lib => 'LE_HBa',
34 plate => 155,
35 chr => 2,
36 row => 'C',
37 col => 4,
38 clonetype => 'bac',
39 match => 'C02HBa0155C04',
40 version => undef,
41 fragment => undef,
44 [ 'C02HBa0155C04.3-87',
45 { lib => 'LE_HBa',
46 plate => 155,
47 chr => 2,
48 row => 'C',
49 col => 4,
50 clonetype => 'bac',
51 match => 'C02HBa0155C04.3-87',
52 version => 3,
53 fragment => 87,
56 [ 'C02HBa0155C04-87',
57 undef,
60 [ 'LE_HBa0034B23',
61 undef,
63 [ '002C17',
64 undef,
67 seqwright_bac_chromat_file => [
68 [ 'tomato_genome/bac_ends/Le-HBa001_A01-T7.ab1.gz',
69 { lib => 'LE_HBa',
70 plate => 1,
71 row => 'A',
72 col => 1,
73 clonetype => 'bac',
74 path => 'tomato_genome/bac_ends/',
75 suffix => '.ab1.gz',
76 primer => 'T7',
77 filename => 'Le-HBa001_A01-T7',
78 match => 'Le-HBa001_A01-T7',
81 [ '/bac_ends/SL_MboI_1_A05-SP6.g',
82 { lib => 'SL_MboI',
83 plate => 1,
84 col => 5,
85 row => 'A',
86 clonetype => 'bac',
87 path => '/bac_ends/',
88 suffix => '',
89 primer => 'SP6',
90 filename => 'SL_MboI_1_A05-SP6.g',
91 match => 'SL_MboI_1_A05-SP6',
95 genbank_accession => [
96 [ 'CT990638.3' =>
98 lib => 'LE_HBa',
99 plate => 6,
100 row => 'E',
101 col => 18,
102 clonetype => 'bac',
103 match => 'CT990638',
106 [ 'CT990624' =>
108 lib => 'LE_HBa',
109 plate => 27,
110 row => 'G',
111 col => 19,
112 clonetype => 'bac',
113 match => 'CT990624',
116 [ CT990637 =>
118 lib => 'LE_HBa',
119 plate => 36,
120 row => 'C',
121 col => 23,
122 clonetype => 'bac',
123 match => 'CT990637',
126 #[ NE999999 => undef ],
130 use Test::More qw/no_plan/;
132 use_ok('CXGN::Genomic::CloneNameParser');
134 my $parser = CXGN::Genomic::CloneNameParser->new;
135 isa_ok($parser,'CXGN::Genomic::CloneNameParser' ,'CloneNameParser constructor works');
137 #test each clone name parser function jimmy
138 foreach my $funcname (keys our %tests) {
139 foreach my $test (@{$tests{$funcname}}) {
140 #pretty-print the expected return value
141 my $exp_str = hashref_to_str($test->[1]);
143 my $ret = $parser->$funcname( $test->[0] );
145 ok( eq_hash( $ret, $test->[1] ),"$funcname('$test->[0]')")
146 or diag "expected $exp_str\ngot ".hashref_to_str($ret)."\n";
150 sub hashref_to_str {
151 my $ref = shift;
153 if ( defined($ref) ) {
154 ref $ref eq 'HASH' or die 'not a hash ref';
156 my @strs;
157 foreach my $key (sort keys %$ref) {
158 my $val = $ref->{$key};
159 $val = 'undef' unless defined($val);
160 push @strs, "$key => $val";
162 return join(', ',@strs);
163 } else {
164 return 'undef';