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
2320cc74
Commit
2320cc74
authored
14 years ago
by
Andreas Kusalananda Kähäri
Browse files
Options
Downloads
Patches
Plain Diff
Remove mentionings of "truncate".
We assume we're running on fresh database.
parent
e0435792
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
misc-scripts/ontology/scripts/load_OBO_file.pl
+16
-35
16 additions, 35 deletions
misc-scripts/ontology/scripts/load_OBO_file.pl
with
16 additions
and
35 deletions
misc-scripts/ontology/scripts/load_OBO_file.pl
+
16
−
35
View file @
2320cc74
...
...
@@ -28,8 +28,6 @@ sub usage {
print
("
\t
-u/--user dbuser
\t
Database user name
\n
");
print
("
\t
-p/--pass dbpass
\t
User password (optional)
\n
");
print
("
\t
-d/--name dbname
\t
Database name
\n
");
print
("
\t
-t/--truncate
\t\t
Truncate (empty) each table
\n
");
print
("
\t\t\t\t
before writing (optional)
\n
");
print
("
\t
-f/--file file
\t\t
The OBO file to parse
\n
");
print
("
\t
-?/--help
\t\t
Displays this information
\n
");
}
...
...
@@ -37,12 +35,10 @@ sub usage {
#-----------------------------------------------------------------------
sub
write_ontology
{
my
(
$dbh
,
$truncate
,
$namespaces
)
=
@_
;
my
(
$dbh
,
$namespaces
)
=
@_
;
print
("
Writing to 'ontology' table...
\n
");
if
(
$truncate
)
{
$dbh
->
do
("
TRUNCATE TABLE ontology
")
}
my
$statement
=
"
INSERT INTO ontology (name, namespace) VALUES (?,?)
";
my
$sth
=
$dbh
->
prepare
(
$statement
);
...
...
@@ -86,12 +82,10 @@ sub write_ontology {
#-----------------------------------------------------------------------
sub
write_subset
{
my
(
$dbh
,
$truncate
,
$subsets
)
=
@_
;
my
(
$dbh
,
$subsets
)
=
@_
;
print
("
Writing to 'subset' table...
\n
");
if
(
$truncate
)
{
$dbh
->
do
("
TRUNCATE TABLE subset
")
}
$dbh
->
do
("
LOCK TABLE subset WRITE
");
my
$statement
=
...
...
@@ -137,12 +131,10 @@ sub write_subset {
#-----------------------------------------------------------------------
sub
write_term
{
my
(
$dbh
,
$truncate
,
$terms
,
$subsets
,
$namespaces
)
=
@_
;
my
(
$dbh
,
$terms
,
$subsets
,
$namespaces
)
=
@_
;
print
("
Writing to 'term' table...
\n
");
if
(
$truncate
)
{
$dbh
->
do
("
TRUNCATE TABLE term
")
}
$dbh
->
do
("
LOCK TABLE term WRITE
");
my
$statement
=
...
...
@@ -202,12 +194,10 @@ sub write_term {
#-----------------------------------------------------------------------
sub
write_relation_type
{
my
(
$dbh
,
$truncate
,
$relation_types
)
=
@_
;
my
(
$dbh
,
$relation_types
)
=
@_
;
print
("
Writing to 'relation_type' table...
\n
");
if
(
$truncate
)
{
$dbh
->
do
("
TRUNCATE TABLE relation_type
")
}
my
$select_stmt
=
"
SELECT relation_type_id FROM relation_type WHERE name = ?
";
my
$select_sth
=
$dbh
->
prepare
(
$select_stmt
);
...
...
@@ -259,12 +249,10 @@ sub write_relation_type {
#-----------------------------------------------------------------------
sub
write_relation
{
my
(
$dbh
,
$truncate
,
$terms
,
$relation_types
)
=
@_
;
my
(
$dbh
,
$terms
,
$relation_types
)
=
@_
;
print
("
Writing to 'relation' table...
\n
");
if
(
$truncate
)
{
$dbh
->
do
("
TRUNCATE TABLE relation
")
}
$dbh
->
do
("
LOCK TABLE relation WRITE
");
my
$statement
=
...
...
@@ -321,17 +309,15 @@ sub write_relation {
my
(
$dbhost
,
$dbport
);
my
(
$dbuser
,
$dbpass
);
my
(
$dbname
,
$truncate
,
$obo_file_name
);
my
(
$dbname
,
$obo_file_name
);
$dbport
=
'
3306
';
$truncate
=
0
;
if
(
!
GetOptions
(
'
dbhost|host|h=s
'
=>
\
$dbhost
,
'
dbport|port|P=i
'
=>
\
$dbport
,
'
dbuser|user|u=s
'
=>
\
$dbuser
,
'
dbpass|pass|p=s
'
=>
\
$dbpass
,
'
dbname|name|d=s
'
=>
\
$dbname
,
'
truncate|t
'
=>
\
$truncate
,
'
file|f=s
'
=>
\
$obo_file_name
,
'
help|?
'
=>
sub
{
usage
();
exit
}
)
||
!
defined
(
$dbhost
)
...
...
@@ -381,20 +367,17 @@ while ( defined( my $line = $obo->getline() ) ) {
$obo_file_date
=
sprintf
(
"
%s/%s
",
$obo_file_name
,
$data
);
if
(
defined
(
$stored_obo_file_date
)
)
{
if
(
$stored_obo_file_date
eq
$obo_file_date
&&
!
$truncate
)
{
if
(
$stored_obo_file_date
eq
$obo_file_date
)
{
print
("
This OBO file has already been processed.
\n
");
$obo
->
close
();
$dbh
->
disconnect
();
exit
;
}
elsif
(
index
(
$stored_obo_file_date
,
$obo_file_name
)
!=
-
1
&&
!
$truncate
)
}
elsif
(
index
(
$stored_obo_file_date
,
$obo_file_name
)
!=
-
1
)
{
print
<<EOT;
==> Trying to load a newer (?) OBO file that has already been loaded.
==> Please clean the database manually of data associated with this
==> file and try again... or use the -t (truncate) switch to empty the
==> tables completely (unless you want to preserve some of the data,
==> obviously).
==> Trying to load a newer (?) OBO file that has already
==> been loaded. Please clean the database manually of
==> data associated with this file and try again...
EOT
$obo
->
close
();
$dbh
->
disconnect
();
...
...
@@ -476,16 +459,14 @@ $obo->close();
print
("
Finished reading OBO file, now writing to database...
\n
");
write_ontology
(
$dbh
,
$truncate
,
\
%namespaces
);
write_subset
(
$dbh
,
$truncate
,
\
%subsets
);
write_term
(
$dbh
,
$truncate
,
\
%terms
,
\
%subsets
,
\
%namespaces
);
write_relation_type
(
$dbh
,
$truncate
,
\
%relation_types
);
write_relation
(
$dbh
,
$truncate
,
\
%terms
,
\
%relation_types
);
write_ontology
(
$dbh
,
\
%namespaces
);
write_subset
(
$dbh
,
\
%subsets
);
write_term
(
$dbh
,
\
%terms
,
\
%subsets
,
\
%namespaces
);
write_relation_type
(
$dbh
,
\
%relation_types
);
write_relation
(
$dbh
,
\
%terms
,
\
%relation_types
);
print
("
Updating meta table...
\n
");
if
(
$truncate
)
{
$dbh
->
do
("
TRUNCATE TABLE meta
")
}
my
$sth
=
$dbh
->
prepare
(
"
DELETE FROM meta
"
.
"
WHERE meta_key = 'OBO_file_date'
"
...
...
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