Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
b2d50053
Commit
b2d50053
authored
21 years ago
by
Graham McVicker
Browse files
Options
Downloads
Patches
Plain Diff
added tests for new AttributeAdaptor
parent
16231d85
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/t/attributeAdaptor.t
+200
-0
200 additions, 0 deletions
modules/t/attributeAdaptor.t
with
200 additions
and
0 deletions
modules/t/attributeAdaptor.t
0 → 100644
+
200
−
0
View file @
b2d50053
use
strict
;
use
lib
'
t
';
use
TestUtils
qw(test_getter_setter debug)
;
BEGIN
{
$|
=
1
;
use
Test
;
plan
tests
=>
11
;
}
use
MultiTestDB
;
use
Bio::EnsEMBL::
Attribute
;
our
$verbose
=
0
;
my
$multi
=
MultiTestDB
->
new
;
# get a core DBAdaptor
my
$db
=
$multi
->
get_DBAdaptor
("
core
");
my
$slice_adaptor
=
$db
->
get_SliceAdaptor
();
my
$mfa
=
$db
->
get_MiscFeatureAdaptor
();
#
# Test get_AttributeAdaptor works
#
my
$aa
=
$db
->
get_AttributeAdaptor
();
ok
(
$aa
&&
ref
(
$aa
)
&&
$aa
->
isa
('
Bio::EnsEMBL::DBSQL::AttributeAdaptor
'));
# hide the contents of the attrib_type, misc_attrib, seq_region_attrib tables
# so we can test storing etc. with a clean slate
$multi
->
hide
('
core
',
'
misc_attrib
',
'
seq_region_attrib
',
'
attrib_type
');
##############
# MiscFeature functionality tests
#
my
$attrib
=
Bio::EnsEMBL::
Attribute
->
new
(
-
NAME
=>
'
test_name
',
-
CODE
=>
'
test_code
',
-
DESC
=>
'
test_desc
',
-
VALUE
=>
'
test_value
');
my
$mf
=
$mfa
->
fetch_by_dbID
(
1
);
$aa
->
store_on_MiscFeature
(
$mf
,
[
$attrib
]);
#
# make sure the misc_attrib table was updated
#
my
$count
=
$db
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM misc_attrib
"
.
"
WHERE misc_feature_id = 1
")
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
#
# make sure the attrib_type table was updated
#
$count
=
$db
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM attrib_type
"
.
"
WHERE code = 'test_code'
")
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
#
# test that we can now retrieve this attribute
#
my
@attribs
=
@
{
$aa
->
fetch_all_by_MiscFeature
(
$mf
)};
ok
(
@attribs
==
1
);
$attrib
=
$attribs
[
0
];
ok
(
$attrib
->
name
eq
'
test_name
');
ok
(
$attrib
->
code
eq
'
test_code
');
ok
(
$attrib
->
desc
eq
'
test_desc
');
ok
(
$attrib
->
value
eq
'
test_value
');
#
# test the removal of this attribute
#
$aa
->
remove_from_MiscFeature
(
$mf
);
#
# make sure the misc_attrib table was updated
#
my
$count
=
$db
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM misc_attrib
"
.
"
WHERE misc_feature_id = 1
")
->
[
0
]
->
[
0
];
ok
(
$count
==
0
);
#
# make sure the attribute is no longer retrievable
#
my
@attribs
=
@
{
$aa
->
fetch_all_by_MiscFeature
(
$mf
)};
ok
(
@attribs
==
0
);
#################
# Slice functionality tests
#
my
$attrib
=
Bio::EnsEMBL::
Attribute
->
new
(
-
NAME
=>
'
test_name2
',
-
CODE
=>
'
test_code2
',
-
DESC
=>
'
test_desc2
',
-
VALUE
=>
'
test_value2
');
my
$slice
=
$slice_adaptor
->
fetch_by_region
('
chromosome
',
'
20
');
$aa
->
store_on_Slice
(
$slice
,
[
$attrib
]);
#
# make sure the seq_region_attrib table was updated
#
my
$count
=
$db
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM seq_region_attrib
"
.
"
WHERE seq_region_id =
"
.
$slice
->
get_seq_region_id
())
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
#
# make sure the attrib_type table was updated
#
$count
=
$db
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM attrib_type
"
.
"
WHERE code = 'test_code2'
")
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
#
# test that we can now retrieve this attribute
#
my
@attribs
=
@
{
$aa
->
fetch_all_by_Slice
(
$slice
)};
ok
(
@attribs
==
1
);
$attrib
=
$attribs
[
0
];
ok
(
$attrib
->
name
eq
'
test_name2
');
ok
(
$attrib
->
code
eq
'
test_code2
');
ok
(
$attrib
->
desc
eq
'
test_desc2
');
ok
(
$attrib
->
value
eq
'
test_value2
');
#
# test the removal of this attribute
#
$aa
->
remove_from_Slice
(
$slice
);
#
# make sure the seq_region_attrib table was updated
#
my
$count
=
$db
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM seq_region_attrib
"
.
"
WHERE seq_region_id =
"
.
$slice
->
get_seq_region_id
())
->
[
0
]
->
[
0
];
ok
(
$count
==
0
);
#
# make sure the attribute is no longer retrievable
#
my
@attribs
=
@
{
$aa
->
fetch_all_by_Slice
(
$slice
)};
ok
(
@attribs
==
0
);
#
# try to add an attribute with an already existing code
#
$aa
->
store_on_Slice
(
$slice
,
[
$attrib
]);
#
# make sure the seq_region_attrib table was updated
#
my
$count
=
$db
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM seq_region_attrib
"
.
"
WHERE seq_region_id =
"
.
$slice
->
get_seq_region_id
())
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
#
# make sure the attrib_type table was updated
#
$count
=
$db
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM attrib_type
"
.
"
WHERE code = 'test_code2'
")
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
my
@attribs
=
@
{
$aa
->
fetch_all_by_Slice
(
$slice
)};
ok
(
@attribs
==
1
);
$multi
->
restore
('
core
',
'
misc_attrib
',
'
seq_region_attrib
',
'
attrib_type
');
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment