-
Notifications
You must be signed in to change notification settings - Fork 118
Fix organometallic conformer gen and custom CCD support #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9453bc2
7219081
1271e69
09bcf7e
393fe86
a5bb17d
b5500f2
3b21379
300bfcd
ee44679
1fd3d53
f3e25f3
caa81b9
76c0e9a
d28bd2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ data_module_args: | |
| # DatasetConfigKwargs: https://github.com/aqlaboratory/openfold-3/blob/main/openfold3/projects/of3_all_atom/config/dataset_configs.py#L270 | ||
| # Arguments for creating template and MSA features | ||
| dataset_config_kwargs: | ||
| ccd_file_path: null # if null, uses CCD from Biotite | ||
| ccd_file_path: null # optional custom CCD (.cif or .bcif); if null, uses Biotite CCD | ||
| # MSA Settings: https://github.com/aqlaboratory/openfold-3/blob/main/openfold3/projects/of3_all_atom/config/dataset_config_components.py#L32 | ||
| # Use this section to customize parsing of MSAs into features, more information in docs/source/precomputed_msa_how_to.md | ||
| msa: | ||
|
|
@@ -158,4 +158,4 @@ template_preprocessor_settings: | |
| structure_array_directory: null | ||
| cache_directory: <tmp-dir>/of3_template_data/template_cache | ||
| log_directory: null | ||
| ccd_file_path: null | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, still there but moved up |
||
| ccd_file_path: null | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,9 @@ | |
| SamplerDataset, | ||
| ) | ||
| from openfold3.core.data.pipelines.preprocessing.template import TemplatePreprocessor | ||
| from openfold3.core.data.primitives.structure.biotite_ccd import ( | ||
| update_biotite_ccd, | ||
| ) | ||
| from openfold3.core.data.tools.colabfold_msa_server import ( | ||
| MsaComputationSettings, | ||
| augment_main_msa_with_query_sequence, | ||
|
|
@@ -545,6 +548,20 @@ def setup(self, stage=None): | |
| dist.broadcast_object_list(placeholder, src=0) | ||
| self.inference_config.query_set = placeholder[0] | ||
| super().setup() | ||
| self._base_worker_init = self.worker_init_function_with_data_seed | ||
| self.worker_init_function_with_data_seed = self._worker_init_with_ccd | ||
|
|
||
| def _worker_init_with_ccd(self, worker_id, rank=None): | ||
| """Wrap the base worker init to re-apply the custom Biotite CCD path. | ||
|
|
||
| The custom CCD setting in Biotite is process-local global state, so we reapply | ||
| it in each worker for future-proofing with spawn/forkserver. | ||
| """ | ||
| self._base_worker_init(worker_id, rank) | ||
| dataset = torch.utils.data.get_worker_info().dataset | ||
| ccd_path = getattr(dataset, "_biotite_ccd_path", None) | ||
| if ccd_path is not None: | ||
| update_biotite_ccd(ccd_path) | ||
|
Comment on lines
+562
to
+564
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see Claude doing this pattern a lot – and I don't love it – a better pattern would be to declare _biotite_ccd_path as a nullable attribute that's defaulting to None. |
||
|
|
||
|
|
||
| # TODO: Remove debug logic and improve handlingi of training only features | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,6 @@ | |
| import pandas as pd | ||
| import torch | ||
| from biotite.structure import AtomArray | ||
| from biotite.structure.io import pdbx | ||
| from torch.utils.data import Dataset | ||
|
|
||
| from openfold3.core.config.msa_pipeline_configs import MsaSampleProcessorInputInference | ||
|
|
@@ -56,6 +55,9 @@ | |
| from openfold3.core.data.pipelines.sample_processing.template import ( | ||
| process_template_structures_of3, | ||
| ) | ||
| from openfold3.core.data.primitives.structure.biotite_ccd import ( | ||
| update_biotite_ccd_from_file, | ||
| ) | ||
| from openfold3.core.data.primitives.structure.component import BiotiteCCDWrapper | ||
| from openfold3.core.data.primitives.structure.query import ( | ||
| StructureWithReferenceMolecules, | ||
|
|
@@ -112,12 +114,15 @@ def __init__( | |
| if self.template_preprocessor_settings.preparse_structures: | ||
| self.template_preprocessor_settings.structure_file_format = "npz" | ||
|
|
||
| # Parse CCD | ||
| if dataset_config.ccd_file_path is not None: | ||
| logger.debug("Parsing CCD file.") | ||
| self.ccd = pdbx.CIFFile.read(dataset_config.ccd_file_path) | ||
| else: | ||
| self.ccd = BiotiteCCDWrapper() | ||
| # If a custom CCD file is provided, overwrite Biotite's global CCD. | ||
| # The resolved path is stored for re-applying in DataLoader workers | ||
| # started with spawn/forkserver. | ||
| self._biotite_ccd_path = update_biotite_ccd_from_file( | ||
| dataset_config.ccd_file_path | ||
| ) | ||
|
Comment on lines
+120
to
+122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this run into an issue if the user provided CCD only contains customized structures, but not standard structures like the residues? |
||
|
|
||
| # Template code requires "conventional" CIF format | ||
| self._ccd = BiotiteCCDWrapper() | ||
|
|
||
| # Create individual datapoint cache (allows rerunning the same query with | ||
| # different seeds) | ||
|
|
@@ -264,7 +269,7 @@ def create_template_features( | |
| template_structures_directory=self.template_preprocessor_settings.structure_directory, | ||
| template_structure_array_directory=self.template_preprocessor_settings.structure_array_directory, | ||
| template_file_format=self.template_preprocessor_settings.structure_file_format, | ||
| ccd=self.ccd, | ||
| ccd=self._ccd, | ||
| ) | ||
|
|
||
| # Featurization | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait so this will no longer be supported?