more tests for the orf finder
[bioperl-live.git] / Build.PL
blob37b95c45495150993a2d65ab4a125ce61db6f07c
1 #!/usr/bin/perl -w
3 # This is a Module::Build script for Bioperl installation.
4 # See http://search.cpan.org/~kwilliams/Module-Build/lib/Module/Build.pm
6 # Uses a custom subclass of Module::Build called Bio::Root::Build
8 # In the future developers may need to alter the requires and recommends
9 # sections of Bio::Root::Build->new() below, but otherwise nothing else here is
10 # likely to need changing.
12 use strict;
13 use lib '.';
14 use Bio::Root::Build;
16 # XML::SAX::RTF doesn't work with BioPerl, at all, nada, zilch.
18 # Since we're running into this now on CPAN Testers, catch it up front and
19 # deal with it.
21 # See: https://rt.cpan.org/Ticket/Display.html?id=5943
22 # http://bugzilla.open-bio.org/show_bug.cgi?id=2975
26 eval {
27 require XML::SAX;
31 unless ($@) {
32 if (grep {$_->{Name} =~ 'XML::SAX::RTF'} @{XML::SAX->parsers()}) {
33 warn <<WARN;
34 ############################# WARNING #############################
36 XML::SAX::RTF is not XML::SAX-compliant but is registered as an
37 XML::SAX parser. If used as the primary parser, modules requiring
38 XML::SAX will NOT work. Please install another XML::SAX-compliant
39 module and modify your local ParserDetails.ini file per XML::SAX docs
40 to remove references to XML::SAX::RTF.
42 ############################# WARNING #############################
43 WARN
44 sleep 3;
50 our @drivers;
52 my $mysql_ok = 0;
54 # Set up the Bio::Root::Build object
55 my $build = Bio::Root::Build->new(
56 module_name => 'Bio',
57 dist_name => 'BioPerl',
58 dist_version_from => 'Bio/Root/Version.pm',
59 dist_author => 'BioPerl Team <bioperl-l@bioperl.org>',
60 dist_abstract => 'Bioinformatics Toolkit',
61 license => 'perl',
62 requires => {
63 'perl' => '5.6.1',
64 'IO::String' => 0,
65 'DB_File' => 0,
66 'Data::Stag' => 0.11, # Bio::SeqIO::swiss, we can change to 'recommend' if needed
67 'Scalar::Util' => 0, # not in Perl 5.6.1, arrived in core in 5.7.3
68 'ExtUtils::Manifest' => '1.52', # allows spaces in file names
70 build_requires => {
71 'Test::More' => 0,
72 'Module::Build' => 0.2805,
73 'Test::Harness' => 2.62,
74 'CPAN' => 1.81
76 recommends => { # does what you would expect of recommends, except more informative output and generates optional_features in META.yml
77 'Ace' => '0/access of ACeDB database/Bio::DB::Ace,Bio::DB::GFF::Adaptor::ace',
78 'Algorithm::Munkres' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
79 'Array::Compare' => '0/Phylogenetic Networks/Bio::PhyloNetwork',
80 # this won't actually install due to circular dep, but we have no way of doing a post-install
81 # the [circular dependency!] specifies it is only installed on explicit request for this specific module,
82 # not when simply choosing to install 'all' modules
83 'Bio::ASN1::EntrezGene' => '0/parsing entrezgene/Bio::SeqIO::entrezgene [circular dependency!]',
84 # we actually need 1.01 of Class::AutoClass, but unfortunately it is versioned as 1.0
85 'Clone' => '0/cloning objects/Bio::Tools::Primer3',
86 'Convert::Binary::C' => '0/strider functionality/Bio::SeqIO::strider',
87 'Graph' => '0/Phylogenetic Networks, ontology engine implementation, contig analysis/Bio::PhyloNetwork,Bio::Ontology::SimpleGOEngine::GraphAdaptor,Bio::Assembly::Tools::ContigSpectrum',
88 'GraphViz' => '0/Phylogenetic Network Visulization/Bio::PhyloNetwork::GraphViz',
89 'HTML::Entities' => '0/remote analysis POST submissions/Bio::SearchIO::blastxml',
90 'HTML::HeadParser' => '3/parsing <HEAD> section of HTML docs/Bio::Tools::Analysis::DNA::ESEfinder',
91 'HTTP::Request::Common' => '0/GenBank+GenPept sequence retrieval, remote http Blast jobs/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::Tools::Analysis::Protein*,Bio::Tools::Analysis::DNA*',
92 'List::MoreUtils' => '0/Back- or reverse-translation of sequences/Bio::Tools::SeqPattern,Bio::Tools::SeqPattern::BackTranslate',
93 'LWP::UserAgent' => '0/remote access/Bio::DB::*,Bio::Tools::Run::RemoteBlast,Bio::WebAgent',
94 'Math::Random' => '0/Random Phylogenetic Networks/Bio::PhyloNetwork::RandomFactory',
95 'PostScript::TextBlock' => '0/EPS output/Bio::Tree::Draw::Cladogram',
96 'Set::Scalar' => '0/proper operation/Bio::Tree::Compatible',
97 'SOAP::Lite' => '0/Bibliographic queries/Bio::DB::Biblio::soap',
98 'Sort::Naturally' => '0/sort lexically, but sort numeral parts numerically/Bio::Assembly::IO::ace,Bio::Assembly::IO::tigr',
99 'Spreadsheet::ParseExcel' => '0/parsing Excel files/Bio::SeqIO::excel,Bio::Microarray::Tools::ReseqChip',
100 'Spreadsheet::WriteExcel' => '0/writing Excel files/Bio::Microarray::Tools::ReseqChip',
101 'Storable' => '2.05/storing sequence objects in local file cache/Bio::DB::FileCache,Bio::SeqFeature::Collection,Bio::PopGen::HtSNP,Bio::PopGen::TagHaplotype,Bio::DB::GFF::Adaptor::berkeleydb',
102 'SVG' => '2.26/creating SVG images/Bio::Draw::Pictogram',
103 'SVG::Graph' => '0.01/creating SVG images/Bio::TreeIO::svggraph',
104 'Text::ParseWords' => '0/test scripts/Bio::DB::SeqFeature::Store::FeatureFileLoader',
105 'URI::Escape' => '0/dealing with web resources/Bio::FeatureIO::gff,Bio::FeatureIO::interpro,Bio::DB::Biblio::eutils,Bio::DB::EUtilParameters,Bio::DB::Query::GenBank,Bio::DB::NCBIHelper,Bio::SeqFeature::Annotated',
106 'XML::DOM::XPath' => '0.13/parsing interpro features/Bio::FeatureIO::interpro',
107 'XML::Parser' => '0/parsing xml/Bio::Biblio::IO::medlinexml',
108 'XML::Parser::PerlSAX' => '0/parsing xml/Bio::SeqIO::tinyseq,Bio::SeqIO::game::gameSubs,Bio::OntologyIO::InterProParser,Bio::ClusterIO::dbsnp',
109 'XML::SAX' => '0.15/parsing xml/Bio::SearchIO::blastxml,Bio::SeqIO::tigrxml,Bio::SeqIO::bsml_sax',
110 'XML::SAX::Writer' => '0/writing xml/Bio::SeqIO::tigrxml',
111 'XML::Simple' => '0/reading custom XML/Bio::Tools::EUtilities,Bio::DB::HIV,Bio::DB::Query::HIVQuery',
112 'XML::Twig' => '0/parsing xml/Bio::Variation::IO::xml,Bio::DB::Taxonomy::entrez,Bio::DB::Biblio::eutils',
113 'XML::Writer' => '0.4/parsing and writing xml/Bio::SeqIO::agave,Bio::SeqIO::game::gameWriter,Bio::SeqIO::chadoxml,Bio::SeqIO::tinyseq,Bio::Variation::IO::xml,Bio::SearchIO::Writer::BSMLResultWriter',
115 get_options => {
116 accept => { },
117 network => { } # say 'perl Build.PL --network' to manually request network tests
119 auto_features => {
120 BioDBSeqFeature_BDB => {
121 description => "BDB tests for Bio::DB::SeqFeature::Store",
122 feature_requires => { 'DB_File' => 0 } # feature_requires is like requires, except that it doesn't trigger installation
124 BioDBGFF => {
125 description => "BioDBGFF database tests (will need to answer questions before really enabling)",
126 feature_requires => { 'DBI' => 0 },
127 excludes_os => ['mswin'],
128 test => \&test_biodbgff # Bio::Root::Build unique requirement that after everything else succeeds, supplied code ref must also return undef
130 BioDBSeqFeature_mysql => {
131 description => "MySQL tests for Bio::DB::SeqFeature::Store",
132 feature_requires => { 'DBI' => 0, 'DBD::mysql' => 0 },
133 test => \&test_db_sf
135 BioDBSeqFeature_Pg => {
136 description => "Postgres tests for Bio::DB::SeqFeature::Store",
137 feature_requires => { 'DBI' => 0, 'DBD::Pg' => 0},
138 test => \&test_db_sf
140 BioDBSeqFeature_SQLite => {
141 description => "SQLite tests for Bio::DB::SeqFeature::Store",
142 feature_requires => { 'DBI' => 0, 'DBD::SQLite' => 0},
143 test => \&test_db_sf
145 Network => {
146 description => "Enable tests that need an internet connection",
147 feature_requires => { 'LWP::UserAgent' => 0 },
148 test => \&Bio::Root::Build::test_internet
151 dynamic_config => 1,
152 create_makefile_pl => 'passthrough',
153 recursive_test_files => 1,
154 # Extra files needed for BioPerl modules
155 xml_files => {'./Bio/DB/HIV/lanl-schema.xml' => 'lib/Bio/DB/HIV/lanl-schema.xml'},
157 #pm_files => {} # modules in Bio are treated as if they were in lib and auto-installed
158 #script_files => [] # scripts in scripts directory are installed on-demand
161 my $accept = $build->args->{accept};
163 my $proceed = prompt_for_biodb($accept) if $build->feature('BioDBGFF') || $build->feature('BioDBSeqFeature_mysql');
165 # Handle auto features
166 if ($proceed && $build->feature('BioDBSeqFeature_BDB')) {
167 # will return without doing anything if user chose not to run tests during
168 # prompt_for_biodb() above
169 make_bdb_test();
171 if ($proceed && ($build->feature('BioDBSeqFeature_mysql') or $build->feature('BioDBSeqFeature_Pg'))) {
172 make_dbi_test();
175 # Ask questions
176 $build->choose_scripts($accept);
177 #prompt_for_biodbgff($accept) if $build->feature('BioDBGFF');
179 if ($build->args('network')) {
180 if ($build->feature('Network')) {
181 $build->notes(network => 1);
182 $build->log_info(" - will run internet-requiring tests\n");
184 else {
185 $build->notes(network => 0);
186 $build->log_info(" - will not run network tests since I seem to be missing essential network functionality\n");
189 else {
190 $build->prompt_for_network($accept) if $build->feature('Network');
192 # then in test script:
193 # use Bio::Root::Build;
194 # my $build = Module::Build->current;
195 # my $do_network_tests = $build->notes('network');
198 # Request that some scripts run post-installation
199 $build->add_post_install_script('maintenance/symlink_script.pl'); # takes a unix file path regardless of local OS
201 # Add extra things to MANIFEST.SKIP
202 $build->add_to_manifest_skip('bioperl.lisp');
204 # Add additional files here
205 $build->add_build_element('xml');
207 # Create the build script and exit
208 $build->create_build_script;
210 exit;
212 sub make_bdb_test {
213 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
214 my $path = File::Spec->catfile('t', 'LocalDB','SeqFeature_BDB.t');
215 unlink($path) if (-e $path);
216 open(my $F, ">", $path) || die "Can't create test file\n";
217 print $F <<END;
218 system '$^X $path0 -adaptor berkeleydb -create 1 -temp 1';
220 close $F;
221 $build->add_to_cleanup($path);
222 $build->add_to_manifest_skip($path);
225 sub test_db_sf {
226 eval {require DBI;}; # if not installed, this sub won't actually be called
227 @drivers = DBI->available_drivers;
228 unless (grep {/mysql|Pg|SQLite/i} @drivers) {
229 $mysql_ok = 0;
230 return "Only MySQL, Postgres and SQLite DBI drivers supported for Bio::DB::SeqFeature RDMS tests";
232 $mysql_ok = 1;
233 return;
236 sub make_dbi_test {
237 my $dsn = $build->notes('test_dsn') || return;
238 my $path0 = File::Spec->catfile('t', 'LocalDB', 'SeqFeature.t');
239 my $driver = $build->notes('dbd_driver');
240 my $path = File::Spec->catfile('t', 'LocalDB',
241 ($driver eq 'mysql') ? 'SeqFeature_mysql.t' :
242 ($driver eq 'SQLite') ? 'SeqFeature_SQLite.t' :
243 'SeqFeature_Pg.t');
244 my $test_db = $build->notes('test_db');
245 my $user = $build->notes('test_user');
246 my $pass = $build->notes('test_pass');
247 open my $F,">$path";
248 my $str = "$path0 -adaptor DBI::$driver -create 1 -temp 1 -dsn $dsn";
249 $str .= " -user $user" if $user;
250 $str .= " -password $pass" if $pass;
251 print $F <<END;
252 system '$^X $str';
254 close $F;
255 $build->add_to_cleanup($path);
256 $build->add_to_cleanup($test_db) if $driver eq 'SQLite';
257 $build->add_to_manifest_skip($path);
260 sub test_biodbgff {
261 eval {require DBI;}; # if not installed, this sub won't actually be called
262 @drivers = DBI->available_drivers;
263 unless (grep {/mysql|Pg|Oracle/i} @drivers) {
264 return "MySQL, Pg nor Oracle DBI drivers are installed";
266 return;
269 sub prompt_for_biodb {
270 my $accept = shift;
271 my $proceed = $accept ? 0 : $build->y_n("Do you want to run the Bio::DB::GFF or ".
272 "Bio::DB::SeqFeature::Store live database tests? ".
273 "y/n", 'n');
275 if ($proceed) {
276 my @driver_choices;
277 foreach my $poss ('SQLite', 'mysql', 'Pg', 'Oracle') {
278 if (grep {/$poss/i} @drivers) {
279 my $choice = $poss;
280 $choice =~ s/^(.)/[$1]/;
281 push(@driver_choices, $choice);
285 my $driver;
286 if (@driver_choices > 1) {
287 my ($default) = $driver_choices[0] =~ /\[(.)/;
288 $driver = $build->prompt("Which database driver should be used? ".join(" ", @driver_choices), $default);
290 else {
291 ($driver) = $driver_choices[0] =~ /\[(.)/;
293 if ($driver =~ /^[mM]/) {
294 $driver = 'mysql';
296 elsif ($driver =~ /^[pP]/) {
297 $driver = 'Pg';
299 elsif ($driver =~ /^[oO]/) {
300 $driver = 'Oracle';
302 elsif ($driver =~ /^[sS]/) {
303 $driver = 'SQLite';
306 my $test_db = $build->prompt("Which database should I use for testing the $driver driver?\n".
307 "This database should already be present but doesn't have to ".
308 "be preloaded for any schema", 'test');
309 my $test_host = $build->prompt("On which host is database '$test_db' running (hostname, ip address or host:port)", 'localhost');
310 my $test_user = $build->prompt("User name for connecting to database '$test_db'?", 'undef');
311 my $test_pass = $build->prompt("Password for connecting to database '$test_db'?", 'undef');
313 my $use_host = 1;
314 if ($test_host eq 'undef' || $test_host eq 'localhost') {
315 $use_host = 0;
318 my $test_dsn;
319 if ($driver eq 'Pg' || $driver eq 'SQLite') {
320 $test_dsn = "dbi:$driver:dbname=$test_db";
321 $mysql_ok = 0;
323 else {
324 $test_dsn = "dbi:$driver:database=$test_db";
325 $mysql_ok = 0;
327 if ($use_host) {
328 $test_dsn .= ";host=$test_host";
331 $build->notes(dbd_driver => $driver);
332 $build->notes(test_db => $test_db);
333 $build->notes(test_host => $test_host);
334 $build->notes(test_user => $test_user eq 'undef' ? undef : $test_user);
335 $build->notes(test_pass => $test_pass eq 'undef' ? undef : $test_pass);
336 $build->notes(test_dsn => $test_dsn);
338 $build->log_info(" - will run tests with database driver '$driver' and these settings:\n",
339 " Database $test_db\n",
340 " Host $test_host\n",
341 " DSN $test_dsn\n",
342 " User $test_user\n",
343 " Password $test_pass\n");
344 $build->log_info(" - will not run the BioDBSeqFeature live ".
345 "database tests (requires MySQL or Pg driver)\n") unless ($driver eq 'mysql' or $driver eq 'Pg');
347 else {
348 $build->log_info(" - will not run the BioDBGFF or BioDBSeqFeature live database tests\n");
351 $build->log_info("\n");
352 return $proceed;