Bio-EnsEMBL
view release on metacpan or search on metacpan
lib/Bio/EnsEMBL/Utils/Converter/bio_ens.pm view on Meta::CPAN
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
=head1 CONTACT
Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.
Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.
=head1 AUTHOR
Juguang Xiao <juguang@fugu-sg.org>
=cut
=head1 NAME
Bio::EnsEMBL::Utils::Converter::bio_ens
=head1 SYNOPISIS
You should not use this module directly. Please check out the
Bio::EnsEMBL::Utils::Converter module.
=head1 DESCRIPTION
=head1 METHODS
=cut
package Bio::EnsEMBL::Utils::Converter::bio_ens;
$Bio::EnsEMBL::Utils::Converter::bio_ens::VERSION = '114.0.0';
use strict;
use vars qw(@ISA);
use Bio::EnsEMBL::Analysis;
use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Utils::Converter;
use Scalar::Util qw(weaken);
@ISA = qw(Bio::EnsEMBL::Utils::Converter);
=head2 new
Please see Bio::EnsEMBL::Utils::Converter::new
=cut
sub new {
my ($caller, @args) = @_;
my $class = ref($caller) || $caller;
if($class eq 'Bio::EnsEMBL::Utils::Converter::bio_ens'){
my %params = @args;
@params{map{lc $_} keys %params} = values %params;
my $module = $class->_guess_module($params{-in}, $params{-out});
return undef unless ($class->_load_module($module));
return "$module"->new(@args);
}else{
my $self = $class->SUPER::new(@args);
# $self->_initialize(@args);
return $self;
}
}
sub _initialize {
my ($self, @args) = @_;
$self->SUPER::_initialize(@args);
my ($dbadaptor,
$dbdriver, $dbhost, $dbport, $dbuser, $dbpass, $dbname,
$analysis, $analysis_dbid, $analysis_logic_name,
$contig, $contig_dbid, $contig_name,
$translation_id) =
$self->_rearrange([qw(DBADAPTOR
DBDRIVER DBHOST DBPORT DBUSER DBPASS DBNAME
ANALYSIS ANALYSIS_DBID ANALYSIS_LOGIC_NAME
CONTIG CONTIG_DBID CONTIG_NAME
TRANSLATION_ID)], @args);
if(defined $dbadaptor){
$self->dbadaptor($dbadaptor);
}elsif(defined $dbname){
$self->ensembl_db(@args);
}else{
# No db information.
}
if(defined $analysis){
$self->analysis($analysis);
# then ignore the analysis_dbid and analysis_logic_name
}elsif(defined $analysis_dbid){
$self->analysis_dbID($analysis_dbid);
}elsif(defined $analysis_logic_name){
$self->analysis_logic_name($analysis_logic_name);
}else{
# No analysis information offered
}
if(defined $contig){
($contig) = ref($contig) eq 'ARRAY' ? @{$contig} : $contig;
$self->contig($contig);
}elsif(defined $contig_dbid){
$self->contig_dbID($contig_dbid);
}elsif(defined $contig_name){
$self->contig_name($contig_name);
}else{
# No contig information
}
if(defined $translation_id){
$self->translation_id($translation_id);
}
}
sub _guess_module {
my ($self, $in, $out) = @_;
my $tail;
if($in eq 'Bio::Search::HSP::GenericHSP'){
$tail = 'bio_ens_hsp';
}elsif($in eq 'Bio::SeqFeature::Generic'){
$tail = 'bio_ens_seqFeature';
}elsif($in eq 'Bio::SeqFeature::FeaturePair'){
$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';
}elsif($in eq 'Bio::SeqFeature::Gene::GeneStructure'){
$tail = 'bio_ens_gene';
}elsif($in eq 'Bio::SeqFeature::Gene::Transcript'){
$tail = 'bio_ens_transcript';
}elsif($in eq 'Bio::SeqFeature::Gene::Exon'){
$tail = 'bio_ens_exon';
}else{
$self->throw("[$in] to [$out], not supported");
}
return "Bio::EnsEMBL::Utils::Converter::$tail";
}
=head2 analysis
Title : analysis
Usage : $self->analysis
Function: get and set for analysis
Return : L<Bio::EnsEMBL::Analysis>
Args : L<Bio::EnsEMBL::Analysis>
=cut
sub analysis {
my ($self, $arg) = @_;
if(defined($arg)){
# convert the analysis, if it's not Bio::Pipeline::Analysis
if($arg->isa('Bio::Pipeline::Analysis')){
my $converter_for_analysis = new Bio::EnsEMBL::Utils::Converter(
-in => 'Bio::Pipeline::Analysis',
-out => 'Bio::EnsEMBL::Analysis'
);
($arg) = @{ $converter_for_analysis->convert([$arg]) };
}
$self->throws("A Bio::EnsEMBL::Analysis object expected.")
unless($arg->isa('Bio::EnsEMBL::Analysis'));
$self->{_analysis} = $arg;
$self->{_analysis_dbid} = $arg->dbID;
$self->{_analysis_logic_name} = $arg->logic_name;
}
return $self->{_analysis};
}
=head2 contig
( run in 0.490 second using v1.01-cache-2.11-cpan-5a3173703d6 )