Archive Ensembl HomeArchive Ensembl Home
DBAdaptor.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 NAME
00020 
00021 Bio::EnsEMBL::Compara::DBSQL::DBAdaptor
00022 
00023 =head1 DESCRIPTION
00024 
00025 This object represents the handle for a comparative DNA alignment database
00026 
00027 =head1 SYNOPSIS
00028 
00029     $db = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor->new(
00030         -user   => 'root',
00031         -host   => 'caldy',
00032         -dbname => 'pog',
00033         -species => 'Multi',
00034         );
00035 
00036     $db = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor->new(
00037         -url => 'mysql://user:pass@host:port/db_name');
00038 
00039 =head1 AUTHORSHIP
00040 
00041 Ensembl Team. Individual contributions can be found in the CVS log.
00042 
00043 =head1 MAINTAINER
00044 
00045 $Author: mm14 $
00046 
00047 =head VERSION
00048 
00049 $Revision: 1.82 $
00050 
00051 =head1 APPENDIX
00052 
00053 The rest of the documentation details each of the object methods.
00054 Internal methods are usually preceded with an underscore (_)
00055 
00056 =cut
00057 
00058 package Bio::EnsEMBL::Compara::DBSQL::DBAdaptor;
00059 
00060 use vars qw(@ISA);
00061 use strict;
00062 
00063 use Bio::EnsEMBL::DBLoader;
00064 use Bio::EnsEMBL::Utils::Argument;
00065 use Bio::EnsEMBL::Utils::Exception;
00066 
00067 use base ('Bio::EnsEMBL::DBSQL::DBAdaptor');
00068 
00069 
00070 =head2 new
00071 
00072   Arg [..]   : list of named arguments.  See Bio::EnsEMBL::DBConnection.
00073                [-URL mysql://user:pass@host:port/db_name] alternative way to specify the
00074                connection parameters. Pass and port are optional. If none is speciefied,
00075                the species name will be equal to the db_name.
00076                [-GROUP] This option is *always* set to "compara". Use another DBAdaptor
00077                for other groups.
00078   Example    :  $db = new Bio::EnsEMBL::Compara::DBSQL::DBAdaptor(
00079                     -user   => 'root',
00080                     -pass => 'secret',
00081                     -host   => 'caldy',
00082                     -port   => 3306,
00083                     -dbname => 'ensembl_compara',
00084                     -species => 'Multi');
00085   Example    :  $db = new Bio::EnsEMBL::Compara::DBSQL::DBAdaptor(
00086                     -url => 'mysql://root:secret@caldy:3306/ensembl_compara'
00087                     -species => 'Multi');
00088   Description: Creates a new instance of a DBAdaptor for the compara database.
00089   Returntype : Bio::EnsEMBL::Compara::DBSQL::DBAdaptor
00090   Exceptions : none
00091   Caller     : general
00092 
00093 =cut
00094 
00095 sub new {
00096   my ($class, @args) = @_;
00097 
00098   my ($url, $species) = rearrange(['URL', 'SPECIES'], @args);
00099 
00100   if ($url and $url =~ /mysql\:\/\/([^\@]+\@)?([^\:\/]+)(\:\d+)?\/(.+)/) {
00101     my $user_pass = $1;
00102     my $host = $2;
00103     my $port = $3;
00104     my $dbname = $4;
00105 
00106     $user_pass =~ s/\@$//;
00107     my ($user, $pass) = $user_pass =~ m/([^\:]+)(\:.+)?/;
00108     $pass =~ s/^\:// if ($pass);
00109     $port =~ s/^\:// if ($port);
00110     push(@args, "-user" => $user) if ($user);
00111     push(@args, "-pass" => $pass) if ($pass);
00112     push(@args, "-port" => $port) if ($port);
00113     push(@args, "-host" => $host);
00114     push(@args, "-dbname" => $dbname);
00115     if (!$species) {
00116       push(@args, "-species" => $dbname);
00117     }
00118   }
00119 
00120   my $self = $class->SUPER::new(@args);
00121 
00122   return $self;
00123 }
00124 
00125 
00126 sub get_available_adaptors {
00127  
00128   my %pairs =  (
00129       "MetaContainer" => "Bio::EnsEMBL::DBSQL::MetaContainer",
00130       "MethodLinkSpeciesSet" => "Bio::EnsEMBL::Compara::DBSQL::MethodLinkSpeciesSetAdaptor",
00131       "SyntenyRegion"   => "Bio::EnsEMBL::Compara::DBSQL::SyntenyRegionAdaptor",
00132       "DnaAlignFeature" => "Bio::EnsEMBL::Compara::DBSQL::DnaAlignFeatureAdaptor",
00133       "GenomeDB"        => "Bio::EnsEMBL::Compara::DBSQL::GenomeDBAdaptor",
00134       "SpeciesSet"      => "Bio::EnsEMBL::Compara::DBSQL::SpeciesSetAdaptor",
00135       "DnaFrag" => "Bio::EnsEMBL::Compara::DBSQL::DnaFragAdaptor",
00136       "DnaFragRegion" => "Bio::EnsEMBL::Compara::DBSQL::DnaFragRegionAdaptor",
00137       "GenomicAlignBlock" => "Bio::EnsEMBL::Compara::DBSQL::GenomicAlignBlockAdaptor",
00138       "GenomicAlign" => "Bio::EnsEMBL::Compara::DBSQL::GenomicAlignAdaptor",
00139       "GenomicAlignGroup" => "Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroupAdaptor",
00140       "GenomicAlignTree" => "Bio::EnsEMBL::Compara::DBSQL::GenomicAlignTreeAdaptor",
00141       "AlignSlice" => "Bio::EnsEMBL::Compara::DBSQL::AlignSliceAdaptor",
00142       "Homology" => "Bio::EnsEMBL::Compara::DBSQL::HomologyAdaptor",
00143       "Family" => "Bio::EnsEMBL::Compara::DBSQL::FamilyAdaptor",
00144       "Domain" => "Bio::EnsEMBL::Compara::DBSQL::DomainAdaptor",
00145       "Subset" => "Bio::EnsEMBL::Compara::DBSQL::SubsetAdaptor",
00146       "Member" => "Bio::EnsEMBL::Compara::DBSQL::MemberAdaptor",
00147       "Attribute" => "Bio::EnsEMBL::Compara::DBSQL::AttributeAdaptor",
00148       "NCBITaxon" => "Bio::EnsEMBL::Compara::DBSQL::NCBITaxonAdaptor",
00149       "PeptideAlignFeature" => "Bio::EnsEMBL::Compara::DBSQL::PeptideAlignFeatureAdaptor",
00150       "Sequence" => "Bio::EnsEMBL::Compara::DBSQL::SequenceAdaptor",
00151       "GeneTree" => "Bio::EnsEMBL::Compara::DBSQL::GeneTreeAdaptor",
00152       "ProteinTree" => "Bio::EnsEMBL::Compara::DBSQL::ProteinTreeAdaptor",
00153       "NCTree" => "Bio::EnsEMBL::Compara::DBSQL::NCTreeAdaptor",
00154       "CAFETree" => "Bio::EnsEMBL::Compara::DBSQL::CAFETreeAdaptor",
00155       "Analysis" => "Bio::EnsEMBL::DBSQL::AnalysisAdaptor",
00156       "ConservationScore" => "Bio::EnsEMBL::Compara::DBSQL::ConservationScoreAdaptor",
00157       "ConstrainedElement" => "Bio::EnsEMBL::Compara::DBSQL::ConstrainedElementAdaptor",
00158       "SitewiseOmega" => "Bio::EnsEMBL::Compara::DBSQL::SitewiseOmegaAdaptor",
00159       "SpeciesTree" => "Bio::EnsEMBL::Compara::DBSQL::SpeciesTreeAdaptor",
00160 
00161        #Production specific adaptors
00162        "DnaFragChunk" => "Bio::EnsEMBL::Compara::Production::DBSQL::DnaFragChunkAdaptor",
00163        "DnaFragChunkSet" => "Bio::EnsEMBL::Compara::Production::DBSQL::DnaFragChunkSetAdaptor",
00164        "DnaCollection" => "Bio::EnsEMBL::Compara::Production::DBSQL::DnaCollectionAdaptor",
00165        "AnchorSeq" => "Bio::EnsEMBL::Compara::Production::DBSQL::AnchorSeqAdaptor",
00166        "AnchorAlign" => "Bio::EnsEMBL::Compara::Production::DBSQL::AnchorAlignAdaptor",
00167 
00168         );
00169   return (\%pairs);
00170 }
00171  
00172 
00173 1;