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
0b6a1221
Commit
0b6a1221
authored
21 years ago
by
Graham McVicker
Browse files
Options
Downloads
Patches
Plain Diff
added code to identify toplevel seq_regions
parent
b5f973cd
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/surgery/SeqStoreConverter/BasicConverter.pm
+120
-28
120 additions, 28 deletions
misc-scripts/surgery/SeqStoreConverter/BasicConverter.pm
with
120 additions
and
28 deletions
misc-scripts/surgery/SeqStoreConverter/BasicConverter.pm
+
120
−
28
View file @
0b6a1221
# Convert release 18-era schemas to use new non-clone/contig schema
# Convert release 18
/19
-era schemas to use new non-clone/contig schema
use
strict
;
use
warnings
;
use
DBI
;
use
Bio::EnsEMBL::DBSQL::
DBAdaptor
;
use
POSIX
qw(ceil)
;
package
SeqStoreConverter::
BasicConverter
;
###############################################################################
...
...
@@ -20,8 +23,14 @@ sub new {
(
$host
,
$port
)
=
split
(
/:/
,
$host
);
$port
||=
3306
;
my
$dbh
=
DBI
->
connect
(
"
DBI:mysql:host=
$host
:port=
$port
",
$user
,
$pass
,
{'
RaiseError
'
=>
1
});
my
$db
=
Bio::EnsEMBL::DBSQL::
DBAdaptor
->
new
(
-
host
=>
$host
,
-
port
=>
$port
,
-
user
=>
$user
,
-
pass
=>
$pass
,
-
driver
=>
'
mysql
');
my
$dbh
=
$db
->
db_handle
();
$self
->
verbose
(
$verbose
);
...
...
@@ -30,11 +39,8 @@ sub new {
$self
->
source
(
$source
);
$self
->
target
(
$target
);
$self
->
schema
(
$schema
);
$self
->
host
(
$host
);
$self
->
password
(
$pass
);
$self
->
user
(
$user
);
$self
->
port
(
$port
);
$self
->
limit
(
$limit
);
$self
->
db
(
$db
);
#check to see if the destination and source databases exist already.
...
...
@@ -97,28 +103,10 @@ sub dbh {
return
$self
->
{'
dbh
'};
}
sub
user
{
my
$self
=
shift
;
$self
->
{'
user
'}
=
shift
if
(
@
_
);
return
$self
->
{'
user
'};
}
sub
host
{
sub
db
{
my
$self
=
shift
;
$self
->
{'
host
'}
=
shift
if
(
@
_
);
return
$self
->
{'
host
'};
}
sub
port
{
my
$self
=
shift
;
$self
->
{'
port
'}
=
shift
if
(
@
_
);
return
$self
->
{'
port
'};
}
sub
password
{
my
$self
=
shift
;
$self
->
{'
password
'}
=
shift
if
(
@
_
);
return
$self
->
{'
password
'};
$self
->
{'
db
'}
=
shift
if
(
@
_
);
return
$self
->
{'
db
'};
}
...
...
@@ -1055,4 +1043,108 @@ sub create_attribs {
}
sub
set_top_level
{
my
$self
=
shift
;
my
$target
=
$self
->
target
();
my
$db
=
$self
->
db
();
my
$csa
=
$db
->
get_CoordSystemAdaptor
();
my
$slice_adaptor
=
$db
->
get_SliceAdaptor
();
my
$attrib_type_id
=
$self
->
add_attrib_code
();
$self
->
debug
("
Setting toplevel attributes of seq_regions
");
$self
->
debug
("
Deleting old toplevel attributes
");
my
$sth
=
$db
->
prepare
("
DELETE FROM
$target
.seq_region_attrib
"
.
"
WHERE attrib_type_id = ?
");
$sth
->
execute
(
$attrib_type_id
);
$sth
->
finish
();
$sth
=
$db
->
prepare
("
INSERT INTO
$target
.seq_region_attrib
"
.
'
SET seq_region_id = ?,
'
.
'
attrib_type_id = ?,
'
.
'
value = ?
');
#get all of the seqlevel sequence regions and project them to 'toplevel'
my
$seqlevel_cs
=
$csa
->
fetch_by_name
('
seqlevel
');
if
(
!
$seqlevel_cs
)
{
die
("
No 'seqlevel' CoordSystem has been defined.
");
}
my
$slices
=
$slice_adaptor
->
fetch_all
(
$seqlevel_cs
->
name
(),
$seqlevel_cs
->
version
);
my
%already_seen
;
my
$total_number
=
@$slices
;
my
$total_processed
=
0
;
my
$five_percent
=
int
(
$total_number
/
20
);
$self
->
debug
("
Adding new toplevel attributes
");
foreach
my
$slice
(
@$slices
)
{
my
$projection
=
$slice
->
project
('
toplevel
');
foreach
my
$segment
(
@$projection
)
{
my
$proj_slice
=
$segment
->
[
2
];
my
$seq_region_id
=
$proj_slice
->
get_seq_region_id
();
if
(
!
$already_seen
{
$seq_region_id
})
{
my
$string
=
$proj_slice
->
coord_system
->
name
();
$string
.=
"
"
.
$proj_slice
->
seq_region_name
();
$self
->
debug
("
Adding
$string
to toplevel
");
$sth
->
execute
(
$seq_region_id
,
$attrib_type_id
,
1
);
$already_seen
{
$seq_region_id
}
=
1
;
}
}
# print out progress periodically
$total_processed
++
;
if
(
$total_processed
%
$five_percent
==
0
)
{
$self
->
debug
("
"
.
ceil
(
$total_processed
/
$total_number
*
100
)
.
"
% complete
");
}
}
$sth
->
finish
();
}
sub
add_attrib_code
{
my
$self
=
shift
;
my
$db
=
$self
->
db
();
my
$target
=
$self
->
target
();
# add a toplevel code to the attrib_type table if it is not there already
my
$sth
=
$db
->
prepare
("
SELECT attrib_type_id
"
.
"
FROM
$target
.attrib_type
"
.
"
WHERE code = 'toplevel'
");
$sth
->
execute
();
if
(
$sth
->
rows
())
{
my
(
$attrib_type_id
)
=
$sth
->
fetchrow_array
();
$sth
->
finish
();
return
$attrib_type_id
;
}
$sth
->
finish
();
$sth
=
$db
->
prepare
("
INSERT INTO
$target
.attrib_type
"
.
"
SET code = 'toplevel',
"
.
"
name = 'Top Level',
"
.
"
description = 'Top Level Non-Redundant Sequence Region'
");
$sth
->
execute
();
my
$attrib_type_id
=
$sth
->
{'
mysql_insertid
'};
$sth
->
finish
();
return
$attrib_type_id
;
}
1
;
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