1
# -*-Perl-*- Test Harness script for Bioperl
2
# $Id: GFF.t 15112 2008-12-08 18:12:38Z sendu $
10
test_begin(-tests => 34);
12
use_ok('Bio::Tools::GFF');
13
use_ok('Bio::SeqFeature::Generic');
16
my $feat = Bio::SeqFeature::Generic->new( -start => 10, -end => 100,
17
-strand => -1, -primary => 'repeat',
18
-source => 'repeatmasker',
23
sillytag => 'this is silly!;breakfast' } );
26
my ($out1, $out2) = (test_output_file(), test_output_file());
27
my $gff1out = Bio::Tools::GFF->new(-gff_version => 1, -file => ">$out1");
29
my $gff2out = Bio::Tools::GFF->new(-gff_version => 2, -file => ">$out2");
32
$gff1out->write_feature($feat);
33
$gff2out->write_feature($feat);
38
my $gff1in = Bio::Tools::GFF->new(-gff_version => 1, -file => "$out1");
40
my $gff2in = Bio::Tools::GFF->new(-gff_version => 2, -file => "$out2");
43
my $feat1 = $gff1in->next_feature();
45
is($feat1->start, $feat->start);
46
is($feat1->end, $feat->end);
47
is($feat1->primary_tag, $feat->primary_tag);
48
is($feat1->score, $feat->score);
50
my $feat2 = $gff2in->next_feature();
52
is($feat2->start, $feat->start);
53
is($feat2->end, $feat->end);
54
is($feat2->primary_tag, $feat->primary_tag);
55
is($feat2->score, $feat->score);
56
is(($feat2->each_tag_value('sillytag'))[0], 'this is silly!;breakfast');
58
#test sequence-region parsing
59
$gff2in = Bio::Tools::GFF->new(-gff_version => 2, -file => test_input_file('hg16_chroms.gff'));
60
is($gff2in->next_feature(),undef);
61
my $seq = $gff2in->next_segment;
62
is($seq->display_id, 'chr1');
63
is($seq->end, 246127941);
69
test_skip(-tests => 12, -requires_module => 'IO::String');
70
my $str = IO::String->new;
71
my $gffout = Bio::Tools::GFF->new(-fh => $str, -gff_version => 3);
72
my $feat_test = Bio::SeqFeature::Generic->new
73
(-primary_tag => 'tag',
74
-source_tag => 'exon',
81
'bungle' => 'jungle;mumble',
82
'lion' => 'snake=tree'
84
$feat_test->add_tag_value('giant_squid', 'lakeshore manor');
85
$gffout->write_feature($feat_test);
87
my $in = Bio::Tools::GFF->new(-fh => $str,
89
my $f_recon = $in->next_feature;
90
is($f_recon->primary_tag, $feat_test->primary_tag);
91
is($f_recon->source_tag, $feat_test->source_tag);
92
is($f_recon->score, $feat_test->score);
93
is($f_recon->start, $feat_test->start);
94
is($f_recon->end, $feat_test->end);
95
is($f_recon->strand, $feat_test->strand);
96
for my $tag ( $feat_test->get_all_tags ) {
97
ok($f_recon->has_tag($tag));
98
if( $f_recon->has_tag($tag) ) {
99
my @v = $feat_test->get_tag_values($tag);
100
my @g = $f_recon->get_tag_values($tag);
102
is(shift @v, shift @g);