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
5b20e766
Commit
5b20e766
authored
8 years ago
by
Alessandro Vullo
Browse files
Options
Downloads
Patches
Plain Diff
[
ENSCORESW-2123
]. Transfer logic to feature adaptor.
parent
2db9f0b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm
+33
-0
33 additions, 0 deletions
modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm
modules/Bio/EnsEMBL/Feature.pm
+17
-45
17 additions, 45 deletions
modules/Bio/EnsEMBL/Feature.pm
with
50 additions
and
45 deletions
modules/Bio/EnsEMBL/DBSQL/BaseFeatureAdaptor.pm
+
33
−
0
View file @
5b20e766
...
...
@@ -1166,6 +1166,39 @@ sub _remap {
return
\
@out
;
}
#
# get seq region boundary (start|end) for a feature
# the method attempts to retrieve the boundary directly from the db
# return undef if cannot determine the associated feature table
#
sub
_seq_region_boundary_from_db
{
my
(
$self
,
$feature
,
$boundary
)
=
@_
;
if
(
!
ref
(
$feature
)
||
!
$feature
->
isa
('
Bio::EnsEMBL::Feature
'))
{
throw
('
Expected Feature argument.
');
}
throw
"
Undefined boundary
"
unless
defined
$boundary
;
$boundary
eq
'
start
'
or
$boundary
eq
'
end
'
or
throw
"
Wrong boundary: select start|end
";
$boundary
=
'
seq_region_
'
.
$boundary
;
my
$sql_helper
=
$self
->
dbc
->
sql_helper
;
throw
"
Unable to get SqlHelper instance
"
unless
defined
$sql_helper
;
my
$feature_table
=
(
$self
->
_tables
)[
0
][
0
];
warning
(
sprintf
"
Unable to get %s for %s instance
\n
Could not find associated feature table, returning undef
",
$boundary
,
ref
$feature
)
and
return
undef
unless
defined
$feature_table
;
my
$db_id
=
$feature
->
dbID
;
my
$attrib_id
=
$feature_table
.
'
_id
';
my
$query
=
"
SELECT
${boundary}
from
${feature_table}
WHERE
${attrib_id}
=
${db_id}
";
return
$sql_helper
->
execute_single_result
(
-
SQL
=>
$query
);
}
=head2 store
...
...
This diff is collapsed.
Click to expand it.
modules/Bio/EnsEMBL/Feature.pm
+
17
−
45
View file @
5b20e766
...
...
@@ -1085,7 +1085,9 @@ sub seq_region_strand {
feature on the seq_region, as opposed to the relative (slice)
position.
Returns undef if this feature is not on a slice.
Returns undef if this feature is not on a slice or slice is
circular and cannot determine the position of the feature from
the db.
Returntype : int or undef
Exceptions : none
Caller : general
...
...
@@ -1099,10 +1101,12 @@ sub seq_region_start {
my
$slice
=
$self
->
slice
();
if
(
defined
(
$slice
)
)
{
return
$self
->
_seq_region_boundary_from_db
('
start
')
if
$slice
->
is_circular
()
and
$self
->
adaptor
()
and
$self
->
adaptor
->
dbc
();
if
(
$slice
->
is_circular
())
{
return
$self
->
adaptor
->
_seq_region_boundary_from_db
(
$self
,
'
start
')
if
$self
->
adaptor
();
return
undef
;
}
my
$start
;
if
(
$slice
->
strand
()
==
1
)
{
$start
=
$slice
->
start
()
+
$self
->
start
()
-
1
...
...
@@ -1127,7 +1131,9 @@ sub seq_region_start {
feature on the seq_region, as opposed to the relative (slice)
position.
Returns undef if this feature is not on a slice.
Returns undef if this feature is not on a slice or slice is
circular and cannot determine the position of the feature from
the db.
Returntype : int or undef
Exceptions : none
Caller : general
...
...
@@ -1141,9 +1147,11 @@ sub seq_region_end {
my
$slice
=
$self
->
slice
();
if
(
defined
(
$slice
)
)
{
return
$self
->
_seq_region_boundary_from_db
('
end
')
if
$slice
->
is_circular
()
and
$self
->
adaptor
()
and
$self
->
adaptor
->
dbc
();
if
(
$slice
->
is_circular
())
{
return
$self
->
adaptor
->
_seq_region_boundary_from_db
(
$self
,
'
end
')
if
$self
->
adaptor
();
return
undef
;
}
my
$end
;
if
(
$slice
->
strand
()
==
1
)
{
...
...
@@ -1583,40 +1591,4 @@ sub _deprecated_transform {
return
$self
;
}
#
# get seq region boundary (start|end) for a feature
# the method attempts to retrieve the boundary directly from the db
# if feature is not of class in the feature_table hash, it means the
# feature it's not stored in the db or we don't know how to get the
# region boundary from the db.
# Return undef in these cases.
#
sub
_seq_region_boundary_from_db
{
my
(
$self
,
$boundary
)
=
@_
;
throw
"
Undefined boundary
"
unless
defined
$boundary
;
$boundary
eq
'
start
'
or
$boundary
eq
'
end
'
or
throw
"
Wrong boundary: select start|end
";
$boundary
=
'
seq_region_
'
.
$boundary
;
my
$sql_helper
=
$self
->
adaptor
->
dbc
->
sql_helper
;
throw
"
Unable to get SqlHelper instance
"
unless
defined
$sql_helper
;
my
$feature_table
=
(
$self
->
adaptor
->
_tables
)[
0
][
0
];
warning
(
sprintf
"
Unable to get %s for %s instance
\n
Could not find associated feature table, returning undef
",
$boundary
,
ref
$self
)
and
return
undef
unless
defined
$feature_table
;
my
$db_id
=
$self
->
dbID
;
my
$attrib_id
=
$feature_table
.
'
_id
';
my
$query
=
"
SELECT
${boundary}
from
${feature_table}
WHERE
${attrib_id}
=
${db_id}
";
return
$sql_helper
->
execute_single_result
(
-
SQL
=>
$query
);
}
1
;
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