Commit 338e7d8b authored by Michele Clamp's avatar Michele Clamp
Browse files

BaseAlignFeature - checks for defined percent_id

Exon - checks phase is defined before comparison
PredictionTranscript - checks phase is defined.  Commented out LOG print statements
TranscriptFactory - start_exon end_exon same old thang
ExonAdaptor - hmm.
parent 9440d0ed
......@@ -536,7 +536,7 @@ sub _parse_features {
$self->throw("Inconsisent scores in feature array [$score - " .
$f->score . "]");
}
if ($percent ne $f->percent_id) {
if (defined($f->percent_id) && $percent ne $f->percent_id) {
$self->throw("Inconsistent pids in feature array [$percent - " .
$f->percent_id . "]");
}
......
# EnsEMBL Exon reading writing adaptor for mySQL
#EnsEMBL Exon reading writing adaptor for mySQL
#
# Copyright EMBL-EBI 2001
#
......@@ -328,6 +328,64 @@ sub _new_Exon_from_hashRef {
=head2 fetch_evidence_by_Exon
Arg [1] : Bio::EnsEMBL::Exon - the exon to fetch evidence for
Example : $exon_adaptor->fetch_evidence_by_Exon($exon);
Description: Currently appears to be broken, and supporting features are
being reworked as I write this. Not sure what the fate of
this method will be. Should retrieves supporting evidence
for an exon.
Returntype : none
Exceptions : none
Caller : Bio::EnsEMBL::Exon
=cut
sub fetch_evidence_by_Exon {
my ( $self, $exon ) = @_;
# if exon is sticky, get supporting from components
if( $exon->isa( 'Bio::EnsEMBL::StickyExon' )) {
# sticky storing. Sticky exons contain normal exons ...
my @componentExons = $exon->each_component_Exon();
for my $componentExon ( @componentExons ) {
$self->fetch_evidence_by_Exon( $componentExon );
}
return;
}
if($exon->dbID){
#
# This looks broken...
# print STDERR "trying to store ".$exon->dbID."\n";
my $sql = "select feature_type, feature_id from supporting_feature where exon_id = ".$exon->dbID." ";
# print STDERR "sql = ".$sql."\n";
my $sth = $self->db->prepare($sql);
$sth->execute;
my $prot_adp = $self->get_ProteinAlignFeatureAdaptor;
my $dna_adp = $self->get_DnaAlignFeatureAdaptor;
while(my ($type, $feature_id) = $sth->fetchrow){
if($type eq 'protein_align_feature'){
my $f = $prot_adp->fetch_by_dbID($feature_id);
$exon->add_Supporting_Feature($f);
}elsif($type eq 'dna_align_feature'){
my $f = $dna_adp->fetch_by_dbID($feature_id);
$exon->add_Supporting_Feature($f);
}
}
}else{
print STDERR "exon has no dbID can't fetch evidence from db no relationship exists\n";
}
return 1;
}
=head2 store
......
......@@ -750,9 +750,19 @@ sub _translate {
sub translate {
my($self) = @_;
my $pep = $self->_translate() || throw ("Can't translate DNA\n");
my $phase=$self->phase();
if($phase){$phase=3-$phase;}
my $phase= 0;
if (defined($self->phase)) {
$phase = $self->phase;
}
if ($phase){
$phase = 3 - $phase;
}
return $pep->[$phase];
}
......@@ -1382,9 +1392,14 @@ sub cdna2genomic {
my $self = shift;
my $start_cdna = shift;
my $end_cdna = shift;
my $phase_start_cdna = $start_cdna + $self->phase();
my $phase_end_cdna = $end_cdna + $self->phase();
my $phase = 0;
if (defined($self->phase)) {
$phase = $self->phase;
}
my $phase_start_cdna = $start_cdna + $phase;
my $phase_end_cdna = $end_cdna + $phase;
my $pep_start = int(($phase_start_cdna+2)/3);
my $pep_end = int (($phase_end_cdna+2)/3);
......
......@@ -454,7 +454,13 @@ sub get_cdna {
push( @{$self->{'_exon_align'}}, $exon_align );
if( $exon->phase() != $lastphase ) {
my $phase = 0;
if (defined($exon->phase)) {
$phase = $exon->phase;
}
if( $phase != $lastphase ) {
if( $lastphase == 1 ) {
$cdna .= 'NN';
......@@ -467,8 +473,8 @@ sub get_cdna {
}
#startpadding for this exon
$cdna .= 'N' x $exon->phase();
$cdna_start += $exon->phase();
$cdna .= 'N' x $phase;
$cdna_start += $phase;
}
$new_cdna = $exon->seq->seq();
......@@ -477,7 +483,8 @@ sub get_cdna {
$cdna_end = $cdna_start + CORE::length( $new_cdna ) - 1;
# how many peptides are added by this exon??
$pep_count = int( ( CORE::length( $new_cdna ) + $exon->phase() + 2 ) / 3 );
$pep_count = int( ( CORE::length( $new_cdna ) + $phase + 2 ) / 3 );
$pep_end = $pep_start + $pep_count - 1;
$lastphase = $exon->end_phase();
......@@ -590,7 +597,7 @@ sub cdna2genomic {
my ( $ov_start, $ov_end );
print ::LOG "cdna2genomic: ",$start_cdna, " ", $end_cdna,"\n";
#print ::LOG "cdna2genomic: ",$start_cdna, " ", $end_cdna,"\n";
if( ! defined $self->{'_exon_align'} ) {
$self->get_cdna();
......@@ -617,7 +624,7 @@ sub cdna2genomic {
}
}
for my $tmp ( @result ) {
print ::LOG "cdna2genomic result: ", join ( " ", @$tmp ),"\n";
#print ::LOG "cdna2genomic result: ", join ( " ", @$tmp ),"\n";
}
return @result;
......
......@@ -96,8 +96,8 @@ sub fset2transcript {
$translation->start(1);
$translation->end($exons[scalar(@exons)-1]->length);
$translation->start_exon($exons[0]);
$translation->end_exon($exons[$#exons]);
$translation->start_Exon($exons[0]);
$translation->end_Exon($exons[$#exons]);
my $endphase = $exons[0]->end_phase;
......@@ -153,8 +153,8 @@ sub fset2transcript_guess_phases {
$translation->start (1);
$translation->end ($exons[$#exons]->end - $exons[$#exons]->start + 1);
$translation->start_exon($exons[0]);
$translation->end_exon($exons[$#exons]);
$translation->start_Exon($exons[0]);
$translation->end_Exon($exons[$#exons]);
$transcript->translation($translation);
my $endphase = 0;
......@@ -249,12 +249,22 @@ sub fset2transcript_3frame {
}
my $translation = new Bio::EnsEMBL::Translation;
#print "contig id = ".$contig->id."\n";
$translation->temporary_id($contig->id . "." . $fset->id);
my $contig_id = "";
my $fset_id = "";
if (defined($contig->id)) {
$contig_id = $contig->id;
}
if (defined($fset->id)) {
$fset_id = $fset->id;
}
$translation->temporary_id($contig_id . "." . $fset_id);
$translation->start (1);
$translation->end ($exons[$#exons]->end - $exons[$#exons]->start + 1);
$translation->start_exon($exons[0]);
$translation->end_exon ($exons[$#exons]);
$translation->start_Exon($exons[0]);
$translation->end_Exon ($exons[$#exons]);
$transcript->translation($translation);
# print STDERR "Phase $startphase " . $transcript->translate->seq . "\n";
......
Markdown is supported
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