2 ## Bioperl Test Harness Script for Modules
4 # Before `make install' is performed this script should be runnable with
5 # `make test'. After `make install' it should work as `perl test.t'
10 # to handle systems with no installed Test module
11 # we include the t dir (where a copy of Test.pm is located)
13 eval { require Test::More; };
20 use_ok('Bio::Tools::GFF');
21 use_ok('Bio::SeqFeatureI');
22 use_ok('Bio::SeqFeature::Generic');
26 unlink("out1.gff", "out2.gff");
29 my $feat = new Bio::SeqFeature::Generic( -start => 10, -end => 100,
30 -strand => -1, -primary => 'repeat',
31 -source => 'repeatmasker',
36 sillytag => 'this is silly!;breakfast' } );
38 my $gff1out = Bio::Tools::GFF->new(-gff_version => 1, -file => ">out1.gff");
40 my $gff2out = Bio::Tools::GFF->new(-gff_version => 2, -file => ">out2.gff");
43 $gff1out->write_feature($feat);
44 $gff2out->write_feature($feat);
49 my $gff1in = Bio::Tools::GFF->new(-gff_version => 1, -file => "out1.gff");
51 my $gff2in = Bio::Tools::GFF->new(-gff_version => 2, -file => "out2.gff");
54 my $feat1 = $gff1in->next_feature();
56 is($feat1->start, $feat->start);
57 is($feat1->end, $feat->end);
58 is($feat1->primary_tag, $feat->primary_tag);
59 is($feat1->score, $feat->score);
61 my $feat2 = $gff2in->next_feature();
63 is($feat2->start, $feat->start);
64 is($feat2->end, $feat->end);
65 is($feat2->primary_tag, $feat->primary_tag);
66 is($feat2->score, $feat->score);
67 is(($feat2->each_tag_value('sillytag'))[0], 'this is silly!;breakfast');
69 #test sequence-region parsing
70 $gff2in = Bio::Tools::GFF->new(-gff_version => 2, -file => Bio::Root::IO->catfile("t","data","hg16_chroms.gff"));
71 is($gff2in->next_feature(),undef);
72 my $seq = $gff2in->next_segment;
73 is($seq->display_id, 'chr1');
74 is($seq->end, 246127941);
80 eval { require IO::String };
81 skip('cannot verify GFF3 writing tests without IO::String installed',12)
83 my $str = IO::String->new;
84 my $gffout = new Bio::Tools::GFF(-fh => $str, -gff_version => 3);
85 my $feat_test = new Bio::SeqFeature::Generic
86 (-primary_tag => 'tag',
87 -source_tag => 'exon',
94 'bungle' => 'jungle;mumble',
95 'lion' => 'snake=tree'
97 $feat_test->add_tag_value('giant_squid', 'lakeshore manor');
98 $gffout->write_feature($feat_test);
100 my $in = new Bio::Tools::GFF(-fh => $str,
102 my $f_recon = $in->next_feature;
103 is($f_recon->primary_tag, $feat_test->primary_tag);
104 is($f_recon->source_tag, $feat_test->source_tag);
105 is($f_recon->score, $feat_test->score);
106 is($f_recon->start, $feat_test->start);
107 is($f_recon->end, $feat_test->end);
108 is($f_recon->strand, $feat_test->strand);
109 for my $tag ( $feat_test->get_all_tags ) {
110 ok($f_recon->has_tag($tag));
111 if( $f_recon->has_tag($tag) ) {
112 my @v = $feat_test->get_tag_values($tag);
113 my @g = $f_recon->get_tag_values($tag);
115 is(shift @v, shift @g);