Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlphaPulldown-ModelCIF-Conversion
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bienchen
AlphaPulldown-ModelCIF-Conversion
Commits
00d3f741
Commit
00d3f741
authored
1 year ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
Use reference DB info from JSON input
parent
743319e5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
convert_to_modelcif.py
+34
-24
34 additions, 24 deletions
convert_to_modelcif.py
with
34 additions
and
24 deletions
convert_to_modelcif.py
+
34
−
24
View file @
00d3f741
...
@@ -364,38 +364,48 @@ def _cast_release_date(release_date):
...
@@ -364,38 +364,48 @@ def _cast_release_date(release_date):
raise
raise
def
_cmp_ref_dbs
(
db_dct
,
db_objs
):
"""
Compare a reference DB dict to a list of ReferenceDatabase objects.
Note: does not check the DB name!
"""
for
obj
in
db_objs
:
if
db_dct
[
"
release_date
"
]
!=
obj
.
release_date
:
continue
if
db_dct
[
"
version
"
]
!=
obj
.
version
:
continue
for
url
in
db_dct
[
"
location_url
"
]:
if
url
==
obj
.
url
:
return
True
return
False
def
_get_modelcif_ref_dbs
(
meta_json
):
def
_get_modelcif_ref_dbs
(
meta_json
):
"""
Get sequence databases used for monomer features.
"""
"""
Get sequence databases used for monomer features.
"""
# vendor formatting for DB names/ URLs, extend on KeyError
# vendor formatting for DB names/ URLs, extend on KeyError
# ToDo: adapt to new JSON input
# ToDo: adapt to new JSON input
sdb_dct
=
{}
# 'sequence database list', starts as dict
sdb_lst
=
{}
# 'sequence database list' starts as dict since we need to
# compare DBs between the different monomers.
i
=
0
for
data
in
meta_json
.
values
():
for
data
in
meta_json
.
values
():
i
+=
1
for
db_name
,
vdct
in
data
[
"
databases
"
].
items
():
for
db_name
,
vdct
in
data
[
"
databases
"
].
items
():
if
vdct
[
"
version
"
]
==
"
NA
"
:
vdct
[
"
version
"
]
=
None
vdct
[
"
release_date
"
]
=
_cast_release_date
(
vdct
[
"
release_date
"
])
vdct
[
"
release_date
"
]
=
_cast_release_date
(
vdct
[
"
release_date
"
])
#
if
DB already exists, check URL and version
if
db_name
in
sdb_lst
:
if
db_name
in
sdb_dct
:
if
_cmp_ref_dbs
(
vdct
,
sdb_lst
[
db_name
])
:
# ToDo: switch URL to the actual URL read from JSON
continue
if
(
else
:
sdb_
dc
t
[
db_name
]
.
version
!=
vdct
[
"
version
"
]
sdb_
ls
t
[
db_name
]
=
[
]
or
sdb_dct
[
db_name
].
url
!=
vdct
[
"
location_url
"
]
[
0
]
for
url
in
vdct
[
"
location_url
"
]
:
):
sdb_lst
[
db_name
].
append
(
raise
RuntimeError
(
modelcif
.
ReferenceDatabase
(
"
Database versions or URLs differ for
"
db_name
,
+
f
"'
{
db_name
}
'
:
'
{
sdb_dct
[
db_name
].
version
}
/
"
url
,
+
f
"
{
sdb_dct
[
db_name
].
url
}
'
vs.
'
{
vdct
[
'
version
'
]
}
/
"
version
=
vdct
[
"
version
"
],
+
f
"
{
vdct
[
'
location_url
'
][
0
]
}
'"
release_date
=
vdct
[
"
release_date
"
],
)
)
# ToDo: deal with DBs with multiple URLs
)
sdb_dct
[
db_name
]
=
modelcif
.
ReferenceDatabase
(
db_name
,
vdct
[
"
location_url
"
][
0
],
version
=
vdct
[
"
version
"
],
release_date
=
vdct
[
"
release_date
"
],
)
return
sdb_
dc
t
.
values
()
return
[
x
for
sublist
in
sdb_
ls
t
.
values
()
for
x
in
sublist
]
def
_store_as_modelcif
(
def
_store_as_modelcif
(
...
@@ -472,7 +482,7 @@ def _store_as_modelcif(
...
@@ -472,7 +482,7 @@ def _store_as_modelcif(
system
.
target_entities
,
system
.
target_entities
,
model
,
model
,
sw_dct
,
sw_dct
,
# ToDo: _stor
t
e_as_modelcif should not use __meta__, __meta__ is
# ToDo: _store_as_modelcif should not use __meta__, __meta__ is
# tool specific
# tool specific
_get_modelcif_ref_dbs
(
data_json
[
"
__meta__
"
]),
_get_modelcif_ref_dbs
(
data_json
[
"
__meta__
"
]),
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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