$db = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor->new(
-user => 'root',
-host => 'caldy',
-dbname => 'pog',
-species => 'Multi',
);
$db = Bio::EnsEMBL::Compara::DBSQL::DBAdaptor->new(
-url => 'mysql://user:pass@host:port/db_name');
sub add_db_adaptor
{ my ($self, $dba) = @_;
deprecate("add_db_adaptor is deprecated. Correct method is to call\n" .
"dba->get_GenomeDBAdaptor->fetch_by_name_assembly(<name>,<assembly>)->db_adaptor(<coreDBA>)\n".
"Or to use add_DBAdaptor using the Bio::EnsEMBL::Registry\n");
unless($dba && ref $dba && $dba->isa('Bio::EnsEMBL::DBSQL::DBAdaptor')) {
$self->throw("dba argument must be a Bio::EnsEMBL::DBSQL::DBAdaptor\n" .
"not a [$dba]");
}
my $mc = $dba->get_MetaContainer;
my $csa = $dba->get_CoordSystemAdaptor;
my $species = $mc->get_Species->binomial;
my ($cs) = @{$csa->fetch_all};
my $assembly = $cs ? $cs->version : '';
my $gdb;
try {
$gdb = $self->get_GenomeDBAdaptor->fetch_by_name_assembly($species,$assembly);
} catch {
warning("Catched an exception, no GenomeDb defined\n$_\n");
};
return 0 unless (defined $gdb);
$gdb->db_adaptor($dba);
return 1; } |
sub get_available_adaptors
{
my %pairs = (
"MetaContainer" => "Bio::EnsEMBL::DBSQL::MetaContainer",
"MethodLinkSpeciesSet" => "Bio::EnsEMBL::Compara::DBSQL::MethodLinkSpeciesSetAdaptor",
"SyntenyRegion" => "Bio::EnsEMBL::Compara::DBSQL::SyntenyRegionAdaptor",
"DnaAlignFeature" => "Bio::EnsEMBL::Compara::DBSQL::DnaAlignFeatureAdaptor",
"GenomeDB" => "Bio::EnsEMBL::Compara::DBSQL::GenomeDBAdaptor",
"DnaFrag" => "Bio::EnsEMBL::Compara::DBSQL::DnaFragAdaptor",
"DnaFragRegion" => "Bio::EnsEMBL::Compara::DBSQL::DnaFragRegionAdaptor",
"GenomicAlignBlock" => "Bio::EnsEMBL::Compara::DBSQL::GenomicAlignBlockAdaptor",
"GenomicAlign" => "Bio::EnsEMBL::Compara::DBSQL::GenomicAlignAdaptor",
"GenomicAlignGroup" => "Bio::EnsEMBL::Compara::DBSQL::GenomicAlignGroupAdaptor",
"GenomicAlignTree" => "Bio::EnsEMBL::Compara::DBSQL::GenomicAlignTreeAdaptor",
"AlignSlice" => "Bio::EnsEMBL::Compara::DBSQL::AlignSliceAdaptor",
"Homology" => "Bio::EnsEMBL::Compara::DBSQL::HomologyAdaptor",
"Family" => "Bio::EnsEMBL::Compara::DBSQL::FamilyAdaptor",
"Domain" => "Bio::EnsEMBL::Compara::DBSQL::DomainAdaptor",
"Subset" => "Bio::EnsEMBL::Compara::DBSQL::SubsetAdaptor",
"Member" => "Bio::EnsEMBL::Compara::DBSQL::MemberAdaptor",
"Attribute" => "Bio::EnsEMBL::Compara::DBSQL::AttributeAdaptor",
"Taxon" => "Bio::EnsEMBL::Compara::DBSQL::TaxonAdaptor",
"NCBITaxon" => "Bio::EnsEMBL::Compara::DBSQL::NCBITaxonAdaptor",
"PeptideAlignFeature" => "Bio::EnsEMBL::Compara::DBSQL::PeptideAlignFeatureAdaptor",
"Sequence" => "Bio::EnsEMBL::Compara::DBSQL::SequenceAdaptor",
"NestedSet" => "Bio::EnsEMBL::Compara::DBSQL::NestedSetAdaptor",
"ProteinTree" => "Bio::EnsEMBL::Compara::DBSQL::ProteinTreeAdaptor",
"Analysis" => "Bio::EnsEMBL::DBSQL::AnalysisAdaptor",
"ConservationScore" => "Bio::EnsEMBL::Compara::DBSQL::ConservationScoreAdaptor",
"ConstrainedElement" => "Bio::EnsEMBL::Compara::DBSQL::ConstrainedElementAdaptor",
"SitewiseOmega" => "Bio::EnsEMBL::Compara::DBSQL::SitewiseOmegaAdaptor"
);
return (\%pairs);
}
1; } |
sub get_db_adaptor
{ my ($self, $species, $assembly) = @_;
deprecate("get_db_adaptor is deprecated. Correct method is to call\n".
"dba->get_GenomeDBAdaptor->fetch_by_name_assembly(<name>,<assembly>)->db_adaptor\n".
"Or to use get_DBAdaptor using the Bio::EnsEMBL::Registry\n");
unless($species && $assembly) {
throw("species and assembly arguments are required\n");
}
my $gdb;
eval {
$gdb = $self->get_GenomeDBAdaptor->fetch_by_name_assembly($species, $assembly);
};
if ($@) {
warning("Catched an exception, here is the exception message\n$@\n");
return undef;
}
return $gdb->db_adaptor; } |
sub new
{ my ($class, @args) = @_;
my ($conf_file, $url, $species) = rearrange(['CONF_FILE', 'URL', 'SPECIES'], @args);
if ($url and $url =~ /mysql\:\/\/([^\@]+\@)?([^\:\/]+)(\:\d+)?\/(.+)/) {
my $user_pass = $1;
my $host = $2;
my $port = $3;
my $dbname = $4;
$user_pass =~ s/\@$//;
my ($user, $pass) = $user_pass =~ m/([^\:]+)(\:.+)?/; $pass =~ s/^\:// if ($pass);
$port =~ s/^\:// if ($port);
push(@args, "-user" => $user) if ($user);
push(@args, "-pass" => $pass) if ($pass);
push(@args, "-port" => $port) if ($port);
push(@args, "-host" => $host);
push(@args, "-dbname" => $dbname);
if (!$species) {
push(@args, "-species" => $dbname);
}
}
my $self = $class->SUPER::new(@args);
if(defined($conf_file) and $conf_file ne "") {
deprecate("Compara.conf file is deprecated. Compara is now using the\n" .
"more generic Bio::EnsEMBL::Registry configuration file\n");
my @conf = @{do $conf_file};
foreach my $genome (@conf) {
my ($species, $assembly, $db_hash) = @$genome;
my $db;
my $module = $db_hash->{'module'};
my $mod = $module;
eval {
if ( $mod =~ /::/ ) {
$mod =~ s/::/\//g;
}
require "${mod}.pm";
$db = $module->new(-dbname => $db_hash->{'dbname'},
-host => $db_hash->{'host'},
-user => $db_hash->{'user'},
-pass => $db_hash->{'pass'},
-port => $db_hash->{'port'},
-driver => $db_hash->{'driver'},
-disconnect_when_inactive => $db_hash->{'disconnect_when_inactive'});
};
if($@) {
throw("could not load module specified in configuration file:$@");
}
unless($db && ref $db && $db->isa('Bio::EnsEMBL::DBSQL::DBAdaptor')) {
throw("[$db] specified in conf file is not a " .
"Bio::EnsEMBL::DBSQL::DBAdaptor");
}
if (defined $db) {
my $gdb = $self->get_GenomeDBAdaptor->fetch_by_name_assembly($species,$assembly);
$gdb->db_adaptor($db);
}
}
}
return $self; } |