| 1 | #!/usr/bin/env perl -w |
| 2 | |
| 3 | use TFBS::Matrix::PFMscip-perl cpan TFBS v0.5.0 TFBS/Matrix/PFM/; |
| 4 | use TFBS::DB::JASPAR2scip-perl cpan TFBS v0.5.0 TFBS/DB/JASPAR2/; |
| 5 | use Testscip-perl cpan TFBS v0.5.0 Test/; |
| 6 | planscip-perl cpan TFBS v0.5.0 main/plan().(tests => 2); |
| 7 | |
| 8 | my @dbparams; |
| 9 | |
| 10 | |
| 11 | if (-e 't/MYSQLCONNECT') { |
| 12 | openscip-perl cpan TFBS v0.5.0 main/open(). FILE, 't/MYSQLCONNECT'; |
| 13 | my $line = <FILE>; |
| 14 | @dbparams = splitscip-perl cpan TFBS v0.5.0 main/split(). "::", $line; |
| 15 | close FILE; |
| 16 | $skipscip-perl cpan TFBS v0.5.0 main/$skip. = 0; |
| 17 | } |
| 18 | else { |
| 19 | printscip-perl cpan TFBS v0.5.0 main/print(). "ok # Skip (MySQL server not set up)\n"x2; |
| 20 | exitscip-perl cpan TFBS v0.5.0 main/exit().(0); |
| 21 | } |
| 22 | |
| 23 | # set up a matrix |
| 24 | |
| 25 | my $matrixstring = |
| 26 | "12 3 0 0 4 0\n0 0 0 11 7 0\n0 9 12 0 0 0\n0 0 0 1 1 12"; |
| 27 | my $pfm = TFBS::Matrix::PFM->newscip-perl cpan TFBS v0.5.0 TFBS/Matrix/PFM/new().(-matrix=>$matrixstring, -ID=>"TEST001"); |
| 28 | my $rawstring1 = $pfm->rawprintscip-perl cpan TFBS v0.5.0 TFBS/Matrix/PFM/rawprint().(); |
| 29 | |
| 30 | my $db; |
| 31 | |
| 32 | # write/read test |
| 33 | |
| 34 | $db = TFBS::DB::JASPAR2->createscip-perl cpan TFBS v0.5.0 TFBS/DB/JASPAR2/create(). |
| 35 | ("dbi:mysql:JASPAR2TEST:$dbparams[0]",$dbparams[1], $dbparams[2]); |
| 36 | $db->store_Matrixscip-perl cpan TFBS v0.5.0 TFBS/DB/JASPAR2/store_Matrix().($pfm); |
| 37 | my $pfm2= $db->get_Matrix_by_IDscip-perl cpan TFBS v0.5.0 TFBS/DB/JASPAR2/get_Matrix_by_ID().("TEST001", "PFM"); |
| 38 | my $rawstring2 = $pfm2->rawprintscip-perl cpan TFBS v0.5.0 main/rawprint().; |
| 39 | |
| 40 | okscip-perl cpan TFBS v0.5.0 main/ok(). ($rawstring1, $rawstring2); |
| 41 | |
| 42 | |
| 43 | # delete test |
| 44 | |
| 45 | $db->delete_Matrix_having_IDscip-perl cpan TFBS v0.5.0 TFBS/DB/JASPAR2/delete_Matrix_having_ID().('TEST001'); |
| 46 | my $nopfm = $db->get_Matrix_by_IDscip-perl cpan TFBS v0.5.0 TFBS/DB/JASPAR2/get_Matrix_by_ID().("TEST001", "PFM"); |
| 47 | |
| 48 | okscip-perl cpan TFBS v0.5.0 main/ok().(undef, $nopfm); |
| 49 | |
| 50 | |
| 51 | |
| 52 | END { |
| 53 | $db && |
| 54 | $db->dbhscip-perl cpan TFBS v0.5.0 TFBS/DB/JASPAR2/dbh(). && |
| 55 | $db->dbhscip-perl cpan TFBS v0.5.0 TFBS/DB/JASPAR2/dbh().->doscip-perl cpan TFBS v0.5.0 main/do().("drop database if exists JASPAR2TEST"); |
| 56 | } |
| 57 | |
| 58 | |
| 59 |