small pod fix
[bioperl-live.git] / t / UniGene.t
blobae7da26f9bc3d29bcfed91ae2d8521c53f8431bc
1 # -*-Perl-*- Test Harness script for Bioperl
2 # $Id$
4 use strict;
6 BEGIN { 
7     use lib 't/lib';
8     use BioperlTest;
9     
10     test_begin(-tests => 73);
11         
12         use_ok('Bio::ClusterIO');
15 my ($str, $unigene); # predeclare variables for strict
17 $str = Bio::ClusterIO->new('-file' => test_input_file('unigene.data'), '-format' => "unigene");
18 ok $str, 'new Bio::ClusterIO object defined';
20 ok ( defined ($unigene = $str->next_cluster()));
22 # check interface implementations to be sure
23 isa_ok $unigene, "Bio::Cluster::UniGeneI";
24 isa_ok $unigene, "Bio::ClusterI";
25 isa_ok $unigene, "Bio::IdentifiableI";
26 isa_ok $unigene, "Bio::DescribableI";
28 # test specific instance of unigene record provided in the unigene.data file
29 is ($unigene->unigene_id, 'Hs.2');
30 is ($unigene->title, 'N-acetyltransferase 2 (arylamine N-acetyltransferase)');
31 is ($unigene->gene, 'NAT2');
32 is ($unigene->cytoband,'8p22');
33 is ($unigene->gnm_terminus,'S');
34 is ($unigene->homol,'YES');
35 is ($unigene->restr_expr,'liver');
36 is ($unigene->scount,26);
37 is (scalar @{ $unigene->locuslink }, 1);
38 is (scalar @{ $unigene->chromosome }, 1);
39 is (scalar @{ $unigene->express }, 7);
40 is (scalar @{ $unigene->sts }, 8);
41 is (scalar @{ $unigene->txmap }, 0);
42 is (scalar @{ $unigene->protsim } , 4);
43 is (scalar @{ $unigene->sequences },26);
45 is ($unigene->locuslink->[0], '10');
46 is ($unigene->chromosome->[0], '8');
47 is ($unigene->express->[0], 'liver');
48 is ($unigene->sts->[0], 'ACC=G59899 UNISTS=137181');
49 is ($unigene->protsim->[0], 'ORG=Escherischia coli; PROTGI=16129422; PROTID=ref:NP_415980.1; PCT=24.81; ALN=255');
51 my ($seq1) = $unigene->next_seq;
52 is ($seq1->display_id, 'BX095770');
54 # test recognition of species
56 SKIP: {
57         # TODO? why wouldn't it be available? Bug if not? Remove this skip?
58         skip 'species not available', 'species test' unless defined $unigene->species;
59         is $unigene->species->binomial, "Homo sapiens" ;
63 # test accessors of interfaces
64 is  ($seq1->namespace, "GenBank");
65 is  ($seq1->authority, "NCBI");
66 is  ($seq1->alphabet, "dna");
67 my $n = 1; # we've seen already one seq
68 while($seq1 = $unigene->next_seq()) {
69     $n++;
71 is  ($n, 26);
72 is  ($unigene->size(), 26);
73 is  (scalar($unigene->get_members()), 26);
74 is  ($unigene->description, 'N-acetyltransferase 2 (arylamine N-acetyltransferase)');
75 is  ($unigene->display_id, "Hs.2");
76 is  ($unigene->namespace, "UniGene");
77 is  ($unigene->authority, "NCBI");
79 $unigene->unigene_id('Hs.50');
80 is ($unigene->unigene_id, 'Hs.50') || diag('unigene_id was ' . $unigene->unigene_id);
82 $unigene->title('title_test');
83 is ($unigene->title, 'title_test') || diag('title was ' . $unigene->title);
85 $unigene->gene('gene_test');
86 is ($unigene->gene, 'gene_test') || diag('gene was ' . $unigene->gene);
88 $unigene->cytoband('cytoband_test');
89 is ($unigene->cytoband, 'cytoband_test') || diag('cytoband was ' . $unigene->cytoband);
91 $unigene->gnm_terminus('gnm_terminus_test');
92 is ($unigene->gnm_terminus, 'gnm_terminus_test') || diag('gnm_terminus was ' . $unigene->gnm_terminus);
94 $unigene->homol('homol_test');
95 is ($unigene->homol, 'homol_test') || diag('homol was ' . $unigene->homol);
97 $unigene->restr_expr('restr_expr_test');
98 is ($unigene->restr_expr, 'restr_expr_test') || diag('restr_expr was ' . $unigene->restr_expr);
100 $unigene->scount('scount_test');
101 is ($unigene->scount, 'scount_test') || diag('scount was ' . $unigene->scount);
103 my $seq = $unigene->next_seq;
104 $seq = $unigene->next_seq;
105 isa_ok ($seq, 'Bio::PrimarySeqI') || diag('expected a Bio::PrimarySeq object but got a ' . ref($seq));
106 my $accession = $seq->accession_number;
107 is ($accession, 'AI262683');
108 my $version = $seq->seq_version();
109 is ($version, 1);
111 # test the sequence parsing is working
112 my $ac = $seq->annotation();
113 my $simple_ann_object;
114 ($simple_ann_object) = $ac->get_Annotations('seqtype');
115 ok defined $simple_ann_object, 'annotation object defined';
116 is ($simple_ann_object->value(), 'EST') || diag('seqtype was ' . $simple_ann_object->value);    
118 # test PERIPHERAL, bug 1708
119 $seq = $unigene->next_seq;
120 $accession = $seq->accession_number;
121 is ($accession, 'CB161982');
123 my @acs = $seq->annotation->get_Annotations('peripheral');
124 is  $acs[0]->display_text, 1;
126 # tests not specific to unigene record provided in the unigene.data file
127 my @locuslink_test = ( "58473", "5354" );
128 $unigene->locuslink(\@locuslink_test);
129 my @locuslink_results;
130 while (my $locuslink = $unigene->next_locuslink) {
131         push @locuslink_results, $locuslink;
133 is(scalar(@locuslink_results), 2) || diag('expected locuslink to have 2 entries but it had ' . scalar(@locuslink_results));
134 my $locuslink = shift @locuslink_results;
135 is( $locuslink, '58473') || diag('expected 58473 but got ' . $locuslink);
138 my @express_test = qw( kidney heart liver spleen );
139 $unigene->express(\@express_test);
140 my @express_results;
141 while (my $tissue = $unigene->next_express) {
142         push @express_results, $tissue;
144 is(  scalar(@express_results), 4) || diag('expected express to have 4 entries but it had ' . scalar(@express_results));
146 my @chromosome_test = ( "7", "11" );
147 $unigene->chromosome(\@chromosome_test);
148 my @chromosome_results;
149 while (my $chromosome = $unigene->next_chromosome) {
150         push @chromosome_results, $chromosome;
152 is( scalar(@chromosome_results), 2) || diag('expected chromosome to have 2 entries but it had ' . scalar(@chromosome_results));
153 my $chromosome = shift @chromosome_results;
154 is(  $chromosome, '7') || diag('expected 7 but got ' . $chromosome);
156 my @sts_test = ( "ACC=- NAME=sts-D90276 UNISTS=37687", "ACC=G29786 NAME=SHGC-35230 UNISTS=58455" );
157 $unigene->sts(\@sts_test);
158 my @sts_results;
159 while (my $sts = $unigene->next_sts) {
160         push @sts_results, $sts;
162 is(scalar(@sts_results), 2) || diag('expected sts to have 2 entries but it had ' . scalar(@sts_results));
163 my $sts = shift @sts_results;
164 is($sts, 'ACC=- NAME=sts-D90276 UNISTS=37687') || diag('expected ACC=- NAME=sts-D90276 UNISTS=37687 but got ' . $sts);
166 my @txmap_test = ("D19S425-D19S418; MARKER=sts-D90276; RHPANEL=GB4" , "D19S425-D19S418; MARKER=stSG41396; RHPANEL=GB4");
167 $unigene->txmap(\@txmap_test);
168 my @txmap_results;
169 while (my $txmap = $unigene->next_txmap) {
170         push @txmap_results, $txmap;
172 is(scalar(@txmap_results), 2) || diag('expected txmap to have 2 entries but it had ' . scalar(@txmap_results));
173 my $txmap = shift @txmap_results;
174 is ($txmap, 'D19S425-D19S418; MARKER=sts-D90276; RHPANEL=GB4') || diag('expected D19S425-D19S418; MARKER=sts-D90276; RHPANEL=GB4 but got ' . $txmap);
176 my @protsim_test = ("ORG=Homo sapiens; PROTGI=107211; PROTID=pir:A40428; PCT=100; ALN=243" , "ORG=Mus musculus; PROTGI=2497288; PROTID=sp:Q61400; PCT=42; ALN=143");
177 $unigene->protsim(\@protsim_test);
178 my @protsim_results;
179 while (my $protsim = $unigene->next_protsim) {
180     push @protsim_results, $protsim;
182 is (scalar(@protsim_results), 2) || diag('expected protsim to have 2 entries but it had ' . scalar(@protsim_results));
183 my $protsim = shift @protsim_results;
184 is ($protsim, 'ORG=Homo sapiens; PROTGI=107211; PROTID=pir:A40428; PCT=100; ALN=243') || diag('expected ORG=Homo sapiens; PROTGI=107211; PROTID=pir:A40428; PCT=100; ALN=243 but got ' . $protsim);
188 # do a quick test on Rn record included as the next cluster in the
189 # test data file because it has version numbers tacked on the end of
190 # the accession numbers in each seq line - NCBI has started doing this
191 # now (Sept 2003).
193 $unigene = $str->next_cluster();
194 $seq = $unigene->next_seq;
195 isa_ok ($seq,'Bio::PrimarySeqI') || diag( 'expected a Bio::PrimarySeq object but got a ' . ref($seq));
196 $version = $seq->seq_version();
197 is($version, '1');
199 # next cluster contains a // in the title - yes NCBI did that. Nonetheless,
200 # this should not trip up the parser:
202 $unigene = $str->next_cluster();
203 ok ($unigene, 'next cluster'); # previously this would have been undef
204 is  ($unigene->unigene_id, "Mm.340763");
205 is ($unigene->title, 'Transcribed locus, strongly similar to NP_003008.1 splicing factor, arginine/serine-rich 3; splicing factor, arginine//serine-rich, 20-kD [Homo sapiens]');
206 is ($unigene->homol, 'YES');
207 is ($unigene->scount, 31);
208 is (scalar($unigene->get_members()), 31);