Archive Ensembl HomeArchive Ensembl Home
ens_bio.pm
Go to the documentation of this file.
00001 =head1 LICENSE
00002 
00003   Copyright (c) 1999-2012 The European Bioinformatics Institute and
00004   Genome Research Limited.  All rights reserved.
00005 
00006   This software is distributed under a modified Apache license.
00007   For license details, please see
00008 
00009     http://www.ensembl.org/info/about/code_licence.html
00010 
00011 =head1 CONTACT
00012 
00013   Please email comments or questions to the public Ensembl
00014   developers list at <dev@ensembl.org>.
00015 
00016   Questions may also be sent to the Ensembl help desk at
00017   <helpdesk@ensembl.org>.
00018 
00019 =head1 AUTHOR
00020 
00021 Juguang Xiao <juguang@fugu-sg.org>
00022 
00023 =cut
00024 
00025 =head1 NAME
00026 
00027 Bio::EnsEMBL::Utils::Converter::ens_bio
00028 
00029 =head1 SYNOPISIS
00030 
00031 You are not supposed to use this module directly. Please read
00032 Bio::EnsEMBL::Utils::Converter
00033 
00034 =head1 DESCRIPTION
00035 
00036 This is a helper module to assist Bio::EnsEMBL::Utils::Converter find
00037 which converter instance should be used, based on the -in and -out
00038 parameters.
00039 
00040 =head1 METHODS
00041 
00042 =cut
00043 
00044 package Bio::EnsEMBL::Utils::Converter::ens_bio;
00045 
00046 use strict;
00047 use vars qw(@ISA);
00048 use Bio::EnsEMBL::Utils::Converter;
00049 @ISA = qw(Bio::EnsEMBL::Utils::Converter);
00050 
00051 =head2 new
00052   Please see Bio::EnsEMBL::Utils::Converter::new
00053 =cut
00054 
00055 sub new {
00056     my ($caller, @args) = @_;
00057     my $class = ref($caller) || $caller;
00058 
00059     if($class eq 'Bio::EnsEMBL::Utils::Converter::ens_bio'){
00060         my %params = @args;
00061         @params{map{lc $_} keys %params} = values %params;
00062         my $module = $class->_guess_module($params{-in}, $params{-out});
00063         return undef unless ($class->_load_module($module));
00064         return "$module"->new(@args);
00065     }else{
00066         my $self = $class->SUPER::new(@args);
00067 #        $self->_initialize(@args);
00068         return $self;
00069     }
00070 
00071 }
00072 
00073 # Unlike bio_ens, ens_bio does not need _initialize method for analysis and 
00074 # contig information.
00075 #
00076 
00077 sub _guess_module {
00078     my ($self, $in, $out) = @_;
00079     my $tail;
00080     if($in eq 'Bio::EnsEMBL::SeqFeature'){
00081         $tail = 'ens_bio_seqFeature';
00082     }elsif($in eq 'Bio::Ens::EMBL::FeaturePair'){
00083         $tail = 'ens_bio_featurePair';
00084     }else{
00085         $self->throw("[$in] to [$out], not supported");
00086     }
00087     return "Bio::EnsEMBL::Utils::Converter::$tail";
00088 }
00089 
00090 1;