Created
April 15, 2011 10:59
-
-
Save dbolser/921519 to your computer and use it in GitHub Desktop.
my attempt at SeqFeature.t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*-Perl-*- Test Harness script for Bioperl | |
| # $Id$ | |
| ## I'm confused about the tests here, so for the sake of simplicity | |
| ## I'm going to start from scratch. Basically I just want to write a | |
| ## few tests to show up some specific bugs. Of course the right thing | |
| ## to do is to create another test file, but I don't know how to get | |
| ## SeqFeature_mysql.t to point at it (that file is automatically | |
| ## generated at build time). | |
| use strict; | |
| use warnings; | |
| use constant TEST_COUNT => 10; | |
| BEGIN { | |
| #use Data::Dumper; | |
| ## What does this do then? | |
| use Bio::Root::Test; | |
| ## Set up the test plan | |
| test_begin(-tests => TEST_COUNT); | |
| use_ok('Bio::DB::SeqFeature::Store'); | |
| use_ok('Bio::DB::SeqFeature::Store::GFF3Loader'); | |
| # use_ok('Bio::Root::IO'); | |
| # use_ok('Bio::DB::Fasta'); | |
| # use_ok('File::Copy'); | |
| } | |
| ## What is this then? | |
| my $DEBUG = test_debug(); | |
| ## This is how different adaptors are tested, by calling the test | |
| ## script, for example, with different values for --dsn (see below). | |
| my @args = @ARGV; | |
| ## Set up our tests... | |
| my $gff_file = | |
| test_input_file('gene_test.gff'); | |
| my $TMP = File::Spec->tmpdir(); | |
| ## Create a Bio::DB::SeqFeature::Store connection object using the | |
| ## values passed by the user at build time (see 'SeqFeature_mysql.t', | |
| ## 'SeqFeature_BDB.t', etc.) | |
| ## Note, extra 'args' are added to the new call here to mirror | |
| ## bp_seqfeature_load.pl as far as possible. | |
| ## NB: -adaptor -create -dsn -user and -password are all supplied in | |
| ## in 'SeqFeature_mysql.t'. | |
| my $db = Bio::DB::SeqFeature::Store-> | |
| new( @args, | |
| -namespace => undef, | |
| -tmpdir => $TMP, | |
| -write => 1, | |
| -compress => 0, | |
| ); | |
| ok($db); | |
| ## Again, copying bp_seqfeature_load.pl to get this bug to show up... | |
| ok( $db->init_database('erase') ); | |
| ## Create a loader to load our GFF file | |
| my $loader = Bio::DB::SeqFeature::Store::GFF3Loader-> | |
| new( -store=> $db, | |
| -sf_class => 'Bio::DB::SeqFeature', | |
| -verbose => 1, | |
| -tmpdir => $TMP, | |
| -fast => 0, | |
| -ignore_seqregion => 0, | |
| -index_subfeatures => 1, | |
| -noalias_target => 0, | |
| -summary_stats => 1, | |
| ); | |
| ok($loader); | |
| ## Try to pin down the weird "Use of uninitialized value in length at | |
| ## /homes/dbolser/perl5/lib/perl5/Bio/DB/SeqFeature/Store/DBI/mysql.pm | |
| ## line 1064." bug... | |
| ## Load the GFF | |
| ok($loader->load($gff_file)); | |
| ## Query some features | |
| my @features = | |
| $db->features( -seq_id => 'chr10', | |
| -start => 1, | |
| -end => 1700000, | |
| -type => 'gene', | |
| ); | |
| ## How many sequence ids in the database? | |
| warn 'There are : '. scalar $db->seq_ids. | |
| " sequences in the database\n"; | |
| warn "\t\tgot ", scalar @features, " features \n"; | |
| __END__ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment