Newer
Older
use Bio::EnsEMBL::Test::MultiTestDB;
use Bio::EnsEMBL::Test::TestUtils;
use Bio::EnsEMBL::Operon;
use Bio::EnsEMBL::OperonTranscript;
use Bio::EnsEMBL::Exon;
use Bio::EnsEMBL::Translation;
use Bio::EnsEMBL::Transcript;
use Bio::EnsEMBL::Gene;
use Bio::EnsEMBL::DBSQL::OperonAdaptor;
debug("Startup test");
ok(1);
my $multi = Bio::EnsEMBL::Test::MultiTestDB->new();
$multi->save('core', 'operon', 'operon_transcript', 'gene', 'transcript');
my $dba = $multi->get_DBAdaptor("core");
debug("Test database instatiated");
ok($dba);
# get a slice
my $slice = $dba->get_SliceAdaptor()->fetch_by_seq_region_id(469283);
# create operon
my $start = 3403162;
my $end = 3405288;
my $strand = 1;
my $display_label = "accBC";
my $analysis = $dba->get_AnalysisAdaptor->fetch_by_logic_name("Genscan");
my $operon = Bio::EnsEMBL::Operon->new( -START => $start,
-END => $end,
-STRAND => $strand,
-SLICE => $slice,
-DISPLAY_LABEL => $display_label, -STABLE_ID=>"op1", -ANALYSIS=>$analysis );
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
my $gene_name = "accB";
my $gene_start = 31225346;
my $gene_end = 31225646;
my $gene_strand = 1;
my $gene_name2 = "accC";
my $gene_start2 = 31225746;
my $gene_end2 = 31225946;
my $gene_strand2 = 1;
# create a gene/transcript/translation/operon set and then store it
my $gene = Bio::EnsEMBL::Gene->new();
my $transcript = Bio::EnsEMBL::Transcript->new();
my $exon = Bio::EnsEMBL::Exon->new();
my $translation = Bio::EnsEMBL::Translation->new();
ok( defined $analysis );
for my $feature ( $gene, $transcript, $exon ) {
$feature->start($gene_start);
$feature->end($gene_end);
$feature->slice($slice);
$feature->strand($gene_strand);
}
$gene->analysis($analysis);
$transcript->analysis($analysis);
$exon->phase(0);
$exon->end_phase(0);
$transcript->add_Exon($exon);
$translation->start_Exon($exon);
$translation->end_Exon($exon);
$translation->start(1);
$translation->end( ( $gene_start - $gene_end + 1 )/3 );
$translation->transcript($transcript);
$transcript->translation($translation);
$gene->add_Transcript($transcript);
$dba->get_GeneAdaptor()->store($gene);
ok( defined $gene->dbID() );
ok( defined $transcript->dbID() );
ok( defined $translation->dbID() );
ok( defined $exon->dbID() );
# create a second gene/transcript/translation/operon set and then store it
my $gene2 = Bio::EnsEMBL::Gene->new();
my $transcript2 = Bio::EnsEMBL::Transcript->new();
my $exon2 = Bio::EnsEMBL::Exon->new();
my $translation2 = Bio::EnsEMBL::Translation->new();
for my $feature ( $gene2, $transcript2, $exon2 ) {
$feature->start($gene_start);
$feature->end($gene_end);
$feature->slice($slice);
$feature->strand($gene_strand);
}
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
$gene2->analysis($analysis);
$transcript2->analysis($analysis);
$exon2->phase(0);
$exon2->end_phase(0);
$transcript2->add_Exon($exon2);
$translation2->start_Exon($exon2);
$translation2->end_Exon($exon2);
$translation2->start(1);
$translation2->end( ( $gene_start2 - $gene_end2 + 1 )/3 );
$translation2->transcript($transcript2);
$transcript2->translation($translation2);
$gene2->add_Transcript($transcript2);
$dba->get_GeneAdaptor()->store($gene2);
ok( defined $gene2->dbID() );
ok( defined $transcript2->dbID() );
ok( defined $translation2->dbID() );
ok( defined $exon2->dbID() );
# add the gene to the operon transcript
my $operon_adaptor = Bio::EnsEMBL::DBSQL::OperonAdaptor->new($dba);
# add the operon_transcript to the operon
# create an operon transcript
my $operon_transcript =
Bio::EnsEMBL::OperonTranscript->new( -START => $start,
-END => $end,
-STRAND => $strand,
-SLICE => $slice, -STABLE_ID=>"opt1", -ANALYSIS=>$analysis );
$operon_transcript->add_gene($gene);
$operon_transcript->add_gene($gene2);
$operon->add_OperonTranscript($operon_transcript);
is( $analysis, $operon_transcript->analysis(), "Analysis" );
my $operon_transcript2 =
Bio::EnsEMBL::OperonTranscript->new( -START => $start,
-END => $gene_start2,
-STRAND => $strand,
-SLICE => $slice, -STABLE_ID=>"opt2", -ANALYSIS=>$analysis );
$operon_transcript2->add_gene($gene);
$operon->add_OperonTranscript($operon_transcript2);
is( $analysis, $operon_transcript->analysis(), "Analysis" );
# store the lot
# store operon
$operon_adaptor->store($operon);
ok( defined $operon->dbID() );
# retrieve operon
my $operon2 = $operon_adaptor->fetch_by_dbID( $operon->dbID() );
is( $operon2->dbID(), $operon->dbID(), "Operon ID" );
is( $operon2->display_label(), $operon->display_label(), "Operon name" );
is( $operon2->seq_region_start(), $operon->seq_region_start(), "Operon start" );
is( $operon2->seq_region_end(), $operon->seq_region_end(), "Operon end" );
is( $operon2->seq_region_strand(),
$operon->seq_region_strand(),
"Operon strand" );
is( $operon2->analysis(), $operon->analysis(), "Analysis" );
my @operon_transcripts = @{ $operon2->get_all_OperonTranscripts() };
# check operon transcript
is( scalar @operon_transcripts, 2, "Expected number of transcripts" );
my $operon_transcript_r = $operon_transcripts[0];
is( $operon_transcript_r->dbID(), $operon_transcript->dbID(),
is( $operon_transcript_r->seq_region_start(),
$operon_transcript->seq_region_start(),
"Operon transcript start" );
is( $operon_transcript_r->seq_region_end(),
$operon_transcript->seq_region_end(),
"Operon transcript end" );
is( $operon_transcript_r->seq_region_strand(),
$operon_transcript->seq_region_strand(),
"Operon transcript strand" );
is( $operon_transcript->analysis(), $operon_transcript_r->analysis(), "Analysis" );
# check genes
my @ogenes = @{ $operon_transcript_r->get_all_Genes() };
is( scalar @ogenes, 2, "Expected number of genes" );
is( $gene_r->dbID(), $gene->dbID(), "Gene ID" );
is( $gene_r->seq_region_start(), $gene->seq_region_start(), "Gene start" );
is( $gene_r->seq_region_end(), $gene->seq_region_end(), "Gene end" );
is( $gene_r->seq_region_strand(), $gene->seq_region_strand(), "Gene strand" );
is( $gene_r->dbID(), $gene2->dbID(), "Gene ID" );
is( $gene_r->seq_region_start(), $gene2->seq_region_start(), "Gene start" );
is( $gene_r->seq_region_end(), $gene2->seq_region_end(), "Gene end" );
is( $gene_r->seq_region_strand(), $gene2->seq_region_strand(), "Gene strand" );
my $operon_transcript_r2 = $operon_transcripts[1];
$operon_transcript2->dbID(),
"Operon transcript ID" );
is( $operon_transcript_r2->seq_region_start(),
$operon_transcript2->seq_region_start(),
"Operon transcript start" );
is( $operon_transcript_r2->seq_region_end(),
$operon_transcript2->seq_region_end(),
"Operon transcript end" );
is( $operon_transcript_r2->seq_region_strand(),
$operon_transcript2->seq_region_strand(),
"Operon transcript strand" );
is( $operon_transcript2->analysis(), $operon_transcript_r2->analysis(), "Analysis" );
# check genes
@ogenes = @{ $operon_transcript_r2->get_all_Genes() };
is( scalar @ogenes, 1, "Expected number of genes" );
is( $gene_r->dbID(), $gene->dbID(), "Gene ID" );
is( $gene_r->seq_region_start(), $gene->seq_region_start(), "Gene start" );
is( $gene_r->seq_region_end(), $gene->seq_region_end(), "Gene end" );
is( $gene_r->seq_region_strand(), $gene->seq_region_strand(), "Gene strand" );
$dba->get_OperonAdaptor()->remove($operon);
$dba->get_GeneAdaptor()->remove($gene);
$dba->get_GeneAdaptor()->remove($gene2);
#test the get_species_and_object_type method from the Registry
my $registry = 'Bio::EnsEMBL::Registry';
my ( $species, $object_type, $db_type ) = $registry->get_species_and_object_type('T16152-16153-4840');
ok( $species eq 'homo_sapiens' && $object_type eq 'OperonTranscript');
#48
my $ota = $dba->get_OperonTranscriptAdaptor();
$operon_transcript = $ota->fetch_by_stable_id('T16152-16153-4840');
debug( "OperonTranscript->fetch_by_stable_id()" );
ok( $operon_transcript );
#49
@operon_transcripts = @{ $ota->fetch_all_versions_by_stable_id('T16152-16153-4840') };
debug("fetch_all_versions_by_stable_id");
ok( scalar(@operon_transcripts) == 1 );
#50
debug ("OperonTranscript->list_stable_ids");
my $stable_ids = $ota->list_stable_ids();
ok (@{$stable_ids});
$multi->restore('core');
done_testing();