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
7644f735
Commit
7644f735
authored
17 years ago
by
Andreas Kusalananda Kähäri
Browse files
Options
Downloads
Patches
Plain Diff
Formatting and slight change to startup logic to be able to see info
about how to run the script.
parent
38233e05
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
+102
-79
102 additions, 79 deletions
misc-scripts/meta_coord/update_meta_coord.pl
with
102 additions
and
79 deletions
misc-scripts/meta_coord/update_meta_coord.pl
+
102
−
79
View file @
7644f735
...
...
@@ -5,109 +5,132 @@ use Bio::EnsEMBL::DBSQL::DBConnection;
use
Getopt::
Long
;
my
$help
=
0
;
my
(
$host
,
$port
,
$user
,
$pass
,
$dbpattern
);
my
$usage
=
"
\n
$0 --host ecs2 --port 3364 --user ensadmin --pass ensembl --dbpattern core
[--help] displays this menu.
This script will dump the current meta_coord table in homo_sapiens_core_27_35a.meta_coord file.
Then it will update the meta_coord table for all the following table names one by one
assembly_exception
gene
exon
density_feature
ditag
ditag_feature
dna_align_feature
karyotype
marker_feature
misc_feature
qtl_feature
oligo_feature
prediction_exon
prediction_transcript
protein_align_feature
regulatory_feature
regulatory_search_region
repeat_feature
simple_feature
transcript
\n
";
GetOptions
('
help
'
=>
\
$help
,
'
host=s
'
=>
\
$host
,
'
port=i
'
=>
\
$port
,
'
user=s
'
=>
\
$user
,
'
pass=s
'
=>
\
$pass
,
'
dbpattern=s
'
=>
\
$dbpattern
);
#print "help: $help argv:" . scalar(@ARGV) . "$host $port $user $pass $dbname\n";
#if ($help || scalar @ARGV == 0) {
# print $usage,"\n";
# exit 0;
#}
my
(
$host
,
$port
,
$user
,
$pass
,
$dbpattern
);
my
$usage
=
qq(
$0 --host ens-staging --port 3306 --user ensadmin \\
--pass XXX --dbpattern core
[--help] displays this menu.
This script will dump the current meta_coord table in the latest
homo_sapiens_core.meta_coord file. Then it will update the meta_coord
table for all the following table names one by one
assembly_exception
gene
exon
density_feature
ditag
ditag_feature
dna_align_feature
karyotype
marker_feature
misc_feature
qtl_feature
oligo_feature
prediction_exon
prediction_transcript
protein_align_feature
regulatory_feature
regulatory_search_region
repeat_feature
simple_feature
transcript
)
;
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
)
{
print
$usage
,
"
\n
";
exit
0
;
}
#print "help: $help argv:"
#. scalar(@ARGV)
#. "$host $port $user $pass $dbname\n";
my
$dsn
=
"
DBI:mysql:host=
$host
";
$dsn
.=
"
;port=
$port
"
if
(
$port
);
my
$db
=
DBI
->
connect
(
$dsn
,
$user
,
$pass
);
my
@dbnames
=
map
{
$_
->
[
0
]
}
@
{
$db
->
selectall_arrayref
("
show databases
")};
my
@dbnames
=
map
{
$_
->
[
0
]
}
@
{
$db
->
selectall_arrayref
("
show databases
")
};
for
my
$dbname
(
@dbnames
)
{
next
if
(
$dbname
!~
/$dbpattern/
);
my
$dbc
=
new
Bio::EnsEMBL::DBSQL::
DBConnection
(
-
host
=>
$host
,
-
port
=>
$port
,
-
user
=>
$user
,
-
pass
=>
$pass
,
-
dbname
=>
$dbname
);
next
if
(
$dbname
!~
/$dbpattern/
);
my
$dbc
=
new
Bio::EnsEMBL::DBSQL::
DBConnection
(
-
host
=>
$host
,
-
port
=>
$port
,
-
user
=>
$user
,
-
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
oligo_feature
prediction_exon
prediction_transcript
protein_align_feature
regulatory_feature
regulatory_search_region
repeat_feature
simple_feature
transcript
)
;
unless
(
system
("
mysql -h
$host
-P
$port
-u
$user
-p
$pass
-N -e 'select * from meta_coord'
$dbname
>
$dbname
.meta_coord.backup
")
==
0
)
{
assembly_exception
gene
exon
density_feature
ditag_feature
dna_align_feature
karyotype
marker_feature
misc_feature
qtl_feature
oligo_feature
prediction_exon
prediction_transcript
protein_align_feature
regulatory_feature
regulatory_search_region
repeat_feature
simple_feature
transcript
)
;
unless
(
system
(
"
mysql -h
$host
-P
$port
-u
$user
-p
$pass
-N
"
.
"
-e 'SELECT * FROM meta_coord'
$dbname
"
.
"
>
$dbname
.meta_coord.backup
"
)
==
0
)
{
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
";
print
STDERR
"
Original meta_coord table backed up in
"
.
"
$dbname
.meta_coord.backup
\n
";
}
foreach
my
$table_name
(
@table_names
)
{
print
STDERR
"
Updating
$table_name
table entries...
";
my
$sql
=
"
delete from
meta_coord
where
table_name = ?
";
my
$sql
=
"
DELETE FROM
meta_coord
WHERE
table_name = ?
";
my
$sth
=
$dbc
->
prepare
(
$sql
);
$sth
->
execute
(
$table_name
);
$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
";
$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
";
$sth
=
$dbc
->
prepare
(
$sql
);
$sth
->
execute
;
$sth
->
finish
;
print
STDERR
"
Done
\n
";
}
}
}
## end for my $dbname (@dbnames)
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