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
d66ab883
Commit
d66ab883
authored
15 years ago
by
Andreas Kusalananda Kähäri
Browse files
Options
Downloads
Patches
Plain Diff
Make SQL nicer.
parent
8aedd2ef
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
misc-scripts/ontology/scripts/add_subset_maps.pl
+16
-12
16 additions, 12 deletions
misc-scripts/ontology/scripts/add_subset_maps.pl
misc-scripts/ontology/scripts/compute_closure.pl
+4
-4
4 additions, 4 deletions
misc-scripts/ontology/scripts/compute_closure.pl
with
20 additions
and
16 deletions
misc-scripts/ontology/scripts/add_subset_maps.pl
+
16
−
12
View file @
d66ab883
#!/usr/
local/ensembl/
bin/perl
-w
#!/usr/bin/
env
perl
use
strict
;
use
warnings
;
...
...
@@ -6,6 +6,8 @@ use warnings;
use
DBI
qw( :sql_types )
;
use
Getopt::
Long
qw( :config no_ignore_case )
;
use
Data::
Dumper
;
#-----------------------------------------------------------------------
sub
usage
{
...
...
@@ -57,6 +59,9 @@ my $dbh =
DBI
->
connect
(
$dsn
,
$dbuser
,
$dbpass
,
{
'
RaiseError
'
=>
0
,
'
PrintError
'
=>
0
}
);
# Associate all subsets in the ontology database with their respective
# ontology.
my
%subsets
;
{
my
$statement
=
q(
...
...
@@ -81,23 +86,22 @@ WHERE ontology.ontology_id = term.ontology_id
while
(
$sth
->
fetch
()
)
{
push
(
@
{
$subsets
{
$ontology_name
}
},
$subset_name
);
}
$sth
->
finish
();
}
{
my
$select_statement
=
q(
SELECT child_term.term_id,
SELECT DISTINCT
child_term.term_id,
parent_term.term_id,
closure.distance
FROM
closure,
term
child
_term
,
term
parent_term
,
ontology
WHERE
closure.parent_term_id = parent_term.term_id
AND closure.child_term_id =
child_term
.term_id
AND FIND_IN_SET(?, parent_term.subsets) > 0
AND parent_term.ontology_id = ontology.ontology_id
FROM
ontology
JOIN
term
parent
_term
ON (
parent_term
.ontology_id = ontology.ontology_id)
JOIN closure
ON
(
closure.parent_term_id = parent_term.term_id
)
JOIN term
child_term
ON (child_term.term_id = closure.child_term_id)
WHERE FIND_IN_SET(?, parent_term.subsets) > 0
AND ontology.name = ?
ORDER BY child_term.accession, closure.distance;
)
;
...
...
This diff is collapsed.
Click to expand it.
misc-scripts/ontology/scripts/compute_closure.pl
+
4
−
4
View file @
d66ab883
...
...
@@ -94,10 +94,10 @@ SELECT DISTINCT
parent.parent_term_id,
child.distance + 1,
parent.child_term_id
FROM closure child
,
closure parent
WHERE
parent.child_term_id = child.parent_term_id
AND
child.distance = ?
FROM closure child
JOIN
closure parent
ON
(
parent.child_term_id = child.parent_term_id
)
WHERE
child.distance = ?
AND parent.distance = 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