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
cc91660c
Commit
cc91660c
authored
21 years ago
by
Graham McVicker
Browse files
Options
Downloads
Patches
Plain Diff
more work on AttributeAdaptor, still incomplete
parent
227ae696
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/Bio/EnsEMBL/DBSQL/AttributeAdaptor.pm
+78
-57
78 additions, 57 deletions
modules/Bio/EnsEMBL/DBSQL/AttributeAdaptor.pm
with
78 additions
and
57 deletions
modules/Bio/EnsEMBL/DBSQL/AttributeAdaptor.pm
+
78
−
57
View file @
cc91660c
...
...
@@ -78,32 +78,40 @@ sub new {
=head2 fetch_all_by_MiscFeature
Arg [1] : none, string, int, Bio::EnsEMBL::Example $formal_parameter_name
Additional description lines
list, listref, hashref
Example : ( optional )
Description: testable description
Returntype : none, txt, int, float, Bio::EnsEMBL::Example
Exceptions : none
Caller : object::methodname or just methodname
Arg [1] : Bio::EnsEMBL::MiscFeature $mf
Example : @attributes = @{$attrib_adaptor->fetch_all_by_MiscFeature($mf)};
Description: Fetches all attributes for a given MiscFeature
Returntype : Bio::EnsEMBL::Attribute
Exceptions : throw if incorrect arguments
throw if provided MiscFeature does not have a dbID
Caller : MiscFeature
=cut
sub
fetch_all_by_MiscFeature
{
my
$self
=
shift
;
my
$mf
=
shift
;
}
=head2 fetch_all_by_Slice
Arg [1] :
none, string, int, Bio::EnsEMBL::Example $formal_parameter_nam
e
Additional description lines
list, listref, hashref
Example
:
( optional
)
Description: testable description
Returntype : none, txt, int, float, Bio::EnsEMBL::Example
Exceptions : non
e
Caller :
object::methodname or just methodnam
e
Arg [1] :
Bio::EnsEMBL::Slice $slic
e
Example : @attributes = @{$attrib_adaptor->fetch_all_by_Slice($slice)};
Description: Fetches all attributes for a given sequence region (which the
passed in slice is on
)
Returntype : Bio::EnsEMBL::Attribute
Exceptions : throw if incorrect arguments
throw if cannot get seq_region_id from provided Slic
e
Caller :
Slic
e
=cut
sub
fetch_all_by_Slice
{
my
$self
=
shift
;
my
$slice
=
shift
;
}
=head2 fetch_all_types
...
...
@@ -127,49 +135,54 @@ sub fetch_all_types {
=head2 store_on_Slice
Arg [1] : Bio::EnsEMBL::Slice $slice
Example : ( optional )
Description: testable description
Returntype : none, txt, int, float, Bio::EnsEMBL::Example
Exceptions : none
Caller : object::methodname or just methodname
Arg [2] : listref of Bio::EnsEMBL::Attribute objects $attribs
Example : $attribute_adaptor->store_on_Slice($slice, \@attribs);
Description: Stores a set of attributes on a sequence region given a
Slice object which is on the seq_region for which attributes are
being stored.
Returntype : none
Exceptions : throw if $slice argument not provided
Caller : general
=cut
sub
store_on_Slice
{
my
$self
=
shift
;
my
$slice
=
shift
;
my
$self
=
shift
;
my
$slice
=
shift
;
my
$attribs
=
shift
;
# need to access directly to prevent lazy loading
my
$attributes
=
$slice
->
{'
???????
'};
if
(
!
ref
(
$slice
)
||
!
$slice
->
isa
('
Bio::EnsEMBL::Slice
'))
{
throw
("
Slice argument expected.
");
}
if
(
!
defined
$attributes
)
{
return
;
if
(
ref
(
$attribs
)
ne
'
ARRAY
')
{
throw
("
Reference to list of Bio::EnsEMBL::Attribute objects
"
.
"
argument expected.
");
}
my
$seq_region_id
=
$slice
->
get_seq_region_id
();
if
(
!
defined
$seq_region_id
)
{
throw
(
);
if
(
!
$seq_region_id
)
{
throw
(
"
Could not get seq_region_id for provided slice:
"
$slice
->
name
()
);
}
my
$sth
=
$self
->
prepare
(
"
INSERT into seq_region_attrib
"
.
"
SET seq_region_id = ?, attrib_type_id = ?,
"
.
"
value = ?
"
);
"
SET seq_region_id = ?, attrib_type_id = ?,
"
.
"
value = ?
"
);
for
my
$attrib
(
@$attributes
)
{
my
$attrib_id
=
$self
->
_store_type
(
$attrib
);
$sth
->
excute
(
$seq_region_id
,
$attrib_id
,
$attrib
->
value
()
);
foreach
my
$at
(
@$attribs
)
{
if
(
!
ref
(
$at
)
&&
$at
->
isa
('
Bio::EnsEMBL::Attribute
'))
{
throw
("
Reference to list of Bio::EnsEMBL::Attribute objects
"
.
"
argument expected.
");
}
my
$atid
=
$self
->
_store_type
(
$at
);
$sth
->
execute
(
$seq_region_id
,
$attrib_id
,
$attrib
->
value
()
);
}
return
;
}
...
...
@@ -178,40 +191,49 @@ sub store_on_Slice {
=head2 store_on_MiscFeature
Arg [1] : Bio::EnsEMBL::MiscFeature $feature
Example : $attribute_adaptor->store_on_MiscFeature( $my_misc_feature )
Example : $attribute_adaptor->store_on_MiscFeature($my_misc_feature,
$attributes)
Description: Stores all the attributes on the misc feature.
Will duplicate things if called twice.
Returntype : none
Exceptions : on database problems.
Exceptions : throw on incorrect arguments
throw if provided feature is not stored in this database
Caller : general, MiscFeatureAdaptor
=cut
sub
store_on_MiscFeature
{
my
$self
=
shift
;
my
$feature
=
shift
;
# need to access directly to prevent lazy loading
my
$attributes
=
$feature
->
{'
attributes
'};
my
$self
=
shift
;
my
$feature
=
shift
;
my
$attributes
=
shift
;
if
(
!
defined
$attributes
)
{
return
;
if
(
!
ref
(
$feature
)
||
!
$feature
->
isa
('
Bio::EnsEMBL::MiscFeature
')
)
{
throw
("
MiscFeature argument expected
")
;
}
my
$feature_id
=
$feature
->
dbID
();
if
(
ref
(
$attributes
)
ne
'
ARRAY
')
{
throw
("
Reference to list of Bio::EnsEMBL::Attribute objects argument
"
.
"
expected
");
}
if
(
!
defined
$feature_id
)
{
throw
("
dbID in feature is not set.
"
.
"
Need to store feature before
store
ing
attributes.
\n
"
);
my
$db
=
$self
->
db
();
if
(
!
$feature
->
is_stored
(
$db
))
{
throw
("
MiscFeature is not stored in this DB - cannot
store attributes.
"
);
}
my
$feature_id
=
$feature
->
dbID
();
my
$sth
=
$self
->
prepare
(
"
INSERT into misc_attrib
"
.
"
SET misc_feature_id = ?, attrib_type_id = ?,
"
.
"
value = ?
"
);
for
my
$attrib
(
@$attributes
)
{
my
$attrib_id
=
$self
->
_store_type
(
$attrib
);
$sth
->
excute
(
$feature_id
,
$attrib_id
,
$attrib
->
value
()
);
if
(
!
ref
(
$at
)
&&
$at
->
isa
('
Bio::EnsEMBL::Attribute
'))
{
throw
("
Reference to list of Bio::EnsEMBL::Attribute objects
"
.
"
argument expected.
");
}
my
$atid
=
$self
->
_store_type
(
$attrib
);
$sth
->
execute
(
$feature_id
,
$atid
,
$attrib
->
value
()
);
}
return
;
...
...
@@ -225,7 +247,6 @@ sub _store_type {
my
$self
=
shift
;
my
$attrib
=
shift
;
my
$sth
=
$self
->
prepare
("
INSERT IGNORE INTO attrib_type set code = ?, name = ?,
"
.
"
description = ?
"
);
...
...
@@ -236,7 +257,7 @@ sub _store_type {
$sth
->
finish
();
if
(
$self
->
db
->
db_handle
->
{'
mysql_info
'}
==
0
){
if
(
$self
->
db
->
db_handle
->
{'
mysql_info
'}
==
0
)
{
# the insert failed because the code is already stored
$sth
=
$self
->
prepare
("
SELECT attrib_type_id FROM attrib_type
"
.
...
...
@@ -248,7 +269,7 @@ sub _store_type {
if
(
!
$atid
)
{
throw
("
Could not store or fetch attrib_type code [
$code
]
\n
"
.
"
Wrong permissions?
");
"
Wrong
database user/
permissions?
");
}
}
...
...
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