diff --git a/modules/t/overlap.dump b/modules/t/overlap.dump new file mode 100755 index 0000000000000000000000000000000000000000..90b62c8b47daeebaf92249394fb8f98b35b27ea2 --- /dev/null +++ b/modules/t/overlap.dump @@ -0,0 +1,19 @@ +INSERT INTO clone VALUES ('pog','pog',1,1,-1,'0000-00-00 00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00'); + +INSERT INTO contig VALUES ('contig1',1,'pog',5,NULL,NULL,1,0); +INSERT INTO contig VALUES ('contig2',2,'pog',6,NULL,NULL,2,0); +INSERT INTO contig VALUES ('contig3',3,'pog',5,NULL,NULL,3,0); +INSERT INTO contig VALUES ('contig4',4,'pog',6,NULL,NULL,4,0); +INSERT INTO contig VALUES ('contig5',5,'pog',5,NULL,NULL,5,0); + +INSERT INTO contigoverlap VALUES (1,2,4,5,'TEST',1,'right2right'); +INSERT INTO contigoverlap VALUES (2,3,1,4,'TEST',1,'left2right'); +INSERT INTO contigoverlap VALUES (3,4,2,2,'TEST',1,'left2left'); +INSERT INTO contigoverlap VALUES (4,5,5,2,'TEST',1,'right2left'); + +INSERT INTO dna VALUES ('AAAAA','2000-04-27 08:31:59',1); +INSERT INTO dna VALUES ('GGGGGG','2000-04-27 08:31:59',2); +INSERT INTO dna VALUES ('AAAAA','2000-04-27 08:31:59',3); +INSERT INTO dna VALUES ('GGGGGG','2000-04-27 08:31:59',4); +INSERT INTO dna VALUES ('AAAAA','2000-04-27 08:31:59',5); + diff --git a/modules/t/overlap.exampleconf b/modules/t/overlap.exampleconf new file mode 100755 index 0000000000000000000000000000000000000000..9c35b49638767f3c7b948b3680c85ff05f2ac6d2 --- /dev/null +++ b/modules/t/overlap.exampleconf @@ -0,0 +1,4 @@ +overlap testoverlap +mysqladmin /nfs/disk89/michele/mysql/bin/mysqladmin +mysql mysql +user root diff --git a/modules/t/overlap.t b/modules/t/overlap.t new file mode 100755 index 0000000000000000000000000000000000000000..16ec98c5a677a68dc3b84380aed51449bed17ddd --- /dev/null +++ b/modules/t/overlap.t @@ -0,0 +1,118 @@ +## Bioperl Test Harness Script for Modules +## +# CVS Version +# $Id$ + + +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.t' + +#----------------------------------------------------------------------- +## perl test harness expects the following output syntax only! +## 1..3 +## ok 1 [not ok 1 (if test fails)] +## 2..3 +## ok 2 [not ok 2 (if test fails)] +## 3..3 +## ok 3 [not ok 3 (if test fails)] +## +## etc. etc. etc. (continue on for each tested function in the .t file) +#----------------------------------------------------------------------- + + +## We start with some black magic to print on failure. +BEGIN { $| = 1; print "1..6\n"; + use vars qw($loaded); } +END {print "not ok 1\n" unless $loaded;} + +use Bio::EnsEMBL::DBSQL::Obj; +use Bio::EnsEMBL::DBLoader; +$loaded=1; +print "ok \n"; # 1st test passed, loaded needed modules + +#Creating test overlap database + +$conf{'overlap'} = 'testoverlap'; +$conf{'mysqladmin'} = '/mysql/current/bin/mysqladmin'; +$conf{'mysql'} = '/mysql/current/bin/mysql'; +$conf{'user'} = 'ensembl'; +$conf{'perl'} = 'perl'; + +if ( -e 't/overlap.conf' ) { + print STDERR "Reading configuration from overlap.conf\n"; + open(C,"t/overlap.conf"); + while(<C>) { + my ($key,$value) = split; + $conf{$key} = $value; + } +} else { + print STDERR "Using default values\n"; + foreach $key ( keys %conf ) { + print STDERR " $key $conf{$key}\n"; + } + print STDERR "\nPlease use a file t/overlap.conf to alter these values if the test fails\nFile is written <key> <value> syntax\n\n"; +} + +$nuser = $conf{user}; + +my $create_overlap = "$conf{mysqladmin} -u ".$nuser." create $conf{overlap}"; + +system($create_overlap) == 0 or die "$0\nError running '$create_overlap' : $!"; + +print "ok 2\n"; #Databases created successfuly + +#Initialising databases +my $init_overlap = "$conf{mysql} -u ".$nuser." $conf{overlap} < ../sql/table.sql"; + +system($init_overlap) == 0 or die "$0\nError running '$init_overlap' : $!"; + +print "ok 3\n"; + +#Suck test data into db +print STDERR "Inserting test data in test overlap db...\n"; +my $suck_data = "$conf{mysql} -u ".$nuser." $conf{overlap} < t/overlap.dump"; +system($suck_data) == 0 or die "$0\nError running '$suck_data' : $!"; + +print "ok 4\n"; + +# Connect to test db + +my $db = new Bio::EnsEMBL::DBSQL::Obj(-host => 'localhost', + -user => $conf{user}, + -dbname => $conf{overlap} + ); + +die "$0\nError connecting to database : $!" unless defined($db); + +print "ok 5\n"; + +my $contig = $db->get_Contig('contig1'); + +die "$0\nError fetching contig1 : $!" unless defined ($contig); + +print "ok 6\n"; + +my $vc = new Bio::EnsEMBL::DB::VirtualContig(-focuscontig => $contig, + -focusposition => 1, + -ori => 1, + -left => 20, + -right => 20); + +die ("$0\nCan't create virtual contig :$!") unless defined ($vc); + +print "ok 7\n"; + +my $seq = $vc->primary_seq; + +die "$0\nVirtual contig sequence " . $seq->seq . "does not equal AAAACCCCTTGGGAAA : $!" if ($seq->seq ne "AAAACCCCTTGGGAAA"); + +print "ok 8\n"; + +END { + my $drop_overlap = "echo \"y\" | $conf{mysqladmin} -u ".$nuser." drop $conf{overlap}"; + system($drop_overlap) == 0 or die "$0\nError running '$drop_overlap' : $!"; +} + + + + diff --git a/modules/t/transfer.t b/modules/t/transfer.t index 4623b4965c9ce2542cca4305219fd998c710588e..022a1a9e3e89c5e91c30d75c3af192660c89699e 100755 --- a/modules/t/transfer.t +++ b/modules/t/transfer.t @@ -32,49 +32,51 @@ print "ok \n"; # 1st test passed, loaded needed modules #Creating test donor and recipient databases -$conf{'donor'} = 'testdonor'; -$conf{'recipient'} = 'testrecipient'; +$conf{'donor'} = 'testdonor'; +$conf{'recipient'} = 'testrecipient'; $conf{'mysqladmin'} = '/mysql/current/bin/mysqladmin'; -$conf{'mysql'} = '/mysql/current/bin/mysql'; -$conf{'user'} = 'ensembl'; -$conf{'update'} = '../scripts/update_list_chunk.pl'; -$conf{'perl'} = 'perl'; +$conf{'mysql'} = '/mysql/current/bin/mysql'; +$conf{'user'} = 'ensembl'; +$conf{'update'} = '../scripts/update_list_chunk.pl'; +$conf{'perl'} = 'perl'; if ( -e 't/transfer.conf' ) { - print STDERR "Reading configuration from transfer.conf\n"; - open(C,"t/transfer.conf"); - while(<C>) { - my ($key,$value) = split; - $conf{$key} = $value; - } + print STDERR "Reading configuration from transfer.conf\n"; + open(C,"t/transfer.conf"); + while(<C>) { + my ($key,$value) = split; + $conf{$key} = $value; + } } else { - print STDERR "Using default values\n"; - foreach $key ( keys %conf ) { - print STDERR " $key $conf{$key}\n"; - } - print STDERR "\nPlease use a file t/transfer.conf to alter these values if the test fails\nFile is written <key> <value> syntax\n\n"; + print STDERR "Using default values\n"; + foreach $key ( keys %conf ) { + print STDERR " $key $conf{$key}\n"; + } + print STDERR "\nPlease use a file t/transfer.conf to alter these values if the test fails\nFile is written <key> <value> syntax\n\n"; } $nuser = $conf{user}; -my $create_donor = "$conf{mysqladmin} -u ".$nuser." create $conf{donor}"; -my $create_recipient = "$conf{mysqladmin} -u ".$nuser." create $conf{recipient}"; -system($create_donor) == 0 or die "$0\nError running '$create_donor' : $!"; +my $create_donor = "$conf{mysqladmin} -u ".$nuser." create $conf{donor}"; +my $create_recipient = "$conf{mysqladmin} -u ".$nuser." create $conf{recipient}"; + +system($create_donor) == 0 or die "$0\nError running '$create_donor' : $!"; system($create_recipient) == 0 or die "$0\nError running '$create_recipient' : $!"; print "ok 2\n"; #Databases created successfuly #Initialising databases -my $init_donor = "$conf{mysql} -u ".$nuser." $conf{donor} < ../sql/table.sql"; -my $init_recipient = "$conf{mysql} -u ".$nuser." $conf{recipient} < ../sql/table.sql"; -system($init_donor) == 0 or die "$0\nError running '$init_donor' : $!"; +my $init_donor = "$conf{mysql} -u ".$nuser." $conf{donor} < ../sql/table.sql"; +my $init_recipient = "$conf{mysql} -u ".$nuser." $conf{recipient} < ../sql/table.sql"; + +system($init_donor) == 0 or die "$0\nError running '$init_donor' : $!"; system($init_recipient) == 0 or die "$0\nError running '$init_recipient' : $!"; print "ok 3\n"; #Suck test data into donor print STDERR "Inserting test data in test donor db... this will take a while...\n"; -my $suck_data = "$conf{mysql} -u ".$nuser." $conf{donor} < t/donor.dump"; +my $suck_data = "$conf{mysql} -u ".$nuser." $conf{donor} < t/donor.dump"; system($suck_data) == 0 or die "$0\nError running '$suck_data' : $!"; print "ok 4\n"; @@ -94,9 +96,9 @@ print "ok 6\n"; END { - my $drop_donor = "echo \"y\" | $conf{mysqladmin} -u ".$nuser." drop $conf{donor}"; - my $drop_recipient = "echo \"y\" | $conf{mysqladmin} -u ".$nuser." drop $conf{recipient}"; - system($drop_donor) == 0 or die "$0\nError running '$drop_donor' : $!"; + my $drop_donor = "echo \"y\" | $conf{mysqladmin} -u ".$nuser." drop $conf{donor}"; + my $drop_recipient = "echo \"y\" | $conf{mysqladmin} -u ".$nuser." drop $conf{recipient}"; + system($drop_donor) == 0 or die "$0\nError running '$drop_donor' : $!"; system($drop_recipient) == 0 or die "$0\nError running '$drop_recipient' : $!"; }