~ubuntu-branches/ubuntu/saucy/bioperl/saucy-proposed

« back to all changes in this revision

Viewing changes to t/Tools/GFF.t

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2009-03-10 07:19:11 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310071911-fukqzw54pyb1f0bd
Tags: 1.6.0-2
* Removed patch system (not used):
  - removed instuctions in debian/rules;
  - removed quilt from Build-Depends in debian/control.
* Re-enabled tests:
  - uncommented test command in debian/rules;
  - uncommented previously missing build-dependencies in debian/control.
  - Re-enabled tests and uncommented build-dependencies accordingly.
* Removed libmodule-build-perl and libtest-harness-perl from
  Build-Depends-Indep (provided by perl-modules).
* Better cleaning of empty directories using find -type d -empty -delete
  instead of rmdir in debian/rules (LP: #324001).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*-Perl-*- Test Harness script for Bioperl
 
2
# $Id: GFF.t 15112 2008-12-08 18:12:38Z sendu $
 
3
 
 
4
use strict;
 
5
 
 
6
BEGIN {     
 
7
    use lib '.';
 
8
    use Bio::Root::Test;
 
9
    
 
10
    test_begin(-tests => 34);
 
11
        
 
12
    use_ok('Bio::Tools::GFF');
 
13
    use_ok('Bio::SeqFeature::Generic');
 
14
}
 
15
 
 
16
my $feat = Bio::SeqFeature::Generic->new( -start => 10, -end => 100,
 
17
                                -strand => -1, -primary => 'repeat',
 
18
                                -source => 'repeatmasker',
 
19
                                -score  => 1000,
 
20
                                -tag    => {
 
21
                                    new => 1,
 
22
                                    author => 'someone',
 
23
                                    sillytag => 'this is silly!;breakfast' } );
 
24
ok($feat);
 
25
 
 
26
my ($out1, $out2) = (test_output_file(), test_output_file());
 
27
my $gff1out = Bio::Tools::GFF->new(-gff_version => 1, -file => ">$out1");
 
28
ok($gff1out);
 
29
my $gff2out = Bio::Tools::GFF->new(-gff_version => 2, -file => ">$out2");
 
30
ok($gff2out);
 
31
 
 
32
$gff1out->write_feature($feat);
 
33
$gff2out->write_feature($feat);
 
34
 
 
35
$gff1out->close();
 
36
$gff2out->close();
 
37
 
 
38
my $gff1in = Bio::Tools::GFF->new(-gff_version => 1,  -file => "$out1");
 
39
ok($gff1in);
 
40
my $gff2in = Bio::Tools::GFF->new(-gff_version => 2, -file => "$out2");
 
41
ok($gff2in);
 
42
 
 
43
my $feat1 = $gff1in->next_feature();
 
44
ok($feat1);
 
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);
 
49
 
 
50
my $feat2 = $gff2in->next_feature();
 
51
ok($feat2);
 
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');
 
57
 
 
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);
 
64
is($seq->start, 1);
 
65
 
 
66
 
 
67
# GFF3
 
68
SKIP: {
 
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',
 
75
     -seq_id      => 'testseq',
 
76
     -score       => undef,
 
77
     -start       => 10,
 
78
     -end         => 120,
 
79
     -strand      => 1,
 
80
     -tag         => { 
 
81
         'bungle' => 'jungle;mumble',
 
82
         'lion'   => 'snake=tree'
 
83
         });
 
84
    $feat_test->add_tag_value('giant_squid', 'lakeshore manor');
 
85
    $gffout->write_feature($feat_test);
 
86
    seek($str,0,0);
 
87
    my $in = Bio::Tools::GFF->new(-fh          => $str,
 
88
                 -gff_version => 3);
 
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);
 
101
            while( @v && @g ) {
 
102
               is(shift @v, shift @g);
 
103
            }
 
104
        }
 
105
    }
 
106
}