Skip to content
Snippets Groups Projects
Commit 394a5a13 authored by Felix Kokocinski's avatar Felix Kokocinski
Browse files

test functions for the ditag modules

parent 99843ad8
No related branches found
No related tags found
No related merge requests found
use strict;
BEGIN { $| = 1;
use Test;
plan tests => 9;
}
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Map::Ditag;
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
my $db = $multi->get_DBAdaptor( 'core' );
my $ditag;
my $dbID = 1;
my $name = "101A01-2";
my $type = "ZZ11";
my $tag_count = 2;
my $sequence = "GAGAACTTGGACCGCAGAGAATACACACAAATCAAACC";
my $adaptor = $db->get_DitagAdaptor;
my $ditag_id = 3278337;
######
# 1 #
######
#test new
$ditag = Bio::EnsEMBL::Map::Ditag->new (
-dbID => $dbID,
-name => $name,
-type => $type,
-tag_count => $tag_count,
-sequence => $sequence,
-adaptor => $adaptor,
);
ok($ditag && $ditag->isa('Bio::EnsEMBL::Map::Ditag'));
#######
# 2-6 #
#######
#test dbID, name, type, sequence, tag-count
ok($ditag->dbID eq $dbID);
ok($ditag->name eq $name);
ok($ditag->type eq $type);
ok($ditag->sequence() eq $sequence);
ok($ditag->tag_count > 0);
######
# 7 #
######
#test adaptor
ok($ditag->adaptor->isa('Bio::EnsEMBL::Map::DBSQL::DitagAdaptor'));
#######
# 8-9 #
#######
#test get_ditagFeatures
my $ditagFeatures = $adaptor->fetch_by_dbID($ditag_id)->get_ditagFeatures();
ok(scalar @$ditagFeatures);
ok($ditagFeatures->[0]->isa('Bio::EnsEMBL::Map::DitagFeature'));
1;
use strict;
BEGIN { $| = 1;
use Test ;
plan tests => 11;
}
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Map::DBSQL::DitagAdaptor;
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
my $db = $multi->get_DBAdaptor( 'core' );
my $name = "101A01-2";
my $type = "ZZ13";
my $tag_count = 2;
my $sequence = "GAGAACTTGGACCGCAGAGAATACACACAAATCAAACC";
######
# 1 #
######
#test get_DitagAdaptor
my $ditag_adaptor = $db->get_DitagAdaptor;
ok($ditag_adaptor && ref $ditag_adaptor);
#####
# 2 #
#####
#test store
my $new_ditag = Bio::EnsEMBL::Map::Ditag->new (
-name => $name,
-type => $type,
-count => $tag_count,
-sequence => $sequence,
-adaptor => $db,
);
my @ditags = ( $new_ditag );
#hide the contents of ditag table
$multi->hide('core', 'ditag');
ok($ditag_adaptor->store(\@ditags));
#######
# 3-4 #
#######
#test fetch_all_by_name
my $ditags = $ditag_adaptor->fetch_by_name($name);
#if feature was stored it has a dbID now
ok(scalar(@$ditags) && $ditags->[0]->isa('Bio::EnsEMBL::Map::Ditag'));
ok($ditags->[0]->name eq $name);
#######
# 5-6 #
#######
#test fetch_all_by_type
$ditags = $ditag_adaptor->fetch_all_by_type($type);
ok(scalar(@$ditags) && $ditags->[0]->isa('Bio::EnsEMBL::Map::Ditag'));
ok($ditags->[0]->type eq $type);
#######
# 7-8 #
#######
#test fetch_all_by_name_and_type
$ditags = $ditag_adaptor->fetch_all_by_name_and_type($name, $type);
ok(scalar(@$ditags) && $ditags->[0]->isa('Bio::EnsEMBL::Map::Ditag'));
ok($ditags->[0]->type eq $type && $ditags->[0]->name eq $name);
######
# 9 #
######
#test fetch_all
$ditags = $ditag_adaptor->fetch_all();
ok(scalar(@$ditags) && $ditags->[0]->isa('Bio::EnsEMBL::Map::Ditag'));
#unhide table after having stored
$multi->restore('core', 'ditag');
######
# 10 #
######
#test fetch_with_limit
$ditags = $ditag_adaptor->fetch_with_limit($type, 5, 0);
ok((scalar(@$ditags) == 5) && $ditags->[0]->isa('Bio::EnsEMBL::Map::Ditag'));
######
# 11 #
######
#test list_dbIDs
my $dbIDs = $ditag_adaptor->list_dbIDs();
ok(scalar @$dbIDs);
1;
use strict;
BEGIN { $| = 1;
use Test;
plan tests => 17;
}
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Map::DitagFeature;
use Bio::EnsEMBL::Analysis;
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
my $db = $multi->get_DBAdaptor( 'core' );
my $dfa = $db->get_DitagFeatureAdaptor;
my $slice = $db->get_SliceAdaptor->fetch_by_region('chromosome','20');
my $analysis = $db->get_AnalysisAdaptor->fetch_by_logic_name('DitagAlign' );
my $dbID = 4828567;
my $ditag_id = 3278337;
my $qstart = 120635196;
my $qend = 120635214;
my $qstrand = 1;
my $tstart = 1;
my $tend = 19;
my $tstrand = 1;
my $ditag_side = 'L';
my $ditag_pair_id = 1;
my $cigar_line = '19M';
######
# 1 #
######
#test new
my $feature = Bio::EnsEMBL::Map::DitagFeature->new(
-slice => $slice,
-start => $qstart,
-end => $qend,
-strand => $qstrand,
-hit_start => $tstart,
-hit_end => $tend,
-hit_strand => $tstrand,
-ditag_id => $ditag_id,
-ditag_side => $ditag_side,
-ditag_pair_id => $ditag_pair_id,
-cigar_line => $cigar_line,
-analysis => $analysis,
);
ok($feature && $feature->isa('Bio::EnsEMBL::Map::DitagFeature'));
########
# 2-14 #
########
#test ditag_id, ditag_side, hit_start, hit_end,
# hit_strand, cigar_line, start, end, strand,
# dbID, sequence, slice, ditag_pair_id
my $ditagFeatures = $dfa->fetch_by_ditagID($ditag_id);
my $ditagFeature = $ditagFeatures->[0];
ok(defined $ditagFeature && $ditagFeature->isa('Bio::EnsEMBL::Map::DitagFeature'));
ok($ditagFeature->ditag_id == $ditag_id);
ok($ditagFeature->slice->isa('Bio::EnsEMBL::Slice'));
ok($ditagFeature->ditag_pair_id == $ditag_pair_id);
ok($ditagFeature->ditag_side eq $ditag_side);
ok($ditagFeature->hit_start == $tstart);
ok($ditagFeature->hit_end == $tend);
ok($ditagFeature->hit_strand eq $tstrand);
ok($ditagFeature->cigar_line eq $cigar_line);
ok($ditagFeature->start == $qstart);
ok($ditagFeature->end == $qend);
ok($ditagFeature->strand eq $qstrand);
ok($ditagFeature->dbID == $dbID);
ok(length($ditagFeature->sequence) > 10);
######
# 13 #
######
#test fetch_ditag
my $ditag = $ditagFeature->fetch_ditag();
ok(defined $ditag && $ditag->isa('Bio::EnsEMBL::Map::Ditag'));
ok($ditag->dbID == $ditag_id);
1;
use strict;
BEGIN { $| = 1;
use Test ;
plan tests => 12;
}
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Map::Ditag;
use Bio::EnsEMBL::Analysis;
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
my $db = $multi->get_DBAdaptor( 'core' );
my $region = 11;
my $ditag_id = 1;
my $qstart = 120635196;
my $qend = 120635214;
my $qstrand = 1;
my $tstart = 3;
my $tend = 19;
my $tstrand = 1;
my $ditag_side = 'L';
my $ditag_pair_id = 1;
my $cigar_line = '17M',
my $type = "ZZ13";
my $dbID = 4828567;
my $other_ditag = 3278337;
#469273
my $slice = $db->get_SliceAdaptor->fetch_by_region('chromosome', $region);
my $analysis = $db->get_AnalysisAdaptor->fetch_by_logic_name('DitagAlign' );
######
# 1 #
######
#test constructor
my $dfa = $db->get_DitagFeatureAdaptor;
ok($dfa && ref $dfa);
######
# 2 #
######
#test construction
my $feature = Bio::EnsEMBL::Map::DitagFeature->new(
-slice => $slice,
-start => $qstart,
-end => $qend,
-strand => $qstrand,
-hit_start => $tstart,
-hit_end => $tend,
-hit_strand => $tstrand,
-ditag_id => $ditag_id,
-ditag_side => $ditag_side,
-ditag_pair_id => $ditag_pair_id,
-cigar_line => $cigar_line,
-analysis => $analysis,
);
ok($feature && $feature->isa('Bio::EnsEMBL::Map::DitagFeature'));
#######
# 3-4 #
#######
#test store
#hide the contents of ditag_feature table
$multi->hide('core', 'ditag_feature');
$dfa->store($feature);
ok($feature->dbID && $feature->adaptor == $dfa);
my $testfeature = $dfa->fetch_by_dbID($feature->dbID);
ok($testfeature && $testfeature->isa('Bio::EnsEMBL::Map::DitagFeature'));
#unhide table
$multi->restore('core', 'ditag_feature');
########
# 5-11 #
########
#test fetch methods
#test fetch all
my $dfs = $dfa->fetch_all();
ok(scalar @$dfs && $dfs->[0]->isa('Bio::EnsEMBL::Map::DitagFeature'));
#test fetch by dbID
my $df = $dfa->fetch_by_dbID($dbID);
ok($df && $df->isa('Bio::EnsEMBL::Map::DitagFeature') && $df->dbID == $dbID);
#test fetch by ditagID
$dfs = $dfa->fetch_by_ditagID($other_ditag);
ok((scalar @$dfs == 2) && $dfs->[0]->isa('Bio::EnsEMBL::Map::DitagFeature')
&& $dfs->[0]->ditag_id == $other_ditag);
#test fetch by type
$dfs = $dfa->fetch_all_by_type($type);
ok((scalar @$dfs) && $dfs->[0]->isa('Bio::EnsEMBL::Map::DitagFeature')
&& $dfs->[0]->fetch_ditag->type eq $type);
# test fetch all by slice
$slice = $db->get_SliceAdaptor->fetch_by_region('chromosome', $region,
$qstart, $qend);
$dfs = $dfa->fetch_all_by_Slice($slice);
ok(scalar(@$dfs) && $dfs->[0]->isa('Bio::EnsEMBL::Map::DitagFeature'));
#test fetch_grouped
$dfs = $dfa->fetch_grouped('', $type);
ok(scalar @$dfs);
ok($dfs->[0]->{'ditag_id'} && $dfs->[0]->{'start'} && $dfs->[0]->{'end'});
######
# 12 #
######
#test list_dbIDs
my $dbIDs = $dfa->list_dbIDs();
ok(scalar @$dbIDs);
1;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment