7 use CXGN
::CDBI
::Class
::DBI
::TestSampler
;
9 our %config = ( packagename
=> 'CXGN::Genomic::GSS',
16 use Test
::More tests
=> $config{numtests
}*$config{test_repeats
};
18 use CXGN
::Genomic
::GSS
;
24 ###test that we can retrieve it
25 my $gss = $config{packagename
}->retrieve($id);
26 ok
( isa
( $gss, $config{packagename
} ) );
28 ### check basic data integrity
29 my @fields = qw
/ status flags seq qual call_positions version chromat_id gss_id /;
30 my $fieldlist = join( ', ', @fields );
31 my $gss2 = $dbh->selectrow_hashref( <<EOSQL, undef, $id );
36 foreach my $field (qw
/seq qual call_positions version gss_id/) {
37 my $v1 = $gss->$field;
38 my $v2 = $gss2->{$field};
39 ok
( !defined $v1 && !defined $v2 || $gss->$field eq $gss2->{$field} );
43 ok
( isa
($gss->chromat_id, 'CXGN::Genomic::Chromat') );
44 ok
( isa
($gss->chromat_object, 'CXGN::Genomic::Chromat') );
45 ok
( $gss->chromat_object->chromat_id == $gss->chromat_id->chromat_id );
46 ok
( $gss->chromat_object->chromat_id == $gss2->{chromat_id
} );
48 ###test gss_submitted_to_genbank
49 my ($good1,$good2) = (1,1);
50 foreach my $sub ($gss->gss_submitted_to_genbank_objects) {
51 $good1 &&= isa
($sub,'CXGN::Genomic::GSSSubmittedToGenbank')
52 or diag
'improper type for gss_submitted_to_genbank object';
53 $good2 &&= ($sub->gss_id == $gss->gss_id)
54 or diag
$sub->gss_id.'!='.$gss->gss_id;
60 #look for any invalid status keys
61 is
( $gss->gen_status_mask($gss->status), $gss2->{status
}, 'status is correct');
62 is
( $gss->gen_flags_mask($gss->flags), $gss2->{flags
}, 'flags is correct' );
63 my %validflags = map { $_,1 } @CXGN::Genomic
::GSS
::otherflags
;
64 my %validstatus = map { $_,1 } @CXGN::Genomic
::GSS
::statusflags
;
65 ok
(! grep {! $validflags{$_} } keys(%{$gss->flags}) );
66 ok
(! grep {! $validstatus{$_} } keys(%{$gss->status}) );
68 #check status2str and flags2str are at least the right length
69 ok
($gss->status2str == keys(%{$gss->status}));
70 ok
($gss->flags2str == keys(%{$gss->flags}));
72 ### check that lengths of seqs, quals, and call_positions are all the same
74 my $tseq = $gss->trimmed_seq;
75 ok
( !defined $_->[0] || length $_->[1] == scalar( my @foo = split /\s/, $_->[0] )
77 ) or diag
("seq: '$_->[1]'\n$_->[2]: '$_->[0]'\n")
78 for [ $gss->qual, $seq, 'qual' ],
79 [ $gss->trimmed_qual, $tseq, 'trimmed qual' ],
80 [ $gss->call_positions, $seq, 'call pos' ];
82 #check consistency of trimmed_regions by trimming the raw sequence
83 #with them and seeing if it comes out the same as the trimmed version
86 my @trimmed = $gss->trimmed_regions;
89 foreach my $trim (@trimmed) {
91 $prevs <= $s or diag
'trimmed_regions not in ascending order';
93 substr($seq,$s-$prevlen,$len,''); #splice out parts of $seq
97 ok
($seq eq $gss->trimmed_seq) or
98 # diag html_break_string($seq,70,"\n")
99 # ."\nis not equal to\n"
100 # .html_break_string($gss->trimmed_seq,70,"\n");
102 ###check the external identifier
103 ok
( index($gss->external_identifier,$gss->chromat_object->clone_read_external_identifier)
107 skip
($gss->version <= 1,1);
108 isnt
(index($gss->external_identifier,'_$gss->version'),-1);
111 ###check that unixtime doesn't crash: this could use some work
115 my $bseq = $gss->to_bio_seq(
116 -factory
=> Bio
::Seq
::SeqFactory
->new( -type
=> 'Bio::Seq::CXGNGenomic' )
119 ok
($bseq->seq eq $gss->seq) or
120 # diag html_break_string($bseq->seq,70,"\n")
121 # ."\nis not equal to\n"
122 # .html_break_string($gss->seq,70,"\n");
124 #check that quals the same
125 ok
(join(' ',@
{$bseq->qual}) eq $gss->qual) or
126 # diag html_break_string(join(' ',@{$bseq->qual}),70,"\n")
127 # ."\nis not equal to\n"
128 # .html_break_string($gss->qual,70,"\n");
130 #check the display_id is the external_identifier
131 ok
($bseq->display_id eq $gss->external_identifier);
133 }#end test subroutine
135 #now run the actual sampled test
136 my $tester = CXGN
::CDBI
::Class
::DBI
::TestSampler
->new;
138 $tester->test_class($config{packagename
},
139 $config{test_repeats
},
142 $tester->disconnect(42);