Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ensembl-gh-mirror
ensembl
Commits
d66ab883
Commit
d66ab883
authored
Feb 11, 2010
by
Andreas Kusalananda Kähäri
Browse files
Make SQL nicer.
parent
8aedd2ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
misc-scripts/ontology/scripts/add_subset_maps.pl
misc-scripts/ontology/scripts/add_subset_maps.pl
+16
-12
misc-scripts/ontology/scripts/compute_closure.pl
misc-scripts/ontology/scripts/compute_closure.pl
+4
-4
No files found.
misc-scripts/ontology/scripts/add_subset_maps.pl
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;
)
;
...
...
misc-scripts/ontology/scripts/compute_closure.pl
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
)
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment