diff --git a/modules/Bio/EnsEMBL/Analysis/Genscan.pm b/modules/Bio/EnsEMBL/Analysis/Genscan.pm index d61efb1441739273cbdbac2fdb4370a5c75bd38f..3f494228b2f720e4b4b00b3f811b0db529c4e1ba 100755 --- a/modules/Bio/EnsEMBL/Analysis/Genscan.pm +++ b/modules/Bio/EnsEMBL/Analysis/Genscan.pm @@ -334,7 +334,7 @@ EXON: foreach my $exon ($tran->each_Exon) { $trans[2] = $exseq->translate('*','X',1); my $i = 0; - $phase; + $phase = 4; # Loop over all frames 0,1,2 for ($i=0; $i < 3; $i++) { diff --git a/modules/Bio/EnsEMBL/DBSQL/Contig.pm b/modules/Bio/EnsEMBL/DBSQL/Contig.pm index a078ddb9d0f2a3ff82d076b522940749504ddf60..ec51f4f9b4470aa60bbb7ddb07500c086bc422df 100755 --- a/modules/Bio/EnsEMBL/DBSQL/Contig.pm +++ b/modules/Bio/EnsEMBL/DBSQL/Contig.pm @@ -249,6 +249,9 @@ sub get_all_SimilarityFeatures{ $analysis = $analhash{$analysisid}; } + if( !defined $name ) { + $name = 'no_source'; + } if( $hid ne '__NONE__' ) { # is a paired feature diff --git a/modules/Bio/EnsEMBL/DBSQL/Obj.pm b/modules/Bio/EnsEMBL/DBSQL/Obj.pm index b8dea01cf08251dc0e6260cbf391e53235df9f50..aeee17a013e23d94f931f4fbe672b5a8b7e82656 100755 --- a/modules/Bio/EnsEMBL/DBSQL/Obj.pm +++ b/modules/Bio/EnsEMBL/DBSQL/Obj.pm @@ -1091,9 +1091,7 @@ sub delete_Gene{ sub geneid_to_cloneid{ my ($self,$geneid) = @_; - my $sth = $self->prepare("select count(*),cl.id, cont.clone ,ex.contig, tran.gene from clone as cl,contig as cont, transcript as tran, exon_transcript as et, exon as ex where ex.id = et.exon and tran.id = et.transcript and ex.contig = cont.id and cont.clone = cl.id and tran.gene = '$geneid' group by cl.id"); - -# my $sth = $self->prepare("select p1.id from contig as p1, transcript as p2, exon_transcript as p3 where p2.gene = '$geneid' and p2.id = p3.transcript and p3 "); + my $sth = $self->prepare("select p1.id from contig as p1, transcript as p2, exon_transcript as p3 where p2.gene = '$geneid' and p2.id = p3.transcript and p3 "); my @out; diff --git a/modules/Bio/EnsEMBL/Exon.pm b/modules/Bio/EnsEMBL/Exon.pm index 14303e93e034b86c39a1d1aa901c5854ea48ae7d..ac00d8cdaf2b6397deb611f711cbb0b7c91241d0 100755 --- a/modules/Bio/EnsEMBL/Exon.pm +++ b/modules/Bio/EnsEMBL/Exon.pm @@ -84,6 +84,7 @@ use strict; # Object preamble - inherits from Bio::SeqFeature::Generic use Bio::SeqFeature::Generic; +use Bio::Seq; # exons have to have sequences... @ISA = qw(Bio::SeqFeature::Generic Exporter); # new() is inherited from Bio::Root::Object diff --git a/modules/Bio/EnsEMBL/PerlDB/Clone.pm b/modules/Bio/EnsEMBL/PerlDB/Clone.pm index f7c28f5b3b8376b9d92161656407d4b72a0e72a2..377fe9019a54a373c7aa2aa9492bb61fa6592e2a 100755 --- a/modules/Bio/EnsEMBL/PerlDB/Clone.pm +++ b/modules/Bio/EnsEMBL/PerlDB/Clone.pm @@ -175,6 +175,110 @@ sub id{ } +=head2 embl_id + + Title : embl_id + Usage : $obj->embl_id($newval) + Function: + Returns : value of embl_id + Args : newvalue (optional) + + +=cut + +sub embl_id{ + my $obj = shift; + if( @_ ) { + my $value = shift; + $obj->{'embl_id'} = $value; + } + return $obj->{'embl_id'}; + +} + +=head2 embl_version + + Title : embl_version + Usage : $obj->embl_version($newval) + Function: + Returns : value of embl_version + Args : newvalue (optional) + + +=cut + +sub embl_version{ + my $obj = shift; + if( @_ ) { + my $value = shift; + $obj->{'embl_version'} = $value; + } + return $obj->{'embl_version'}; + +} + +=head2 seq_date + + Title : seq_date + Usage : $obj->seq_date($newval) + Function: + Returns : value of seq_date + Args : newvalue (optional) + + +=cut + +sub seq_date{ + my $obj = shift; + if( @_ ) { + my $value = shift; + $obj->{'seq_date'} = $value; + } + return $obj->{'seq_date'}; + +} + +=head2 version + + Title : version + Usage : $obj->version($newval) + Function: + Returns : value of version + Args : newvalue (optional) + + +=cut + +sub version{ + my $obj = shift; + if( @_ ) { + my $value = shift; + $obj->{'version'} = $value; + } + return $obj->{'version'}; + +} +=head2 htg_phase + + Title : htg_phase + Usage : $obj->htg_phase($newval) + Function: + Returns : value of htg_phase + Args : newvalue (optional) + + +=cut + +sub htg_phase{ + my $obj = shift; + if( @_ ) { + my $value = shift; + $obj->{'htg_phase'} = $value; + } + return $obj->{'htg_phase'}; + +} + 1; diff --git a/modules/Bio/EnsEMBL/PerlDB/Contig.pm b/modules/Bio/EnsEMBL/PerlDB/Contig.pm index 040becf09b94f30a4ab07dc6175268b8efca93d0..35b553d6b38bcef4ac2c57d90d956d67a4abda92 100755 --- a/modules/Bio/EnsEMBL/PerlDB/Contig.pm +++ b/modules/Bio/EnsEMBL/PerlDB/Contig.pm @@ -62,7 +62,8 @@ sub _initialize { my $make = $self->SUPER::_initialize; - $self->{'_sf_array'} = []; + $self->{'_repeat_array'} = []; + $self->{'_simil_array'} = []; $self->{'_gene_array'} = []; # set stuff in self from @args @@ -70,9 +71,9 @@ sub _initialize { } -=head2 get_all_SeqFeatures +=head2 get_all_Genes - Title : get_all_SeqFeatures + Title : get_all_Genes Usage : Function: Example : @@ -82,15 +83,16 @@ sub _initialize { =cut -sub get_all_SeqFeatures{ +sub get_all_Genes{ my ($self) = @_; - - return @{$self->{'_sf_array'}}; + + return @{$self->{'_gene_array'}}; } -=head2 get_all_Genes - Title : get_all_Genes +=head2 add_Gene + + Title : add_Gene Usage : Function: Example : @@ -100,15 +102,19 @@ sub get_all_SeqFeatures{ =cut -sub get_all_Genes{ - my ($self) = @_; - - return @{$self->{'_gene_array'}}; +sub add_Gene{ + my ($self,$gene) = @_; + + if( !$gene->isa("Bio::EnsEMBL::Gene") ) { + $self->throw("$gene is a not a Bio::EnsEMBL::Gene type"); + } + + push(@{$self->{'_gene_array'}},$gene); } -=head2 add_SeqFeature +=head2 get_all_RepeatFeatures - Title : add_SeqFeature + Title : get_all_RepeatFeatures Usage : Function: Example : @@ -118,19 +124,38 @@ sub get_all_Genes{ =cut -sub add_SeqFeature{ - my ($self,$sf) = @_; +sub get_all_RepeatFeatures{ + my ($self,@args) = @_; + + return @{$self->{'_repeat_array'}}; +} + +=head2 add_RepeatFeature + + Title : add_RepeatFeature + Usage : + Function: + Example : + Returns : + Args : - if( $sf->isa("Bio::SeqFeatureI") ) { - $self->throw("$sf is a not a SeqFeatureI type"); + +=cut + +sub add_RepeatFeature{ + my ($self,$value) = @_; + + if( !ref $value || !$value->isa('Bio::EnsEMBL::Repeat') ) { + $self->throw("$value is not a repeat"); } - push(@{$self->{'_sf_array'}},$sf); + push(@{$self->{'_repeat_array'}},$value); } -=head2 add_Gene - Title : add_Gene +=head2 get_all_SimilarityFeatures + + Title : get_all_SimilarityFeatures Usage : Function: Example : @@ -140,16 +165,35 @@ sub add_SeqFeature{ =cut -sub add_Gene{ - my ($self,$gene) = @_; +sub get_all_SimilarityFeatures{ + my ($self,@args) = @_; - if( !$gene->isa("Bio::EnsEMBL::Gene") ) { - $self->throw("$gene is a not a Bio::EnsEMBL::Gene type"); + return @{$self->{'_simil_array'}}; +} + +=head2 add_SimilarityFeatures + + Title : add_SimilarityFeatures + Usage : + Function: + Example : + Returns : + Args : + + +=cut + +sub add_SimilarityFeatures { + my ($self,$value) = @_; + + if( !ref $value || !$value->isa('Bio::EnsEMBL::FeaturePair') ) { + $self->throw("$value is not a FeaturePair"); } - push(@{$self->{'_gene_array'}},$gene); + push(@{$self->{'_simil_array'}},$value); } + =head2 offset Title : offset @@ -192,6 +236,27 @@ sub orientation{ } +=head2 order + + Title : order + Usage : $obj->order($newval) + Function: + Returns : value of order + Args : newvalue (optional) + + +=cut + +sub order{ + my $obj = shift; + if( @_ ) { + my $value = shift; + $obj->{'order'} = $value; + } + return $obj->{'order'}; + +} + =head2 seq @@ -240,4 +305,25 @@ sub id{ } +=head2 version + + Title : version + Usage : $obj->version($newval) + Function: + Returns : value of version + Args : newvalue (optional) + + +=cut + +sub version{ + my $obj = shift; + if( @_ ) { + my $value = shift; + $obj->{'version'} = $value; + } + return $obj->{'version'}; + +} + 1; diff --git a/modules/Bio/EnsEMBL/Repeat.pm b/modules/Bio/EnsEMBL/Repeat.pm index 67f73f3a399bad056e48462fb55f7f816d6a1505..17855c79187be1c43a4a952fa0d8b5bf0bf794cc 100755 --- a/modules/Bio/EnsEMBL/Repeat.pm +++ b/modules/Bio/EnsEMBL/Repeat.pm @@ -11,25 +11,11 @@ =head1 NAME -Bio::EnsEMBL::Repeat +Bio::EnsEMBL::Repeat - Object for repeats =head1 SYNOPSIS - -=head1 DESCRIPTION - -Extends Bio::EnsEMBL::FeaturePair to store -genomic repeat features. - -Creation: - - my $rep = new Bio::EnsEMBL::Repeat(-start => $start, - -end => $end, - -strand => $strand, - -source => $source, - -primary=> $primary, - ); - -Manipulation: + + # behaves exactly like a Bio::EnsEMBL::FeaturePair my $start = $rep->start; my $end = $rep->end; @@ -38,6 +24,14 @@ Manipulation: my $repstart = $rep->hstart; my $repend = $rep->hend; +=head1 DESCRIPTION + +Extends Bio::EnsEMBL::FeaturePair to store +genomic repeat features. Only here really so we can +put in to_FTHelper (EMBL/GenBank dumping code) +specific to repeats. + + =head1 CONTACT diff --git a/modules/Bio/EnsEMBL/SeqFeature.pm b/modules/Bio/EnsEMBL/SeqFeature.pm index afdbdfb1cbb20f1828908ca1713dbe97e2f6036c..66e2e016154ed84b91bf1599ce0cbf71e82e0a62 100755 --- a/modules/Bio/EnsEMBL/SeqFeature.pm +++ b/modules/Bio/EnsEMBL/SeqFeature.pm @@ -392,17 +392,17 @@ sub validate { sub vthrow { my ($self,$message) = @_; - print("Error validating feature [$message]\n"); - print(" Seqname : [" . $self->{_gsf_seqname} . "]\n"); - print(" Start : [" . $self->{_gsf_start} . "]\n"); - print(" End : [" . $self->{_gsf_end} . "]\n"); - print(" Strand : [" . $self->{_gsf_strand} . "]\n"); - print(" Score : [" . $self->{_gsf_score} . "]\n"); - print(" Source_tag : [" . $self->{_source_tag} . "]\n"); - print(" Primary_tag : [" . $self->{_primary_tag} . "]\n"); - print(" Analysis : [" . $self->{_analysis} . "]\n"); - - $self->throw(""); + print(STDERR "Error validating feature [$message]\n"); + print(STDERR " Seqname : [" . $self->{_gsf_seqname} . "]\n"); + print(STDERR " Start : [" . $self->{_gsf_start} . "]\n"); + print(STDERR " End : [" . $self->{_gsf_end} . "]\n"); + print(STDERR " Strand : [" . $self->{_gsf_strand} . "]\n"); + print(STDERR " Score : [" . $self->{_gsf_score} . "]\n"); + print(STDERR " Source_tag : [" . $self->{_source_tag} . "]\n"); + print(STDERR " Primary_tag : [" . $self->{_primary_tag} . "]\n"); + print(STDERR " Analysis : [" . $self->{_analysis} . "]\n"); + + $self->throw("Invalid feature - see dump on STDERR"); } # These methods are specified in the SeqFeatureI interface but we don't want # people to store data in them. These are just here in order to keep diff --git a/modules/t/DB.t b/modules/t/DB.t index 2718a5462fb7c1f423d8dfd64c15955562088204..45ace1ea930cb39cae62ab60cc5c19e2b8318deb 100755 --- a/modules/t/DB.t +++ b/modules/t/DB.t @@ -21,7 +21,7 @@ ## We start with some black magic to print on failure. -BEGIN { $| = 1; print "1..5\n"; +BEGIN { $| = 1; print "1..7\n"; use vars qw($loaded); } END {print "not ok 1\n" unless $loaded;} @@ -67,18 +67,33 @@ if( $@ ) { print "ok 2\n"; @cloneids = $db->get_all_Clone_id(); my $clone = $db->get_Clone($cloneids[0]); + +# check clone stuff. +$discard = $clone->htg_phase(); +$discard = $clone->embl_id(); +$discard = $clone->version(); +$discard = $clone->embl_version(); print "ok 3\n"; + my @contigs = $clone->get_all_Contigs(); my $contig = $db->get_Contig($contigs[0]->id); print "ok 4\n"; +@repeats = $contig->get_all_RepeatFeatures(); +@repeats = (); +print "ok 5\n"; + +@simil = $contig->get_all_SimilarityFeatures(); +@simil = (); +print "ok 6\n"; + foreach $gene ( $clone->get_all_Genes() ) { if( ! $gene->isa("Bio::EnsEMBL::Gene") ) { - print "not ok 5\n"; + print "not ok 7\n"; exit(1); } } -print "ok 5\n"; +print "ok 7\n"; diff --git a/modules/t/EmblDump.t b/modules/t/EmblDump.t index c6b281640c0435e8bfd0e72fc4abeb8ff69e7985..fd9ae3442eb8287cafcb4373535c382c0cccd056 100755 --- a/modules/t/EmblDump.t +++ b/modules/t/EmblDump.t @@ -50,13 +50,15 @@ $seq = Bio::Seq->new( -id => 'Contig-1' , -seq => 'ATGGCGGATGTTTATGTGGGTGGCCCGGG #$contig->add_SeqFeature($sf); $contig->offset(1); $contig->orientation(1); +$contig->order(1); $contig->seq($seq); $contig->id('Contig-1'); $seq2 = Bio::Seq->new( -id => 'Contig-2' , -seq => 'TCAGAAATTTGGGTGTTTTGGCCCTGGTGGTTTGGGTTT' ); $contig2 = Bio::EnsEMBL::PerlDB::Contig->new(); -$contig2->offset(60); +$contig2->offset(900); $contig2->orientation(1); +$contig2->order(2); $contig2->id('Contig-2'); $contig2->seq($seq2); @@ -71,11 +73,11 @@ $ex1->start(8); $ex1->end(13); $ex1->phase(0); $ex1->strand(1); -$ex1->attach_seq($seq2); -$ex1->contig_id('Contig-2'); +$ex1->attach_seq($seq); +$ex1->contig_id('Contig-1'); $ex1->clone_id('test-clone'); -$ex1->created('dummy_creation_date'); -$ex1->modified('dummy_modification_date'); +$ex1->created(time()); +$ex1->modified(time()); $ex1->id('exon-id-1'); $ex2->start(18); @@ -85,8 +87,8 @@ $ex2->strand(1); $ex2->attach_seq($seq2); $ex2->contig_id('Contig-2'); $ex2->clone_id('test-clone'); -$ex2->created('dummy_creation_date'); -$ex2->modified('dummy_modification_date'); +$ex2->created(time()); +$ex2->modified(time()); $ex2->id('exon-id-2'); $gene->id('gene-id'); @@ -95,6 +97,13 @@ $tr->id('transcript-id'); $tr->add_Exon($ex1); $tr->add_Exon($ex2); +$trans = Bio::EnsEMBL::Translation->new(); +$trans->start_exon_id('exon-id-1'); +$trans->end_exon_id('exon-id-2'); +$trans->start(8); +$trans->end(23); +$tr->translation($trans); +$tr->id('peptide-id'); $gene->add_Transcript($tr); $contig->add_Gene($gene); @@ -113,7 +122,7 @@ $clone->add_Contig($contig2); print "ok 2\n"; $as = $clone->get_AnnSeq(); -$asio = Bio::AnnSeqIO->new(-format => 'EMBL' , -fh => \*STDERR ) ; +$asio = Bio::AnnSeqIO->new( '-format' => 'EMBL' , -fh => \*STDERR ) ; $asio->_post_sort(\&sort_FTHelper_EnsEMBL); $asio->write_annseq($as); diff --git a/modules/t/Gene.t b/modules/t/Gene.t index 379762e834902372c061c9e8a372b29c6a42689f..ea0ddf85cb6212ca375b15193fd1048b826726b2 100755 --- a/modules/t/Gene.t +++ b/modules/t/Gene.t @@ -21,7 +21,7 @@ ## We start with some black magic to print on failure. -BEGIN { $| = 1; print "1..8\n"; +BEGIN { $| = 1; print "1..9\n"; use vars qw($loaded); } END {print "not ok 1\n" unless $loaded;} @@ -29,6 +29,7 @@ END {print "not ok 1\n" unless $loaded;} use Bio::EnsEMBL::Gene; use Bio::EnsEMBL::Transcript; use Bio::EnsEMBL::Exon; +use Bio::EnsEMBL::Translation; $loaded = 1; print "ok 1\n"; # 1st test passes. @@ -43,33 +44,54 @@ $ex2 = new Bio::EnsEMBL::Exon; $ex3 = new Bio::EnsEMBL::Exon; print "ok 4\n"; +$seq = Bio::Seq->new( -id => 'Contig-1' , -seq => 'ATGGCGGATGTTTATGTGGGTGGCCCGGGG' ); +$seq2 = Bio::Seq->new( -id => 'Contig-2' , -seq => 'TCAGAAATTTGGGTGTTTTGGCCCTGGTGGTTTGGGTTT' ); + $ex1->id("dummy_id_1"); $ex1->contig_id("c_id_1"); -$ex1->start(10); -$ex1->end(20); +$ex1->phase(0); +$ex1->start(8); +$ex1->end(13); +$ex1->attach_seq($seq); $ex1->strand(1); $ex2->id("dummy_id_2"); -$ex2->contig_id("c_id_1"); -$ex2->start(40); -$ex2->end(50); +$ex2->contig_id("c_id_2"); +$ex2->phase(0); +$ex2->start(18); +$ex2->end(23); +$ex2->attach_seq($seq2); $ex2->strand(1); $ex3->id("dummy_id_3"); $ex3->contig_id("c_id_2"); -$ex3->start(40); -$ex3->end(50); +$ex3->phase(0); +$ex3->start(26); +$ex3->end(28); +$ex3->attach_seq($seq2); $ex3->strand(1); $tr->add_Exon($ex1); $tr->add_Exon($ex2); - -$tr->add_Exon($ex1); -$tr->add_Exon($ex2); -$tr->add_Exon($ex3); +$trans = Bio::EnsEMBL::Translation->new(); +$trans->start_exon_id('dummy_id_1'); +$trans->start(8); +$trans->end_exon_id('dummy_id_2'); +$trans->end(23); +$tr->translation($trans); + +$tr1->add_Exon($ex1); +$tr1->add_Exon($ex2); +$tr1->add_Exon($ex3); +$trans = Bio::EnsEMBL::Translation->new(); +$trans->start_exon_id('dummy_id_1'); +$trans->start(8); +$trans->end_exon_id('dummy_id_3'); +$trans->end(28); +$tr1->translation($trans); $gene->add_Transcript($tr); $gene->add_Transcript($tr1); @@ -110,6 +132,11 @@ if( scalar @contigs != 2 ) { print "ok 8\n"; } +foreach $trans ( $gene->each_Transcript ) { + $pep = $trans->translate(); + } +print "ok 9\n"; +$pep = 0; diff --git a/modules/t/Ghost.t b/modules/t/Ghost.t index 6fc0fb33da4899426fcede0c7083874e97efcde4..bad18212c27133bdadf6bb7a0b691a78faa15a75 100755 --- a/modules/t/Ghost.t +++ b/modules/t/Ghost.t @@ -27,6 +27,7 @@ BEGIN { $| = 1; print "1..2\n"; END {print "not ok 1\n" unless $loaded;} use Bio::EnsEMBL::Ghost; +$loaded = 1; print "ok 1\n"; # 1st test passes. $ghost = new Bio::EnsEMBL::Ghost;