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
d0d8858f
Commit
d0d8858f
authored
20 years ago
by
Glenn Proctor
Browse files
Options
Downloads
Patches
Plain Diff
Added -create option to (re)create database.
parent
08c58114
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/xref_mapping/XrefParser/BaseParser.pm
+41
-2
41 additions, 2 deletions
misc-scripts/xref_mapping/XrefParser/BaseParser.pm
misc-scripts/xref_mapping/xref_parser.pl
+6
-5
6 additions, 5 deletions
misc-scripts/xref_mapping/xref_parser.pl
with
47 additions
and
7 deletions
misc-scripts/xref_mapping/XrefParser/BaseParser.pm
+
41
−
2
View file @
d0d8858f
...
...
@@ -19,7 +19,7 @@ my %dependent_sources;
my
%taxonomy2species_id
;
my
%name2species_id
;
my
(
$host
,
$port
,
$dbname
,
$user
,
$pass
);
my
(
$host
,
$port
,
$dbname
,
$user
,
$pass
,
$create
);
my
$skipdownload
;
# --------------------------------------------------------------------------------
...
...
@@ -27,11 +27,13 @@ my $skipdownload;
sub
run
{
(
$host
,
$port
,
$dbname
,
$user
,
$pass
,
my
$speciesr
,
my
$sourcesr
,
$skipdownload
)
=
@_
;
(
$host
,
$port
,
$dbname
,
$user
,
$pass
,
my
$speciesr
,
my
$sourcesr
,
$skipdownload
,
$create
)
=
@_
;
my
@species
=
@$speciesr
;
my
@sources
=
@$sourcesr
;
create
(
$host
,
$port
,
$user
,
$pass
,
$dbname
)
if
(
$create
);
my
$dbi
=
dbi
();
# validate species names
...
...
@@ -771,5 +773,42 @@ sub sanitise {
# --------------------------------------------------------------------------------
# Create database if required. Assumes sql/table.sql and sql/populate_metadata.sql
# are present.
sub
create
{
my
(
$host
,
$port
,
$user
,
$pass
,
$dbname
)
=
@_
;
my
$dbh
=
DBI
->
connect
(
"
DBI:mysql:host=
$host
:port=
$port
",
$user
,
$pass
,
{'
RaiseError
'
=>
1
});
# check to see if the database already exists
my
%dbs
=
map
{
$_
->
[
0
]
=>
1
}
@
{
$dbh
->
selectall_arrayref
('
SHOW DATABASES
')};
if
(
$dbs
{
$dbname
})
{
if
(
$create
)
{
$dbh
->
do
(
"
DROP DATABASE
$dbname
"
);
print
"
Removed existing database
$dbname
\n
";
}
else
{
die
("
Database
$dbname
already exists. Use -create option to overwrite it.
");
}
}
$dbh
->
do
(
"
CREATE DATABASE
"
.
$dbname
);
print
"
Creating
$dbname
from sql/table.sql
\n
";
die
"
Cannot open sql/table.sql
"
if
(
!
-
e
"
sql/table.sql
");
my
$cmd
=
"
mysql -u
$user
-p
$pass
-P
$port
-h
$host
$dbname
< sql/table.sql
";
system
(
$cmd
);
print
"
Populating metadata in
$dbname
from sql/populate_metadata.sql
\n
";
die
"
Cannot open sql/populate_metadata.sql
"
if
(
!
-
e
"
sql/populate_metadata.sql
");
$cmd
=
"
mysql -u
$user
-p
$pass
-P
$port
-h
$host
$dbname
< sql/populate_metadata.sql
";
system
(
$cmd
);
}
# --------------------------------------------------------------------------------
1
;
This diff is collapsed.
Click to expand it.
misc-scripts/xref_mapping/xref_parser.pl
+
6
−
5
View file @
d0d8858f
...
...
@@ -3,7 +3,7 @@ use strict;
use
Getopt::
Long
;
use
XrefParser::
BaseParser
;
my
(
$host
,
$port
,
$dbname
,
$user
,
$pass
,
@species
,
@sources
,
$skipdownload
);
my
(
$host
,
$port
,
$dbname
,
$user
,
$pass
,
@species
,
@sources
,
$skipdownload
,
$create
);
GetOptions
('
user=s
'
=>
\
$user
,
'
pass=s
'
=>
\
$pass
,
...
...
@@ -13,6 +13,7 @@ GetOptions('user=s' => \$user,
'
species=s
'
=>
\
@species
,
'
source=s
'
=>
\
@sources
,
'
skipdownload
'
=>
\
$skipdownload
,
'
create
'
=>
\
$create
,
'
help
'
=>
sub
{
usage
();
exit
(
0
);
});
@species
=
split
(
/,/
,
join
('
,
',
@species
));
...
...
@@ -23,21 +24,21 @@ if (!$user || !$host || !$dbname) {
usage
();
exit
(
1
);
}
XrefParser::BaseParser::
run
(
$host
,
$port
,
$dbname
,
$user
,
$pass
,
\
@species
,
\
@sources
,
$skipdownload
);
XrefParser::BaseParser::
run
(
$host
,
$port
,
$dbname
,
$user
,
$pass
,
\
@species
,
\
@sources
,
$skipdownload
,
$create
);
# --------------------------------------------------------------------------------
# TODO - better usage instructions
sub
usage
{
print
<<
"
EOF
";
xref_parser
.
pm
-
user
{
user
}
-
pass
{
password
}
-
host
{
host
}
-
port
{
port
}
-
dbname
{
database
}
-
species
{
species1
,
species2
}
-
source
{
source1
,
source2
}
-
skipdownload
xref_parser
.
pm
-
user
{
user
}
-
pass
{
password
}
-
host
{
host
}
-
port
{
port
}
-
dbname
{
database
}
-
species
{
species1
,
species2
}
-
source
{
source1
,
source2
}
-
skipdownload
-
create
EOF
}
#
--------------------------------------------------------------------------------
#--------------------------------------------------------------------------------
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