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
8d9096bc
Commit
8d9096bc
authored
Apr 05, 2013
by
Magali Ruffier
Browse files
added support for is_obsolete
parent
eaaf8b00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
12 deletions
+25
-12
misc-scripts/ontology/scripts/add_subset_maps.pl
misc-scripts/ontology/scripts/add_subset_maps.pl
+3
-0
misc-scripts/ontology/scripts/compute_closure.pl
misc-scripts/ontology/scripts/compute_closure.pl
+2
-0
misc-scripts/ontology/scripts/load_OBO_file.pl
misc-scripts/ontology/scripts/load_OBO_file.pl
+19
-12
misc-scripts/ontology/sql/tables.sql
misc-scripts/ontology/sql/tables.sql
+1
-0
No files found.
misc-scripts/ontology/scripts/add_subset_maps.pl
View file @
8d9096bc
...
...
@@ -69,6 +69,7 @@ FROM ontology,
term,
subset
WHERE ontology.ontology_id = term.ontology_id
AND isnull(is_obsolete)
AND FIND_IN_SET(subset.name, term.subsets) > 0
)
;
...
...
@@ -93,6 +94,8 @@ WHERE ontology.name = %s
AND FIND_IN_SET(%s, parent_term.subsets) > 0
AND parent_term.ontology_id = closure.ontology_id
AND child_term.ontology_id = closure.ontology_id
AND isnull(parent_term.is_obsolete)
AND isnull(child_term.is_obsolete)
GROUP BY child_term.term_id, parent_term.term_id
)
;
...
...
misc-scripts/ontology/scripts/compute_closure.pl
View file @
8d9096bc
...
...
@@ -70,6 +70,7 @@ INSERT INTO closure
(child_term_id, parent_term_id, distance, subparent_term_id, ontology_id)
SELECT term_id, term_id, 0, NULL, ontology_id
FROM term
WHERE isnull(is_obsolete)
)
);
$dbh
->
do
(
...
...
@@ -80,6 +81,7 @@ SELECT term_id, term_id, 0, NULL, r.ontology_id
FROM term t, relation r
WHERE term_id = child_term_id
AND t.ontology_id != r.ontology_id
AND isnull(is_obsolete)
)
);
$dbh
->
do
(
...
...
misc-scripts/ontology/scripts/load_OBO_file.pl
View file @
8d9096bc
...
...
@@ -170,7 +170,7 @@ sub write_term {
$dbh
->
do
("
LOCK TABLES term WRITE, synonym WRITE
");
my
$statement
=
"
INSERT IGNORE INTO term (ontology_id, subsets, accession, name, definition, is_root) VALUES (?,?,?,?,?,?)
";
my
$statement
=
"
INSERT IGNORE INTO term (ontology_id, subsets, accession, name, definition, is_root
, is_obsolete
) VALUES (?,?,?,?,?,?
,?
)
";
my
$syn_stmt
=
"
INSERT INTO synonym (term_id, name) VALUES (?,?)
";
...
...
@@ -213,12 +213,13 @@ sub write_term {
}
else
{
#if not link it to Unknown ontology
$sth
->
bind_param
(
1
,
$unknown_onto_id
,
SQL_INTEGER
);
$sth
->
bind_param
(
2
,
$term_subsets
,
SQL_VARCHAR
);
$sth
->
bind_param
(
3
,
$term
->
{'
accession
'},
SQL_VARCHAR
);
$sth
->
bind_param
(
4
,
'
UNKNOWN NAME
',
SQL_VARCHAR
);
$sth
->
bind_param
(
5
,
'
UNKNOWN DEFINITION
',
SQL_VARCHAR
);
$sth
->
bind_param
(
6
,
$term
->
{'
is_root
'},
SQL_INTEGER
);
$sth
->
bind_param
(
1
,
$unknown_onto_id
,
SQL_INTEGER
);
$sth
->
bind_param
(
2
,
$term_subsets
,
SQL_VARCHAR
);
$sth
->
bind_param
(
3
,
$term
->
{'
accession
'},
SQL_VARCHAR
);
$sth
->
bind_param
(
4
,
'
UNKNOWN NAME
',
SQL_VARCHAR
);
$sth
->
bind_param
(
5
,
'
UNKNOWN DEFINITION
',
SQL_VARCHAR
);
$sth
->
bind_param
(
6
,
$term
->
{'
is_root
'},
SQL_INTEGER
);
$sth
->
bind_param
(
7
,
$term
->
{'
is_obsolete
'},
SQL_INTEGER
);
$sth
->
execute
();
my
$id
=
$dbh
->
last_insert_id
(
undef
,
undef
,
'
term
',
'
term_id
');
$term
->
{'
id
'}
=
$id
;
...
...
@@ -240,6 +241,7 @@ sub write_term {
$update_sth
->
bind_param
(
4
,
$term
->
{'
definition
'},
SQL_VARCHAR
);
$update_sth
->
bind_param
(
5
,
$existing_term_id
,
SQL_INTEGER
);
$update_sth
->
bind_param
(
6
,
$term
->
{'
is_root
'},
SQL_INTEGER
);
$update_sth
->
bind_param
(
7
,
$term
->
{'
is_obsolete
'},
SQL_INTEGER
);
$update_sth
->
execute
();
...
...
@@ -254,6 +256,7 @@ sub write_term {
$sth
->
bind_param
(
4
,
$term
->
{'
name
'},
SQL_VARCHAR
);
$sth
->
bind_param
(
5
,
$term
->
{'
definition
'},
SQL_VARCHAR
);
$sth
->
bind_param
(
6
,
$term
->
{'
is_root
'},
SQL_INTEGER
);
$sth
->
bind_param
(
7
,
$term
->
{'
is_obsolete
'},
SQL_INTEGER
);
$sth
->
execute
();
my
$id
=
$dbh
->
last_insert_id
(
undef
,
undef
,
'
term
',
'
term_id
');
...
...
@@ -633,7 +636,6 @@ foreach my $subs (@subsets) {
# get all non obsolete terms
foreach
my
$t
(
@
{
$ontology
->
get_terms
()})
{
if
(
!
(
$t
->
is_obsolete
()))
{
my
%term
;
my
$is_root
=
1
;
...
...
@@ -648,15 +650,21 @@ foreach my $t (@{$ontology->get_terms()}) {
}
$namespaces
{
$term
{'
namespace
'}}
=
$ontology_name
;
$term
{'
accession
'}
=
$t
->
id
();
$term
{'
name
'}
=
$t
->
name
();
$term
{'
definition
'}
=
$t
->
def_as_string
();
$term
{'
accession
'}
=
$t
->
id
();
$term
{'
name
'}
=
$t
->
name
();
$term
{'
definition
'}
=
$t
->
def_as_string
();
$term
{'
is_obsolete
'}
=
$t
->
is_obsolete
();
if
(
$t
->
idspace
()
ne
$ontology_name
)
{
$is_root
=
0
;
}
else
{
if
(
scalar
(
@
{
$ontology
->
get_parent_terms
(
$t
)
})
>
0
)
{
$is_root
=
0
;
}
else
{
if
(
$t
->
is_obsolete
())
{
$is_root
=
0
;
}
}
}
$term
{'
is_root
'}
=
$is_root
;
...
...
@@ -701,7 +709,6 @@ foreach my $t (@{$ontology->get_terms()}) {
$terms
{
$term
{'
accession
'}}
=
{
%term
};
}
}
#get all relationship types
...
...
misc-scripts/ontology/sql/tables.sql
View file @
8d9096bc
...
...
@@ -41,6 +41,7 @@ CREATE TABLE term (
name
VARCHAR
(
255
)
NOT
NULL
,
definition
TEXT
,
is_root
INT
,
is_obsolete
INT
,
PRIMARY
KEY
(
term_id
),
UNIQUE
INDEX
accession_idx
(
accession
),
...
...
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