Commit 56f2806c authored by Ian Longden's avatar Ian Longden
Browse files

regulatory stuff moved to seperate database

parent deab9c2a
use strict;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::RegulatoryFactor;
BEGIN { $| = 1;
use Test;
plan tests => 11;
}
my $verbose = 0;
# get a core DBAdaptor and a RegualtoryFactorAdaptor
#
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new;
my $dba = $multi->get_DBAdaptor("core");
my $factor_adaptor = $dba->get_RegulatoryFactorAdaptor();
#
# Test constructor
#
my $rm = Bio::EnsEMBL::RegulatoryFactor->new(-NAME => 'Joe',
-TYPE => 'promoter');
ok($rm);
ok(ref($rm));
ok($rm->isa('Bio::EnsEMBL::RegulatoryFactor'));
ok($rm->name eq 'Joe');
ok($rm->type eq 'promoter');
ok(test_getter_setter($rm,'name','Fred'));
ok(test_getter_setter($rm,'type','miRNA_target'));
# test coding_transcript & gene
my $factor = $factor_adaptor->fetch_by_dbID(1);
my $transcript = $factor->coding_transcript();
ok($transcript->dbID() == 21716);
$factor = $factor_adaptor->fetch_by_dbID(5);
my $gene = $factor->coding_gene();
ok($gene->dbID() == 18271);
# test getting factors coded for by gene and transcript
my $gene_adaptor = $dba->get_GeneAdaptor();
$gene = $gene_adaptor->fetch_by_dbID(18271);
my @factors = @{$factor_adaptor->fetch_factors_coded_for_by_gene($gene)};
ok($factors[0]->dbID() == 5);
my $transcript_adaptor = $dba->get_TranscriptAdaptor();
$transcript = $transcript_adaptor->fetch_by_dbID(21717);
@factors = @{$factor_adaptor->fetch_factors_coded_for_by_transcript($transcript)};
ok($factors[0]->dbID() == 2);
use strict;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Test::MultiTestDB;
BEGIN { $| = 1;
use Test;
plan tests => 11;
}
my $multi_db = Bio::EnsEMBL::Test::MultiTestDB->new;
my $db = $multi_db->get_DBAdaptor('core');
my $verbose = 0;
# Test Creation
my $rma = $db->get_RegulatoryFactorAdaptor();
ok(ref($rma) && $rma->isa('Bio::EnsEMBL::DBSQL::RegulatoryFactorAdaptor'));
#
# Test fetch_by_dbID
#
my $rm = $rma->fetch_by_dbID(1);
ok($rm->name() eq 'hsa-miR-23b');
ok($rm->dbID == 1);
ok($rm->type eq 'miRNA_target');
#
# Test fetch_by_name
#
$rm = $rma->fetch_by_name('hsa-miR-23b');
ok($rm->name() eq 'hsa-miR-23b');
ok($rm->dbID() == 1);
ok($rm->type() eq 'miRNA_target');
#
# Test fetch_all_by_type
#
ok(@{$rma->fetch_all_by_type('transcription_factor')} == 2);
#
# Test store
#
$multi_db->save('core', 'regulatory_factor');
$rm = Bio::EnsEMBL::RegulatoryFactor->new(-NAME => 'test_store',
-TYPE => 'transcription_factor');
$rma->store($rm);
ok($rm->dbID && $rm->adaptor());
$rm = $rma->fetch_by_dbID($rm->dbID);
ok($rm->name eq 'test_store');
ok($rm->type eq 'transcription_factor');
$multi_db->restore('core', 'regulatory_factor');
use strict;
use Bio::EnsEMBL::Test::TestUtils;
BEGIN { $| = 1;
use Test;
plan tests => 11;
}
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::RegulatoryFeature;
use Bio::EnsEMBL::RegulatoryFactor;
our $verbose = 0;
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new;
# get a core DBAdaptor
#
my $dba = $multi->get_DBAdaptor("core");
my $rfa = $dba->get_RegulatoryFeatureAdaptor;
#
# 1 create a new RegulatoryFeature
#
my $rf = new Bio::EnsEMBL::RegulatoryFeature;
ok($rf);
#
# 2-7 test the basic getter and setters
#
# 2 start
ok(test_getter_setter($rf,'start',10));
# 3 end
ok(test_getter_setter($rf,'end',14));
# 4 strand
ok(test_getter_setter($rf,'strand',1));
# 5 factor
my $rm = Bio::EnsEMBL::RegulatoryFactor->new(-NAME => 'Joe',
-TYPE => 'transcription_factor');
ok(test_getter_setter($rf,'factor',$rm));
# 6 influence
#ok(test_getter_setter($rf,'influence','positive'));
# 7 dbID
ok(test_getter_setter($rf,'dbID',20));
#
# 8 check adaptor attaching
#
$rf->adaptor($rfa);
ok($rf->adaptor->isa('Bio::EnsEMBL::DBSQL::RegulatoryFeatureAdaptor'));
# 9 check retrieving regulated transcripts
my $rf1 = $rfa->fetch_by_dbID(1);
ok(@{$rf1->regulated_transcripts()} == 1);
# 10 check get_transcripts_regulated_by_same_factor
ok(@{$rf1->transcripts_regulated_by_same_factor()} == 1);
# 11 check retrieving regulated genes
my $rf2 = $rfa->fetch_by_dbID(40);
ok(@{$rf2->regulated_genes()} == 1);
# 12 check get_genes_regulated_by_same_factor
ok(@{$rf2->genes_regulated_by_same_factor()} == 2);
use strict;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Test::MultiTestDB;
BEGIN { $| = 1;
use Test;
plan tests => 14;
}
my $multi_db = Bio::EnsEMBL::Test::MultiTestDB->new;
my $db = $multi_db->get_DBAdaptor('core');
my $verbose = 0;
# Test Creation
my $rfa = $db->get_RegulatoryFeatureAdaptor();
ok(ref($rfa) && $rfa->isa('Bio::EnsEMBL::DBSQL::RegulatoryFeatureAdaptor'));
#
## retrieve a feature via dbID
#
debug('---- fetch_by_dbID (default coords) ----');
my $feat = $rfa->fetch_by_dbID(2);
ok($feat->dbID == 2);
ok($feat->slice->seq_region_name() eq '1');
ok($feat->start == 919787);
ok($feat->end == 919807);
ok($feat->strand == 1);
# test fetch all by factor
my $rma = $db->get_RegulatoryFactorAdaptor();
my $factor = $rma->fetch_by_name('hsa-miR-138');
ok($factor);
ok(@{$rfa->fetch_all_by_factor($factor)} == 3);
# List_dbids
my $ids = $rfa->list_dbIDs();
ok (@{$ids});
# test fetch_all_by_transcript
my $transcript = $db->get_TranscriptAdaptor()->fetch_by_stable_id("ENST00000217299");
ok(@{$rfa->fetch_all_by_transcript($transcript)} == 14);
# Test store
$multi_db->save('core', 'regulatory_feature', 'regulatory_feature_object' );
my $slice = $db->get_SliceAdaptor()->fetch_by_seq_region_id(469286);
my $analysis = $db->get_AnalysisAdaptor->fetch_by_logic_name('miRanda');
my $rm = Bio::EnsEMBL::RegulatoryFactor->new(-name => 'factor1',
-type => 'miRNA_target');
my $rf = Bio::EnsEMBL::RegulatoryFeature->new(-name => 'hsa-miR-108',
-start => 100,
-end => 220,
-strand => -1,
-slice => $slice,
-analysis => $analysis,
-factor => $factor,
-adaptor => $rfa);
my @obj = [$transcript, 'positive', 'some evidence'];
$rfa->store($rf, \@obj);
ok($rf->dbID && $rf->adaptor());
$rf = $rfa->fetch_by_dbID($rf->dbID());
ok($rf->name() eq 'hsa-miR-108');
ok($rf->start() eq 100);
ok($rf->analysis()->logic_name() eq 'miRanda');
$multi_db->restore('core');
use strict;
use Bio::EnsEMBL::Test::TestUtils;
BEGIN { $| = 1;
use Test;
plan tests => 11;
}
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::CoordSystem;
use Bio::EnsEMBL::Slice;
use Bio::EnsEMBL::Analysis;
use Bio::EnsEMBL::RegulatorySearchRegion;
use Bio::EnsEMBL::DBSQL::RegulatorySearchRegionAdaptor;
our $verbose = 0;
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new;
# get a core DBAdaptor
#
my $dba = $multi->get_DBAdaptor("core");
my $rsa = $dba->get_RegulatorySearchRegionAdaptor();
#
# 1 create a new RegulatorySearchRegion
#
my $coord_system = Bio::EnsEMBL::CoordSystem->new
(-NAME => 'chromosome',
-VERSION => 'NCBI34',
-DBID => 1,
-RANK => 1);
my $analysis = Bio::EnsEMBL::Analysis->new(-LOGIC_NAME => 'test');
my $slice = Bio::EnsEMBL::Slice->new(-COORD_SYSTEM => $coord_system,
-SEQ_REGION_NAME => 'X',
-SEQ_REGION_LENGTH => 15e6,
-START => 0,
-END => 2_000_000);
my $gene = $dba->get_GeneAdaptor()->fetch_by_stable_id( "ENSG00000171456" );
my $rs = new Bio::EnsEMBL::RegulatorySearchRegion(-start => 100,
-end => 220,
-strand => -1,
-slice => $slice,
-analysis => $analysis,
-ensembl_object_id => 18256,
-ensembl_object_type => 'Gene',
-dbID => 1230,
-adaptor => $rsa);
ok($rs);
#
# 2-8 test the basic getter and setters
#
# 2 start
ok(test_getter_setter($rs,'start',10));
# 3 end
ok(test_getter_setter($rs,'end',14));
# 4 strand
ok(test_getter_setter($rs,'strand',1));
# 5 dbID
ok(test_getter_setter($rs,'dbID',20));
# 6 name
ok(test_getter_setter($rs,'name', 'CisRed_search_2'));
# 7 ensembl_object_id
ok(test_getter_setter($rs,'ensembl_object_id',18256));
#8 ensembl_object_type
ok(test_getter_setter($rs,'ensembl_object_type','Gene'));
#
# 9 check adaptor attaching
#
$rs->adaptor($rsa);
ok($rs->adaptor->isa('Bio::EnsEMBL::DBSQL::RegulatorySearchRegionAdaptor'));
# 10-11 Check loading of ensembl object
$gene = $rs->ensembl_object();
ok($gene->isa('Bio::EnsEMBL::Gene'));
ok($gene->dbID() == 18256);
use strict;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Test::MultiTestDB;
BEGIN { $| = 1;
use Test;
plan tests => 12;
}
my $multi_db = Bio::EnsEMBL::Test::MultiTestDB->new;
my $db = $multi_db->get_DBAdaptor('core');
my $verbose = 0;
# Test Creation
my $rfa = $db->get_RegulatorySearchRegionAdaptor();
ok(ref($rfa) && $rfa->isa('Bio::EnsEMBL::DBSQL::RegulatorySearchRegionAdaptor'));
#
## retrieve a search region via dbID
#
debug('---- fetch_by_dbID (default coords) ----');
my $feat = $rfa->fetch_by_dbID(2);
ok($feat->dbID == 2);
ok($feat->slice->seq_region_name() eq 'X');
ok($feat->start == 99639860);
ok($feat->end == 99646074);
ok($feat->strand == 1);
# List_dbids
my $ids = $rfa->list_dbIDs();
ok (@{$ids});
# test fetch_by_name
my $rsr = $rfa->fetch_by_name("CisRed_Search_11");
ok($rsr->dbID() == 2);
# Test store
$multi_db->save('core', 'regulatory_search_region');
my $slice = $db->get_SliceAdaptor()->fetch_by_seq_region_id(469293);
my $analysis = $db->get_AnalysisAdaptor->fetch_by_logic_name('cisred_search');
my $rf = Bio::EnsEMBL::RegulatorySearchRegion->new(-name => 'new_search_region',
-start => 100,
-end => 220,
-strand => -1,
-slice => $slice,
-analysis => $analysis,
-ensembl_object_type => "Gene",
-ensembl_object_id => 18258,
-adaptor => $rfa);
$rfa->store($rf);
ok($rf->dbID && $rf->adaptor());
$rf = $rfa->fetch_by_dbID($rf->dbID());
ok($rf->name() eq 'new_search_region');
ok($rf->start() eq 100);
ok($rf->analysis()->logic_name() eq 'cisred_search');
$multi_db->restore('core', 'regulatory_search_region');
Markdown is supported
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