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
22717880
Commit
22717880
authored
1 year ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
Argument parsing (early version)
parent
a02045f7
No related branches found
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
+90
-0
90 additions, 0 deletions
convert_to_modelcif.py
with
90 additions
and
0 deletions
convert_to_modelcif.py
0 → 100755
+
90
−
0
View file @
22717880
#!/usr/bin/env python3
"""
Take the output of the AlphaPulldown pipeline and turn it into a ModelCIF
file with a lot of metadata in place.
"""
from
absl
import
app
from
absl
import
flags
FLAGS
=
flags
.
FLAGS
flags
.
DEFINE_list
(
"
metadata
"
,
None
,
"
JSON files with information about experiment setup, one file per feature
"
,
)
flags
.
DEFINE_string
(
"
af2_output
"
,
None
,
"
Results of AlphaFold2 modelling
"
)
flags
.
DEFINE_integer
(
"
model_selected
"
,
None
,
"
Model to be converted into ModelCIF, use
'
--select_all
'
to convert all
"
+
"
models found in
'
--af2_output
'"
,
)
flags
.
DEFINE_bool
(
"
select_all
"
,
False
,
"
Convert all models found in
'
--af2_output
'
into ModelCIF, excludes
"
+
"'
--model_selected
'"
,
)
def
_mark_model_selection_as_mutual_exclusive
():
"""
Create & register a validator for model selection.
Enforce only one option is set, either
'
--select_all
'
or
'
--model_selected
'
.
Enforce that at least one of
'
--select_all
'
or
'
--model_selected
'
is set
(so this options will not pop up in `flags.mark_flags_as_required`).
"""
def
_validate_mutual_exclusion_model_selection
(
flags_dict
):
not_set_count
=
0
if
flags_dict
[
"
model_selected
"
]
is
None
:
not_set_count
+=
1
if
flags_dict
[
"
select_all
"
]
is
False
:
not_set_count
+=
1
if
not_set_count
==
1
:
return
True
return
False
flags
.
register_multi_flags_validator
(
[
"
model_selected
"
,
"
select_all
"
],
_validate_mutual_exclusion_model_selection
,
"
Exactly one (and only one) argument needs to be set.
"
,
)
_mark_model_selection_as_mutual_exclusive
()
flags
.
mark_flags_as_required
([
"
metadata
"
,
"
af2_output
"
])
# ToDo: implement a flags.register_validator() for 'metadata', checking that
# the file exists and is readable.
# ToDo: implement a flags.register_validator() for 'af2_output', checking that
# the file directory exists and is readable (overkill: check directory
# structure).
def
main
(
argv
):
"""
Run as script.
"""
"""
Here, the metadata json files for each feature are in features_monomers/
directory. The models are in models/ directory, and usually there are many
complexes modelled using different permutations of the monomeric features.
For the sake of size, I send you the models of only one dimer
cage_B_and_cage_C/ that was generated using features_monomers/cage_B.pkl
and features_monomers/cage_C.pkl accordingly.
Please note that typically all the cage_?_feature_metadata.json files are
identical in terms of used databases and software versions and generated
in one go.
However, theoretically they could be generated using different binaries/DBs
versions, so maybe it makes sense to compare them and store both/all
versions if they are different. This merging can be done on our
AlphaPulldown side and may be added now or later on. Let me know if it is
critical for you now.
"""
del
argv
# Unused.
if
__name__
==
"
__main__
"
:
app
.
run
(
main
)
# LocalWords: ToDo
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