Skip to content
Snippets Groups Projects
Commit 11dafb81 authored by juguang's avatar juguang
Browse files

converter for genscan result;

more doc for converter factory to enumerate all instances so far.
parent 834206f1
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,15 @@ Bio::EnsEMBL::Utils::Converter, a converter factory
Module to converter the business objects between EnsEMBL and any other projects, currently BioPerl.
What the ready conversions are,
Bio::SeqFeature::Generic <-> Bio::EnsEMBL::SeqFeature, Bio::EnsEMBL::SimpleFeature
Bio::SeqFeature::FeaturePair <-> Bio::EnsEMBL::SeqFeature, Bio::EnsEMBL::RepeatFeature
Bio::Search::HSP::GenericHSP -> Bio::EnsEMBL::BaseAlignFeature's submodules
Bio::Tools::Prediction::Gene -> Bio::EnsEMBL::PredictionTranscript
Bio::Tools::Prediction::Exon -> Bio::EnsEMBL::Exon
Bio::Pipeline::Analysis -> Bio::EnsEMBL::Analysis
=head1 FEEDBACK
......
......@@ -105,6 +105,10 @@ sub _guess_module {
$tail = 'bio_ens_featurePair';
}elsif($in eq 'Bio::Pipeline::Analysis'){
$tail = 'bio_ens_analysis';
}elsif($in eq 'Bio::Tools::Prediction::Gene'){
$tail = 'bio_ens_predictionGene';
}elsif($in eq 'Bio::Tools::Prediction::Exon'){
$tail = 'bio_ens_predictionExon';
}else{
$self->throw("[$in] to [$out], not supported");
}
......
# Bio::EnsEMBL::Utils::Converter::bio_ens_predictionExon
#
# Created and cared for by Juguang Xiao <juguang@tll.org.sg>
# Created date: 19/3/2003
#
# Copyright Juguang Xiao
#
# You may distribute this module under the same terms as perl itself
#
# POD documentation
#
=head1 NAME
Bio::EnsEMBL::Utils::Converter::bio_ens_predictionExon
=head1 SYNOPISIS
my $converter = new Bio::EnsEMBL::Utils::Converter(
-in => 'Bio::Tools::Prediction::Exon',
-out => 'Bio::EnsEMBL::Exon'
-contig => $ens_contig
);
=head1 DESCRIPTION
=head1 FEEDBACK
=head2 Mailing Lists
=head2 Reporting Bugs
=head1 AUTHOR Juguang Xiao
Juguang Xiao <juguang@tll.org.sg>
=head1 APPENDIX
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
=cut
# Let the code begin ...
package Bio::EnsEMBL::Utils::Converter::bio_ens_predictionExon;
use strict;
use vars qw(@ISA);
use Bio::EnsEMBL::Utils::Converter;
use Bio::EnsEMBL::Exon;
use Bio::EnsEMBL::Utils::Converter::bio_ens;
@ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
sub _convert_single {
my ($self, $input) = @_;
$input || $self->throw("a input object needed");
$self->throw("a Bio::Tools::Prediction::Exon object needed")
unless($input->isa("Bio::Tools::Prediction::Exon"));
$output = Bio::EnsEMBL::Exon->new(
-start => $input->start,
-end => $input->end,
-strand => $input->strand
);
$output->score($input->score);
$output->p_value($input->significance);
$output->phase($input->get_tag_values("phase")); # only first element is used
$output->end_phase($input->get_tag_values("end_phase"));
$output->contig($self->contig);
return $output;
}
1;
# Bio::EnsEMBL::Utils::Converter::bio_ens_predictionGene
#
# Created and cared for by Juguang Xiao <juguang@tll.org.sg>
# Created date: 18/3/2003
#
# Copyright Juguang Xiao
#
# You may distribute this module under the same terms as perl itself
#
# POD documentation
#
=head1 NAME
Bio::EnsEMBL::Utils::Converter::bio_ens_predictionGene
=head1 SYNOPISIS
=head1 DESCRIPTION
=head1 FEEDBACK
=head2 Mailing Lists
=head2 Reporting Bugs
=head1 AUTHOR Juguang Xiao
Juguang Xiao <juguang@tll.org.sg>
=head1 APPENDIX
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
=cut
# Let the code begin ...
package Bio::EnsEMBL::Utils::Converter::bio_ens_predictionGene;
use strict;
use vars qw(@ISA);
use Bio::EnsEMBL::Utils::Converter;
use Bio::EnsEMBL::PredictionTranscript;
use Bio::EnsEMBL::Utils::Converter::bio_ens;
@ISA = qw(Bio::EnsEMBL::Utils::Converter::bio_ens);
sub _initialize {
my ($self, @args) = @_;
$self->SUPER::_initialize(@args);
$self->{_predictionExonConverter} = new Bio::EnsEMBL::Utils::Converter(
-in => 'Bio::Tools::Prediction::Exon',
-out => 'Bio::EnsEMBL::Exon',
-contig => $self->contig
);
}
sub _convert_single {
my ($self, $input) = @_;
$self->throw("one argument needed") unless($input and defined($input));
$self->throw("a Bio::Tools::Prediction::Gene object needed")
unless(ref($input) && $input->isa('Bio::Tools::Prediction::Gene'));
my $output = Bio::EnsEMBL::PredictionTranscript->new;
$output->analysis($self->analysis);
my @exons = sort {$a->start <=> $b->start} $input->exons;
# Not sure on the correctivity of phase calculation.
my $previous_end_phase = -1;
foreach(@exons){
my $length = $_->length;
my $frame = $_->frame;
my $phase = ($previous_end_phase+1) %3;
my $end_phase = ($length-$frame) %1;
$previous_end_phase = $end_phase;
$_->add_tag_value("phase", $phase);
$_->add_tag_value("end_phase", $end_phase);
}
my @ens_exons = @{$self->{_predictionExonConverter}->convert(\@exons)};
$output->add_Exon($_) foreach(@ens_exons);
return $output;
}
=head2 contig
Title : contig
Usage : $self->contig
Function: get and set for contig
Return : L<Bio::EnsEMBL::RawContig>
Args : L<Bio::EnsEMBL::RawContig>
=cut
sub contig {
my ($self, $arg) = @_;
if(defined($arg)){
$self->throws("A Bio::EnsEMBL::RawContig object expected.") unless(defined $arg);
$self->{_contig} = $arg;
# assign it to the sub converter which converts exons
$self->{_predictionExonConverter}->contig($arg);
}
return $self->{_contig};
}
1;
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