Skip to content
Snippets Groups Projects
Commit bc3074db authored by Arne Stabenau's avatar Arne Stabenau
Browse files

added supporting feature test

parent 3841d1bd
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ use warnings;
BEGIN { $| = 1;
use Test;
plan tests => 22;
plan tests => 26;
}
use MultiTestDB;
......@@ -13,7 +13,8 @@ use TestUtils qw ( debug );
use Bio::EnsEMBL::Gene;
# switch on the debug prints
my $verbose = 0;
our $verbose = 0;
debug( "Startup test" );
ok(1);
......@@ -58,11 +59,16 @@ ok( scalar @$links == 6 );
# now create a new gene ...
my $slice = $db->get_SliceAdaptor()->fetch_by_chr_start_end( "20",30264615, 30265615 );
my $sa = $db->get_SliceAdaptor();
my $slice = $sa->fetch_by_chr_start_end( "20", 30_249_935, 31_254_640 );
debug( "Slice from SliceAdaptor" );
ok($slice);
my $analysis = $db->get_AnalysisAdaptor->fetch_by_logic_name("ensembl");
my $f_analysis = $db->get_AnalysisAdaptor->fetch_by_logic_name("Vertrna");
debug( "Analysis from AnalysisAdaptor" );
ok($analysis);
......@@ -82,26 +88,106 @@ my $translation2 = Bio::EnsEMBL::Translation->new();
ok($gene);
$ex1->start(5);
$ex1->end(10);
$ex1->start( 13586 );
$ex1->end( 13735 );
$ex1->phase(0);
$ex1->end_phase( 0 );
$ex1->contig( $slice );
$ex1->strand(1);
$ex1->analysis($analysis);
$ex2->start(15);
$ex2->end(23);
my @feats;
my $fp = new Bio::EnsEMBL::FeaturePair;
$fp->start(13586);
$fp->end (13705);
$fp->strand(1);
$fp->score(10);
$fp->contig($slice);
$fp->hstart(100);
$fp->hend (219);
$fp->hstrand (1);
$fp->hseqname('dummy-hid');
push(@feats,$fp);
$fp = new Bio::EnsEMBL::FeaturePair;
$fp->start(13707);
$fp->end (13735);
$fp->strand(1);
$fp->score(10);
$fp->contig($slice);
$fp->seqname(1);
$fp->hstart (220);
$fp->hend (248);
$fp->hstrand (1);
$fp->hseqname('dummy-hid');
push(@feats,$fp);
#
#
# 2 Test DnaDnaAlignFeature::new(-features)
#
my $dnaf = Bio::EnsEMBL::DnaDnaAlignFeature->new( -features => \@feats );
$dnaf->analysis( $f_analysis );
$ex1->add_supporting_features( $dnaf );
$ex2->start(201372);
$ex2->end(201571);
$ex2->phase(0);
$ex2->end_phase( 0 );
$ex2->end_phase( -1 );
$ex2->contig( $slice );
$ex2->strand(1);
$ex2->analysis($analysis);
$ex3->start(28);
$ex3->end(33);
$ex3->phase(0);
$ex3->end_phase( 0 );
@feats = ();
$fp = new Bio::EnsEMBL::FeaturePair;
$fp->start(201372);
$fp->end (201471);
$fp->strand(1);
$fp->score(10);
$fp->contig($slice);
$fp->hstart(100);
$fp->hend (199);
$fp->hstrand (1);
$fp->hseqname('dummy-hid');
push(@feats,$fp);
$fp = new Bio::EnsEMBL::FeaturePair;
$fp->start(201472);
$fp->end (201571);
$fp->strand(1);
$fp->score(10);
$fp->contig($slice);
$fp->seqname(1);
$fp->hstart (201);
$fp->hend (300);
$fp->hstrand (1);
$fp->hseqname('dummy-hid');
push(@feats,$fp);
#
#
# 2 Test DnaDnaAlignFeature::new(-features)
#
$dnaf = Bio::EnsEMBL::DnaDnaAlignFeature->new( -features => \@feats );
$dnaf->analysis( $f_analysis );
$ex2->add_supporting_features( $dnaf );
$ex3->start(210600);
$ex3->end(210800);
$ex3->phase(-1);
$ex3->end_phase( -1 );
$ex3->contig( $slice );
$ex3->strand(1);
$ex3->analysis($analysis);
......@@ -111,7 +197,7 @@ $transcript1->add_Exon($ex2);
$translation1->start_Exon($ex1);
$translation1->end_Exon($ex2);
$translation1->start(1);
$translation1->end(9);
$translation1->end(150);
$transcript1->translation($translation1);
......@@ -119,9 +205,9 @@ $transcript2->add_Exon($ex1);
$transcript2->add_Exon($ex2);
$transcript2->add_Exon($ex3);
$translation2->start_Exon($ex1);
$translation2->end_Exon($ex3);
$translation2->end_Exon($ex2);
$translation2->start(1);
$translation2->end(6);
$translation2->end(180);
$transcript2->translation($translation2);
debug( "Transcripts created" );
......@@ -136,8 +222,14 @@ $gene->analysis($analysis);
debug( "Getting all the Transcripts/Exons from new Gene" );
my $count = 0;
my $translates = 1;
foreach my $tr( @{$gene->get_all_Transcripts()} ) {
if( $tr->translate()->seq() =~ /\*./ ) {
$translates = 0;
debug( "Translate failed.".$tr->translate()->seq() );
}
foreach my $exon ( @{$tr->get_all_Exons()} ) {
debug( " Exon start: ". $exon->start());
debug( " Exon end: ". $exon->end() );
......@@ -147,11 +239,12 @@ foreach my $tr( @{$gene->get_all_Transcripts()} ) {
}
ok($count == 5);
ok( $translates );
ok( scalar(@{$gene->get_all_Exons()} ) == 3);
$gene->transform();
$multi->hide( "core", "gene", "transcript", "exon", "exon_transcript", "gene_description", "translation", "gene_stable_id", "transcript_stable_id", "exon_stable_id", "translation_stable_id" );
$multi->hide( "core", "gene", "transcript", "exon", "exon_transcript", "gene_description", "translation", "gene_stable_id", "transcript_stable_id", "exon_stable_id", "translation_stable_id", "supporting_feature", "dna_align_feature" );
my $gene_ad = $db->get_GeneAdaptor();
debug( "Storing the gene" );
......@@ -159,9 +252,7 @@ $gene_ad->store($gene);
ok(1);
my $new_slice = $db->get_SliceAdaptor()->fetch_by_chr_start_end( "20",30263615, 30265615 );
my $genes = $new_slice->get_all_Genes();
my $genes = $slice->get_all_Genes();
......@@ -181,9 +272,11 @@ foreach my $tr( @{$gene_out->get_all_Transcripts()} ) {
my $exons = $gene_out->get_all_Transcripts()->[0]->get_all_Exons();
ok($exons->[0]->start==1005);
ok($exons->[1]->strand==1);
ok($exons->[1]->phase==0);
ok( $exons->[0]->start == 13586 );
ok( $exons->[1]->strand == 1 );
ok( $exons->[1]->phase == 0 );
......@@ -204,7 +297,26 @@ foreach my $trans( @{$gene_out->get_all_Transcripts()} ){
ok($translate == 1);
my $t = $gene_out->get_all_Transcripts()->[1];
my $e = $t->get_all_Exons()->[0];
my $se = $e->get_all_supporting_features();
debug( "Got ".scalar( @$se )." supporting features." );
ok( scalar( @$se ) == 2 );
my $se_start = $se->[0]->start() < $se->[1]->start() ?
$se->[0]->start() : $se->[1]->start();
my $se_end = $se->[0]->end() > $se->[1]->end() ?
$se->[0]->end() : $se->[1]->end();
debug( "Supporting start $se_start, end $se_end" );
debug( "Exon start ".$e->start()." end ".$e->end() );
ok( $se_start == $e->start() );
ok( $se_end == $e->end() );
my $pep1 = $t->translate()->seq();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment