#-*-Perl-*- # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.t' use strict; use warnings; use Module::Build; use Bio::Root::IO; use File::Path 'rmtree'; use IO::String; use CGI; use FindBin '$Bin'; use constant TEST_COUNT => 3; use constant CONF_FILE => "$Bin/testdata/conf/GBrowse.conf"; my $PID; BEGIN { # to handle systems with no installed Test module # we include the t dir (where a copy of Test.pm is located) # as a fallback eval { require Test; }; if( $@ ) { use lib 't'; } use Test; plan test => TEST_COUNT; $PID = $$; rmtree '/tmp/gbrowse_testing'; } END { # rmtree '/tmp/gbrowse_testing' if $$ == $PID; } %ENV = (); $ENV{GBROWSE_DOCS} = $Bin; chdir $Bin; use lib "$Bin/../lib"; use Bio::Graphics::Browser2; use Bio::Graphics::Browser2::I18n; use Bio::Graphics::Karyotype; use lib "$Bin/testdata"; use TemplateCopy; # for the template_copy() function for ('volvox_final.conf','yeast_chr1.conf') { template_copy("testdata/conf/templates/$_", "testdata/conf/$_", {}); } # create objects we need to test the karyotype generator my $globals = Bio::Graphics::Browser2->new(CONF_FILE); my $session = $globals->session; my $source = $globals->create_data_source('volvox'); my $lang = Bio::Graphics::Browser2::I18n->new($source->globals->language_path); $lang->language('en'); my $kg = Bio::Graphics::Karyotype->new(source => $source, language => $lang, ); my @motifs = $source->open_database()->features('motif'); $kg->sort_sub(sub ($$) { my $a = shift; my $b = shift; return $b->length<=>$a->length; } ); ok($kg); $kg->add_hits(\@motifs); my $html = $kg->to_html; ok($html); my @imgs = $html =~ /(','foo.html'; print $f <<'END'; karyotype test

karyotype test

END ; print $f $html; print $f <<'END'; END ; close $f; system "firefox ./foo.html"; } exit 0; END { unlink 'testdata/conf/volvox_final.conf', 'testdata/conf/yeast_chr1.conf'; rmtree('/tmp/gbrowse_testing',0,0); }