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
39b703eb
Commit
39b703eb
authored
12 years ago
by
Andreas Kusalananda Kähäri
Browse files
Options
Downloads
Patches
Plain Diff
Allow for using dbhost, dbport etc. as options, and set default value
for port to '3306'. Some formatting.
parent
ac77391b
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/meta_coord/update_meta_coord.pl
+48
-51
48 additions, 51 deletions
misc-scripts/meta_coord/update_meta_coord.pl
with
48 additions
and
51 deletions
misc-scripts/meta_coord/update_meta_coord.pl
+
48
−
51
View file @
39b703eb
...
...
@@ -7,6 +7,8 @@ use Getopt::Long;
my
$help
=
0
;
my
(
$host
,
$port
,
$user
,
$pass
,
$dbpattern
);
$port
=
'
3306
';
my
$usage
=
qq(
$0 --host ens-staging --port 3306 --user ensadmin \\
--pass XXX --dbpattern core
...
...
@@ -37,34 +39,50 @@ table for all the following table names one by one
transcript
)
;
if
(
scalar
@ARGV
==
0
)
{
if
(
scalar
@ARGV
==
0
)
{
print
$usage
,
"
\n
";
exit
0
;
}
GetOptions
(
'
help
'
=>
\
$help
,
'
host=s
'
=>
\
$host
,
'
port=i
'
=>
\
$port
,
'
user=s
'
=>
\
$user
,
'
pass=s
'
=>
\
$pass
,
'
dbpattern=s
'
=>
\
$dbpattern
);
if
(
$help
)
{
if
(
!
GetOptions
(
'
help!
'
=>
\
$help
,
'
dbhost|host=s
'
=>
\
$host
,
'
dbport|port=i
'
=>
\
$port
,
'
dbuser|user=s
'
=>
\
$user
,
'
dbpass|password|pass=s
'
=>
\
$pass
,
'
dbpattern=s
'
=>
\
$dbpattern
)
||
$help
)
{
print
$usage
,
"
\n
";
exit
0
;
exit
;
}
#print "help: $help argv:"
#. scalar(@ARGV)
#. "$host $port $user $pass $dbname\n";
my
$dsn
=
"
DBI:mysql:host=
$host
";
$dsn
.=
"
;port=
$port
"
if
(
$port
);
my
$dsn
=
"
DBI:mysql:host=
$host
;port=
$port
";
my
$db
=
DBI
->
connect
(
$dsn
,
$user
,
$pass
);
my
@dbnames
=
map
{
$_
->
[
0
]
}
@
{
$db
->
selectall_arrayref
("
show databases
")
};
map
{
$_
->
[
0
]
}
@
{
$db
->
selectall_arrayref
("
SHOW DATABASES
")
};
my
@table_names
=
qw(
assembly_exception
gene
exon
density_feature
ditag_feature
dna_align_feature
karyotype
marker_feature
misc_feature
qtl_feature
prediction_exon
prediction_transcript
protein_align_feature
repeat_feature
simple_feature
splicing_event
transcript
)
;
for
my
$dbname
(
@dbnames
)
{
...
...
@@ -77,37 +95,16 @@ for my $dbname (@dbnames) {
-
pass
=>
$pass
,
-
dbname
=>
$dbname
);
my
@table_names
=
qw(
assembly_exception
gene
exon
density_feature
ditag_feature
dna_align_feature
karyotype
marker_feature
misc_feature
qtl_feature
prediction_exon
prediction_transcript
protein_align_feature
repeat_feature
simple_feature
splicing_event
transcript
)
;
unless
(
system
(
"
mysql -h
$host
-P
$port
-u
$user
-p'
$pass
' -N
"
.
"
-e 'SELECT * FROM meta_coord'
$dbname
"
.
"
>
$dbname
.meta_coord.backup
"
)
==
0
)
if
(
system
(
"
mysql -h
$host
-P
$port
-u
$user
-p'
$pass
' -N
"
.
"
-e 'SELECT * FROM meta_coord'
$dbname
"
.
"
>
$dbname
.meta_coord.backup
"
)
)
{
print
STDERR
"
Can't dump the original meta_coord for back up
\n
";
exit
1
;
}
else
{
print
STDERR
"
Original meta_coord table backed up in
"
.
"
$dbname
.meta_coord.backup
\n
";
}
else
{
print
STDERR
"
Original meta_coord table backed up in
"
.
"
$dbname
.meta_coord.backup
\n
";
}
foreach
my
$table_name
(
@table_names
)
{
...
...
@@ -118,12 +115,12 @@ for my $dbname (@dbnames) {
$sth
->
finish
;
$sql
=
"
INSERT INTO meta_coord
"
.
"
SELECT '
$table_name
', s.coord_system_id,
"
.
"
MAX( t.seq_region_end - t.seq_region_start + 1 )
"
.
"
FROM
$table_name
t, seq_region s
"
.
"
WHERE t.seq_region_id = s.seq_region_id
"
.
"
GROUP BY s.coord_system_id
";
"
INSERT INTO meta_coord
"
.
"
SELECT '
$table_name
', s.coord_system_id,
"
.
"
MAX( t.seq_region_end - t.seq_region_start + 1 )
"
.
"
FROM
$table_name
t, seq_region s
"
.
"
WHERE t.seq_region_id = s.seq_region_id
"
.
"
GROUP BY s.coord_system_id
";
$sth
=
$dbc
->
prepare
(
$sql
);
$sth
->
execute
;
$sth
->
finish
;
...
...
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