Skip to content
Snippets Groups Projects
Commit 254f7ab2 authored by Graham McVicker's avatar Graham McVicker
Browse files

added stable id to prediction transcripts

parent af70810b
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,8 @@ sub _objs_from_sth {
my ($analysis, $contig, $pre_trans, $ptid, $on_slice_flag, $last_end,
$chr, $start, $end, $strand,
$slice_start, $slice_end, $slice_strand,
$exon, $exon_start, $exon_end, $exon_strand);
$exon, $exon_start, $exon_end, $exon_strand,
$stable_start, $stable_end, $stable_ctg);
my (%analysis_hash, %contig_hash);
if($slice) {
......@@ -167,6 +168,7 @@ sub _objs_from_sth {
$on_slice_flag = 0;
while($sth->fetch) {
#create a new transcript for each new prediction transcript id
unless(defined $pre_trans && $ptid == $prediction_transcript_id) {
......@@ -183,17 +185,39 @@ sub _objs_from_sth {
$pre_trans->analysis($analysis);
$pre_trans->set_exon_count($exon_count);
#throw away last pred_transcript if none of the exons were on the slice
if(@out && $slice && $on_slice_flag == 0) {
pop @out;
if(@out) {
#throw away last pred_transcript if none of the exons were on the slice
if(@out && $slice && $on_slice_flag == 0) {
pop @out;
} else {
#set the stable_id of the previous prediction
$out[$#out]->stable_id("$stable_ctg.$stable_start.$stable_end");
}
}
push( @out, $pre_trans );
#reset values used for last predtrans
$on_slice_flag = 0;
$last_end = undef;
$stable_start = -1;
$stable_end = -1;
$stable_ctg = '';
}
#recalculate stable id values
if($stable_start == -1 || $contig_start < $stable_start) {
$stable_start = $contig_start;
}
if($contig_end > $stable_end) {
$stable_end = $contig_end;
}
unless($contig = $contig_hash{$contig_id}) {
$contig = $rca->fetch_by_dbID($contig_id);
$contig_hash{$contig_id} = $contig;
}
$stable_ctg = $contig->name;
if($slice) {
#a slice was passed in so we want slice coords
......@@ -225,17 +249,13 @@ sub _objs_from_sth {
$exon_strand = $strand;
}
#use slice as the contig instead of the raw contig
$contig = $slice;
} else {
#we just want plain old contig coords
$exon_start = $contig_start;
$exon_end = $contig_end;
$exon_strand = $contig_strand;
unless($contig = $contig_hash{$contig_id}) {
$contig = $rca->fetch_by_dbID($contig_id);
$contig_hash{$contig_id} = $contig;
}
}
#create an exon and add it to the prediction transcript
......@@ -254,6 +274,9 @@ sub _objs_from_sth {
#throw away last pred_transcript if it had no exons overlapping the slice
if(@out && $slice && $on_slice_flag == 0) {
pop @out;
} else {
#set the stable id of the last prediction transcript
$out[$#out]->stable_id("$stable_ctg.stable_start.$stable_end");
}
return \@out;
......
......@@ -19,7 +19,8 @@ PredictionTranscript
=head1 DESCRIPTION
Container for single transcript ab initio gene prediction ala GenScan.
. Is directly storable/retrievable in EnsEMBL using PredictionTranscript Adaptor.
Is directly storable/retrievable in EnsEMBL using PredictionTranscript Adaptor.
Creation:
......@@ -31,18 +32,25 @@ Creation:
The order of the exons has to be right, as PT cant judge how to sort them.
( no sort as in Bio::EnsEMBL::Transcript )
PredictionTranscript is geared towards the partial retrieve case from db. Exons can be missing in the middle. For storage though its necessary to have them all and in contig coord system.
PredictionTranscript is geared towards the partial retrieve case from db.
Exons can be missing in the middle. For storage though its necessary to
have them all and in contig coord system.
Manipulation:
my @exons = @{$tran->get_all_Exons} # Returns an array of Exon objects, might contain undef instead of exon.
my $pep = $tran->translate() # Returns the peptide translation as string
my $cdna = $trans->get_cdna() # phase padded Exons cdna sequence.Padding might not often occur, phases usually match.
# Returns an array of Exon objects, might contain undef instead of exon.
my @exons = @{$tran->get_all_Exons};
# Returns the peptide translation as string
my $pep = $tran->translate;
# phase padded Exons cdna sequence. Phases usually match.
my $cdna = $trans->get_cdna()
=head1 CONTACT
Describe contact details here
contact EnsEMBL dev for information
=head1 APPENDIX
......@@ -77,8 +85,6 @@ use Bio::Seq;
=cut
sub new {
my($class,@optional_exons) = @_;
......@@ -103,6 +109,35 @@ sub new {
}
=head2 stable_id
Arg [1] : (optional) $stable_id
Example : my $pt_id = $prediction_transcript->stable_id;
Description: Retrieves the stable id fro this prediction transcript.
Prediction transcripts do not maintain stable ids as real
transcripts do - the id is constructed from the name of the
contig the prediction transcript was pulled off of, and the
start and end of the transcript on the contig.
i.e. the stable id is: "$contig_name.$contig_start.$contig_end"
Returntype : string
Exceptions : none
Caller : general, PredictionTranscriptAdaptor
=cut
sub stable_id {
my ($self, $value) = @_;
if($value) {
$self->{'_stable_id'} = $value;
}
return $self->{'_stable_id'};
}
=head2 coding_start
Arg [1] : The new coding start of this prediction transcript in slice
......
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