Skip to content
Snippets Groups Projects
Commit 22717880 authored by Bienchen's avatar Bienchen
Browse files

Argument parsing (early version)

parent a02045f7
No related branches found
No related tags found
No related merge requests found
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment