Module::Build::Chado - Build,configure and test chado database backed modules and applications
version 0.0011
use Module::Build::Chado;
my $build = Module::Build::Chado->new(
module_name => 'MyChadoApp',
license => 'perl',
dist_abstract => 'My chado module'
dist_version => '1.0'
);
$build->create_build_script;
perl Build.PL && ./Build test(default is a temporary SQLite database)
It will deploy chado schema in a SQLite database, load fixtures and run all tests)
use Module::Build::Chado;
my $schema = Module::Build::Chado->current->schema;
#do something with it ....
$schema->resultset('Organism::Organism')->....
PostgreSQL
./Build test --dsn "dbi:Pg:dbname=mychado" --user tucker --password booze
Oracle
./Build test --dsn "dbi:Oracle:sid=myoracle" --user tucker --password hammer
This is subclass of Module::Build to configure, build and test chado database backed perl modules and applications. During the /Build test testing phase it loads some default fixtures which can be accessed in every test(.t) file using standard DBIx::Class API.
Look at the organism.yaml in the shared folder
OBO relationship types, available here http://bioportal.bioontology.org/ontologies/1042.
Sequence types and features, available here http://bioportal.bioontology.org/ontologies/1109
my $schema = Module::Build->current->schema;
isa_ok($schema, 'Bio::Chado::Schema');
Access them using DBIx::Class API
my $row = $schema->resultset('Organism::Organism')->find({species => 'Homo', genus => 'sapiens'});
my $resultset = $schema->resultset('Organism::Organism')->search({});
my $relonto = $schema->resultset('Cv::Cv')->find({'name' => 'relationship'});
my $seqonto = $schema->resultset('Cv::Cv')->find({'name' => 'sequence'});
my $cvterm_rs = $seqonto->cvterms;
while(my $cvterm = $cvterm_rs->next) { ..... }
You probably will not be accessing them too often, but mostly needed to load other test fixtures.
- Create your own subclass and implement either or both of two methods
__before_all_fixtures__ and __after_all_fixtures__
- before_all_fixtures
This code will run before any fixture is loaded
- after_all_fixtures
This code will run after organism data, relationship and sequence ontologies are loaded
package MyBuilder;
use base qw/Module::Build::Chado/;
sub before_all_fixtures {
my ($self) = @_;
}
sub before_all_fixtures {
my ($self) = @_;
}
A Bio::Chado::Schema object.
Database connect string, defaults to a temporary SQLite database.
Database user, not needed for SQLite backend.
Database password, not needed for SQLite backend.
Database super user, in case the regular use do not have enough permissions for manipulating the database schema. It defaults to the user attribute.
Similar concept as superuser
DDL file for particular backend, by default comes for SQLite, Postgresql and Oracle.
Fixture for loading organisms, by default the distribution comes with a organism.yaml file.
Relation ontology file in obo_xml format. The distribution includes a relationship.obo_xml file.
Sequence ontology file in obo_xml format. By default, it includes sofa.obo_xml file.
Returns a hash with the following connection specific keys ...
Returns an 4 elements array with connection arguments identical to DBI's connect method.
Sets up the basic parameters for the build object and loads the specific backend class. It is called by every other action. Override of calling it separately absolutely not recommended.
Creates a database. However, at this point it is not implemented for Postgresql and Oracle backends. For that, you need to use database specific client tools. For SQLite backend the database is created when the schema is loaded.
Deploy a chado database to the specified backend. Create action is implied.
Deploy a chado database to the specified backend. Unlike the deploy action, create action is not implied here. So, except SQLite backend, this action expects a database to be created already.
Loads the organism fixture to the deployed chado schema. __deploy_schema__ action is implied.
Load the relationship ontology. __deploy_schema__ action is implied.
Load the sequence ontology. __load_rel__ action is implied.
Load all fixtures in the given order.
__deploy_schema__ is implied.
Deletes the relationship ontology.
Deletes the sequence ontology.
Deletes the organisms.
Delete all fixtures including organism, relationship and sequence ontologies.
Delete all fixtures. However, unlike running all the dependent unload_actions similar to unload_fixture it empties all the database tables. It runs a little bit faster than unload_fixture.
Overrides the default __Action_test__ of Module::Build. This action drop any existing schema, loads the fixture along with the schema, runs all the tests and then drops the schema.
Drops the database. However, except SQLite it is not implemented for Oracle and Postgresql.
Drops the database schema.
Siddhartha Basu biosidd@gmail.com
This software is copyright (c) 2011 by Siddhartha Basu.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.