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
cc95264d
Commit
cc95264d
authored
17 years ago
by
Glenn Proctor
Browse files
Options
Downloads
Patches
Plain Diff
Added lots of sanity checking to track down formatting errors.
parent
034681c2
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/external_db/update_external_dbs.pl
+48
-17
48 additions, 17 deletions
misc-scripts/external_db/update_external_dbs.pl
with
48 additions
and
17 deletions
misc-scripts/external_db/update_external_dbs.pl
+
48
−
17
View file @
cc95264d
...
@@ -53,6 +53,9 @@ if($release_num) {
...
@@ -53,6 +53,9 @@ if($release_num) {
@dbnames
=
grep
{
/^[a-zA-Z]+\_[a-zA-Z]+\_(core|est|estgene|vega|otherfeatures|cdna)\_${release_num}\_\d+[A-Za-z]?$/
}
@dbnames
;
@dbnames
=
grep
{
/^[a-zA-Z]+\_[a-zA-Z]+\_(core|est|estgene|vega|otherfeatures|cdna)\_${release_num}\_\d+[A-Za-z]?$/
}
@dbnames
;
}
}
my
@field_names
=
qw(external_db_id db_name release status dbprimary_acc_linkable display_label_linkable priority db_display_name type)
;
my
@types
=
qw(ARRAY ALT_TRANS MISC LIT PRIMARY_DB_SYNONYM)
;
#
#
# make sure the user wishes to continue
# make sure the user wishes to continue
...
@@ -77,8 +80,9 @@ if ($input ne 'yes') {
...
@@ -77,8 +80,9 @@ if ($input ne 'yes') {
my
$fh
=
IO::
File
->
new
();
my
$fh
=
IO::
File
->
new
();
$fh
->
open
(
$file
)
or
die
("
Could not open input file
$file
");
$fh
->
open
(
$file
)
or
die
("
Could not open input file
$file
");
my
@rows
;
my
@rows
;
my
$row
;
my
%bad_lines
;
while
(
$row
=
<
$fh
>
)
{
while
(
my
$row
=
<
$fh
>
)
{
chomp
(
$row
);
chomp
(
$row
);
next
if
(
$row
=~
/^#/
);
# skip comments
next
if
(
$row
=~
/^#/
);
# skip comments
next
if
(
$row
=~
/^$/
);
# and blank lines
next
if
(
$row
=~
/^$/
);
# and blank lines
...
@@ -104,16 +108,45 @@ while ($row = <$fh>) {
...
@@ -104,16 +108,45 @@ while ($row = <$fh>) {
exit
(
1
);
exit
(
1
);
}
}
if
(
$a
[
1
]
=~
/^$/
||
$a
[
1
]
=~
/^\s+$/
||
$a
[
1
]
=~
/^\d+$/
)
{
# do some formatting checks
print
STDERR
"
Cannot parse the following line:
\n
"
my
$blank
;
.
$row
for
(
my
$i
=
0
;
$i
<
scalar
(
@a
);
$i
++
)
{
.
"
\n
It probably has spaces separating the fields
"
if
(
$a
[
$i
]
eq
'')
{
.
"
rather than tabs.
\n
";
$bad_lines
{
$row
}
=
$field_names
[
$i
]
.
"
- field blank - check all tabs/spaces in line
";
exit
(
1
);
}
}
if
(
$a
[
1
]
=~
/\s/
)
{
$bad_lines
{
$row
}
=
"
db_name field appears to contain spaces
";
}
}
if
(
$a
[
1
]
=~
/^$/
)
{
$bad_lines
{
$row
}
=
"
db_name field appears to be missing
";
}
if
(
$a
[
1
]
=~
/^\s+$/
)
{
$bad_lines
{
$row
}
=
"
db_name field appears to be blank
";
}
if
(
$a
[
1
]
=~
/^\d+$/
)
{
$bad_lines
{
$row
}
=
"
db_name field appears to be numeric - check formatting
";
}
my
$type_ok
;
foreach
my
$type
(
@types
)
{
$type_ok
=
1
if
(
$a
[
8
]
eq
$type
);
}
$bad_lines
{
$row
}
=
"
type field is
"
.
$a
[
8
]
.
"
, not one of the recognised types
"
if
(
!
$type_ok
);
}
}
$fh
->
close
();
$fh
->
close
();
if
(
%bad_lines
)
{
print
STDERR
"
Cannot parse the following line(s) from
$file
; check that all fields are present and are separated by one tab (not spaces).
\n
";
print
STDERR
"
Name of problem field, and the error is printed in brackets first
\n\n
";
foreach
my
$row
(
keys
%bad_lines
)
{
print
STDERR
"
[
"
.
$bad_lines
{
$row
}
.
"
]
"
.
"
$row
\n
";
}
exit
(
1
);
}
# Load into master database
# Load into master database
if
(
!
$nonreleasemode
){
if
(
!
$nonreleasemode
){
load_database
(
$db
,
$master
,
@rows
);
load_database
(
$db
,
$master
,
@rows
);
...
@@ -121,30 +154,28 @@ $fh->close();
...
@@ -121,30 +154,28 @@ $fh->close();
# Check each other database in turn
# Check each other database in turn
# Load if no extra rows in db that aren't in master
# Load if no extra rows in db that aren't in master
# Warn and skip if there are
# Warn and skip if there are
foreach
my
$dbname
(
@dbnames
)
{
foreach
my
$dbname
(
@dbnames
)
{
print
STDERR
"
Looking at
$dbname
...
\n
";
print
STDERR
"
Looking at
$dbname
...
\n
";
if
(
$force
||
$nonreleasemode
)
{
if
(
$force
||
$nonreleasemode
)
{
print
STDERR
"
Forcing overwrite of external_db table in
"
print
STDERR
"
Forcing overwrite of external_db table in
"
.
"
$dbname
from
$file
\n
";
.
"
$dbname
from
$file
\n
";
load_database
(
$db
,
$dbname
,
@rows
);
load_database
(
$db
,
$dbname
,
@rows
);
}
elsif
(
compare_external_db
(
$db
,
$master
,
$dbname
))
{
}
elsif
(
compare_external_db
(
$db
,
$master
,
$dbname
))
{
print
STDERR
"
$dbname
has no additional rows.
"
print
STDERR
"
$dbname
has no additional rows.
"
.
"
Overwriting external_db table from
$file
\n
";
.
"
Overwriting external_db table from
$file
\n
";
load_database
(
$db
,
$dbname
,
@rows
);
load_database
(
$db
,
$dbname
,
@rows
);
}
else
{
}
else
{
print
STDERR
"
$dbname
has extra rows
"
print
STDERR
"
$dbname
has extra rows
"
.
"
that are not in
$file
, skipping
\n
";
.
"
that are not in
$file
, skipping
\n
";
}
}
}
}
...
...
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