Permalink
Browse files

add some more tests

  • Loading branch information...
1 parent c6bc148 commit 55105bde726b57ba7bc9571d8534051729d16401 @rbuels rbuels committed Apr 13, 2012
Showing with 57 additions and 0 deletions.
  1. +25 −0 t/data/spec_eden.gff3
  2. +3 −0 t/data/spec_match.gff3
  3. +29 −0 t/parser.t
View
@@ -0,0 +1,25 @@
+##gff-version 3
+##sequence-region ctg123 1 1497228
+ctg123 . gene 1000 9000 . + . ID=gene00001;Name=EDEN
+ctg123 . TF_binding_site 1000 1012 . + . Parent=gene00001
+ctg123 . mRNA 1050 9000 . + . ID=mRNA00001;Parent=gene00001
+ctg123 . mRNA 1050 9000 . + . ID=mRNA00002;Parent=gene00001
+ctg123 . mRNA 1300 9000 . + . ID=mRNA00003;Parent=gene00001
+ctg123 . exon 1300 1500 . + . Parent=mRNA00003
+ctg123 . exon 1050 1500 . + . Parent=mRNA00001,mRNA00002
+ctg123 . exon 3000 3902 . + . Parent=mRNA00001,mRNA00003
+ctg123 . exon 5000 5500 . + . Parent=mRNA00001,mRNA00002,mRNA00003
+ctg123 . exon 7000 9000 . + . Parent=mRNA00001,mRNA00002,mRNA00003
+ctg123 . CDS 1201 1500 . + 0 ID=cds00001;Parent=mRNA00001
+ctg123 . CDS 3000 3902 . + 0 ID=cds00001;Parent=mRNA00001
+ctg123 . CDS 5000 5500 . + 0 ID=cds00001;Parent=mRNA00001
+ctg123 . CDS 7000 7600 . + 0 ID=cds00001;Parent=mRNA00001
+ctg123 . CDS 1201 1500 . + 0 ID=cds00002;Parent=mRNA00002
+ctg123 . CDS 5000 5500 . + 0 ID=cds00002;Parent=mRNA00002
+ctg123 . CDS 7000 7600 . + 0 ID=cds00002;Parent=mRNA00002
+ctg123 . CDS 3301 3902 . + 0 ID=cds00003;Parent=mRNA00003
+ctg123 . CDS 5000 5500 . + 1 ID=cds00003;Parent=mRNA00003
+ctg123 . CDS 7000 7600 . + 1 ID=cds00003;Parent=mRNA00003
+ctg123 . CDS 3391 3902 . + 0 ID=cds00004;Parent=mRNA00003
+ctg123 . CDS 5000 5500 . + 1 ID=cds00004;Parent=mRNA00003
+ctg123 . CDS 7000 7600 . + 1 ID=cds00004;Parent=mRNA00003
@@ -0,0 +1,3 @@
+ctg123 . cDNA_match 1050 1500 5.8e-42 + . ID=match00001;Target=cdna0123 12 462
+ctg123 . cDNA_match 5000 5500 8.1e-43 + . ID=match00001;Target=cdna0123 463 963
+ctg123 . cDNA_match 7000 9000 1.4e-40 + . ID=match00001;Target=cdna0123 964 2964
View
@@ -57,6 +57,8 @@ for (
[ 6, 'knownGene2.gff3' ],
[ 11, 'mm9_sample_ensembl.gff3' ],
[ 16, 'tomato_test.gff3' ],
+ [ 3, 'spec_eden.gff3' ],
+ [ 1, 'spec_match.gff3' ],
) {
my ( $count, $f ) = @$_;
my $p = Bio::GFF3::LowLevel::Parser->open( catfile(qw( t data ), $f ));
@@ -111,6 +113,33 @@ EOG
is( $stuff[5]{directive}, 'FASTA', 'and last thing is a FASTA directive' );
}
+
+# try parsing the EDEN gene from the gff3 spec
+{
+ my $p = Bio::GFF3::LowLevel::Parser->open( catfile(qw( t data spec_eden.gff3 )));
+ my @stuff; push @stuff, $_ while $_ = $p->next_item;
+ my $eden = $stuff[2];
+ is( scalar(@$eden), 1 );
+ $eden = $eden->[0];
+ is( scalar(@{ $eden->{child_features} }), 4, 'right number of EDEN child features' );
+
+ is( $eden->{child_features}[0][0]{type}, 'TF_binding_site' );
+
+ # all the rest are mRNAs
+ my @mrnas = @{ $eden->{child_features} }[1..3];
+ is( scalar( grep @$_ == 1, @mrnas ), 3, 'all unique-IDed' );
+ @mrnas = map $_->[0], @mrnas;
+ is( scalar( grep $_->{type} eq 'mRNA', @mrnas ), 3, 'all mRNAs' );
+ # check that all the mRNAs share the last exon
+ my $last_exon = $mrnas[2]{child_features}[3][0];
+ is( $last_exon, $mrnas[0]{child_features}[3][0] );
+ is( $last_exon, $mrnas[1]{child_features}[2][0] );
+ is( scalar(@{ $mrnas[2]{child_features}} ), 6, 'mRNA00003 has 6 children' )
+ or diag explain $mrnas[2]{child_features};
+ is( scalar(@{ $mrnas[1]{child_features}} ), 4, 'mRNA00002 has 4 children' );
+ is( scalar(@{ $mrnas[0]{child_features}} ), 5, 'mRNA00001 has 5 children' );
+}
+
done_testing;
sub slurp_fh {

0 comments on commit 55105bd

Please sign in to comment.