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
d15ac173
Commit
d15ac173
authored
12 years ago
by
Magali Ruffier
Browse files
Options
Downloads
Patches
Plain Diff
adding test cases for gene_attrib
parent
8cf11593
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
+148
-1
148 additions, 1 deletion
modules/t/attributeAdaptor.t
with
148 additions
and
1 deletion
modules/t/attributeAdaptor.t
+
148
−
1
View file @
d15ac173
...
...
@@ -17,6 +17,7 @@ my $db = $multi->get_DBAdaptor("core");
my
$slice_adaptor
=
$db
->
get_SliceAdaptor
();
my
$mfa
=
$db
->
get_MiscFeatureAdaptor
();
my
$ga
=
$db
->
get_GeneAdaptor
();
#
...
...
@@ -29,7 +30,7 @@ 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
');
$multi
->
hide
('
core
',
'
misc_attrib
',
'
seq_region_attrib
',
'
attrib_type
'
,
'
gene_attrib
'
);
##############
...
...
@@ -254,6 +255,152 @@ ok($count == 0);
cmp_ok
(
$new_rows
,
'
>
',
$current_rows
,
'
Asserting the storage of undefined attributes will always store them
');
}
#################
# Gene functionality tests
#
$attrib
=
Bio::EnsEMBL::
Attribute
->
new
(
-
NAME
=>
'
test_name2
',
-
CODE
=>
'
test_code2
',
-
DESCRIPTION
=>
'
test_desc2
',
-
VALUE
=>
'
test_value2
');
my
$gene
=
$ga
->
fetch_by_stable_id
('
ENSG00000171456
');
$aa
->
store_on_Gene
(
$gene
,
[
$attrib
]);
#
# make sure the seq_region_attrib table was updated
#
$count
=
$db
->
dbc
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM gene_attrib
"
.
"
WHERE gene_id =
"
.
$gene
->
dbID
())
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
#
# make sure the attrib_type table was updated
#
$count
=
$db
->
dbc
->
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
#
@attribs
=
@
{
$aa
->
fetch_all_by_Gene
(
$gene
)};
ok
(
@attribs
==
1
);
@attribs
=
@
{
$aa
->
fetch_all_by_Gene
(
$gene
,"
rubbish
")};
ok
(
@attribs
==
0
);
@attribs
=
@
{
$aa
->
fetch_all_by_Gene
(
$gene
,"
test_code2
")};
ok
(
@attribs
==
1
);
@attribs
=
@
{
$aa
->
fetch_all_by_Gene
(
undef
,"
test_code2
")};
ok
(
@attribs
==
1
);
$attrib
=
$attribs
[
0
];
ok
(
$attrib
->
name
eq
'
test_name2
');
ok
(
$attrib
->
code
eq
'
test_code2
');
ok
(
$attrib
->
description
eq
'
test_desc2
');
ok
(
$attrib
->
value
eq
'
test_value2
');
#
# test the removal of this attribute with atrrib code
#
$aa
->
remove_from_Gene
(
$gene
,"
junk
");
$count
=
$db
->
dbc
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM gene_attrib
"
.
"
WHERE gene_id =
"
.
$gene
->
dbID
())
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
#
# test the removal of this attribute
#
$aa
->
remove_from_Gene
(
$gene
,"
test_code2
");
$count
=
$db
->
dbc
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM gene_attrib
"
.
"
WHERE gene_id =
"
.
$gene
->
dbID
())
->
[
0
]
->
[
0
];
ok
(
$count
==
0
);
#
# make sure the attribute is no longer retrievable
#
@attribs
=
@
{
$aa
->
fetch_all_by_Gene
(
$gene
)};
ok
(
@attribs
==
0
);
#
# try to add an attribute with an already existing code
#
$aa
->
store_on_Gene
(
$gene
,
[
$attrib
]);
#
# make sure the seq_region_attrib table was updated
#
$count
=
$db
->
dbc
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM gene_attrib
"
.
"
WHERE gene_id =
"
.
$gene
->
dbID
())
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
#
# make sure the attrib_type table was updated
#
$count
=
$db
->
dbc
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM attrib_type
"
.
"
WHERE code = 'test_code2'
")
->
[
0
]
->
[
0
];
ok
(
$count
==
1
);
@attribs
=
@
{
$aa
->
fetch_all_by_Gene
(
$gene
)};
note
"
attribs:
"
.
scalar
(
@attribs
);
ok
(
@attribs
==
1
);
@attribs
=
@
{
$aa
->
fetch_all_by_Gene
(
undef
)};
ok
(
@attribs
==
1
);
#
# test the removal of this attribute
#
$aa
->
remove_from_Gene
(
$gene
);
$count
=
$db
->
dbc
->
db_handle
->
selectall_arrayref
("
SELECT count(*) FROM gene_attrib
"
.
"
WHERE gene_id =
"
.
$gene
->
dbID
())
->
[
0
]
->
[
0
];
ok
(
$count
==
0
);
#
# test the storage of empty attrib values
#
{
my
%args
=
(
-
NAME
=>
'
test_name2
',
-
CODE
=>
'
test_code2
',
-
DESCRIPTION
=>
'
test_desc2
');
my
$current_rows
=
count_rows
(
$db
,
'
gene_attrib
');
my
$atrib
=
Bio::EnsEMBL::
Attribute
->
new
(
%args
,);
$aa
->
store_on_Gene
(
$gene
,
[
Bio::EnsEMBL::
Attribute
->
new
(
%args
,
-
VALUE
=>
q{}
)]);
$aa
->
store_on_Gene
(
$gene
,
[
Bio::EnsEMBL::
Attribute
->
new
(
%args
,
-
VALUE
=>
0
)]);
my
$new_rows
=
count_rows
(
$db
,
'
gene_attrib
');
cmp_ok
(
$new_rows
,
'
>
',
$current_rows
,
'
Asserting the storage of undefined attributes will always store them
');
}
$multi
->
restore
('
core
',
'
misc_attrib
',
'
seq_region_attrib
',
'
attrib_type
');
done_testing
();
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