| 1 | =head1 LICENSE | ||
| 2 | |||
| 3 | See the NOTICE file distributed with this work for additional information | ||
| 4 | regarding copyright ownership. | ||
| 5 | |||
| 6 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 7 | you may not use this file except in compliance with the License. | ||
| 8 | You may obtain a copy of the License at | ||
| 9 | |||
| 10 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 11 | |||
| 12 | Unless required by applicable law or agreed to in writing, software | ||
| 13 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 15 | See the License for the specific language governing permissions and | ||
| 16 | limitations under the License. | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | |||
| 21 | =head1 CONTACT | ||
| 22 | |||
| 23 | Please email comments or questions to the public Ensembl | ||
| 24 | developers list at <http://lists.ensembl.org/mailman/listinfo/dev>. | ||
| 25 | |||
| 26 | Questions may also be sent to the Ensembl help desk at | ||
| 27 | <http://www.ensembl.org/Help/Contact>. | ||
| 28 | |||
| 29 | =head1 AUTHOR | ||
| 30 | |||
| 31 | Juguang Xiao <juguang@fugu-sg.org> | ||
| 32 | |||
| 33 | =cut | ||
| 34 | |||
| 35 | =head1 NAME | ||
| 36 | |||
| 37 | Bio::EnsEMBL::Utils::Converter::ens_bio | ||
| 38 | |||
| 39 | =head1 SYNOPISIS | ||
| 40 | |||
| 41 | You are not supposed to use this module directly. Please read | ||
| 42 | Bio::EnsEMBL::Utils::Converter | ||
| 43 | |||
| 44 | =head1 DESCRIPTION | ||
| 45 | |||
| 46 | This is a helper module to assist Bio::EnsEMBL::Utils::Converter find | ||
| 47 | which converter instance should be used, based on the -in and -out | ||
| 48 | parameters. | ||
| 49 | |||
| 50 | =head1 METHODS | ||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | package Bio::EnsEMBL::Utils::Converter::ens_bio; | ||
| 55 | $Bio::EnsEMBL::Utils::Converter::ens_bio::VERSION = '114.0.0'; | ||
| 56 | use strict; | ||
| 57 | use vars qw(@ISA); | ||
| 58 | use Bio::EnsEMBL::Utils::Converter; | ||
| 59 | @ISA = qw(Bio::EnsEMBL::Utils::Converter); | ||
| 60 | |||
| 61 | =head2 new | ||
| 62 | Please see Bio::EnsEMBL::Utils::Converter::new | ||
| 63 | =cut | ||
| 64 | |||
| 65 | sub new { | ||
| 66 | my ($caller, @args) = @_; | ||
| 67 | my $class = ref($caller) || $caller; | ||
| 68 | |||
| 69 | if($class eq 'Bio::EnsEMBL::Utils::Converter::ens_bio'){ | ||
| 70 | my %params = @args; | ||
| 71 | @params{map{lc $_} keys %params} = values %params; | ||
| 72 | my $module = $class->_guess_module($params{-in}, $params{-out}); | ||
| 73 | return undef unless ($class->_load_module($module)); | ||
| 74 | return "$module"->new(@args); | ||
| 75 | }else{ | ||
| 76 | my $self = $class->SUPER::new(@args); | ||
| 77 | # $self->_initialize(@args); | ||
| 78 | return $self; | ||
| 79 | } | ||
| 80 | |||
| 81 | } | ||
| 82 | |||
| 83 | # Unlike bio_ens, ens_bio does not need _initialize method for analysis and | ||
| 84 | # contig information. | ||
| 85 | # | ||
| 86 | |||
| 87 | sub _guess_module { | ||
| 88 | my ($self, $in, $out) = @_; | ||
| 89 | my $tail; | ||
| 90 | if($in eq 'Bio::EnsEMBL::SeqFeature'){ | ||
| 91 | $tail = 'ens_bio_seqFeature'; | ||
| 92 | }elsif($in eq 'Bio::Ens::EMBL::FeaturePair'){ | ||
| 93 | $tail = 'ens_bio_featurePair'; | ||
| 94 | }else{ | ||
| 95 | $self->throw("[$in] to [$out], not supported"); | ||
| 96 | } | ||
| 97 | return "Bio::EnsEMBL::Utils::Converter::$tail"; | ||
| 98 | } | ||
| 99 | |||
| 100 | 1; |