openprotein-python 0.16.0__tar.gz → 0.17.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/PKG-INFO +9 -9
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/align/align.py +18 -2
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/align/api.py +28 -9
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/align/msa.py +49 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/align/schemas.py +44 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/__init__.py +1 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/molecules/chains.py +6 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/molecules/complex.py +159 -44
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/molecules/protein.py +13 -1
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/prompt/api.py +35 -8
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/prompt/prompt.py +95 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/pyproject.toml +18 -18
- openprotein_python-0.16.0/openprotein/api/__init__.py +0 -9
- openprotein_python-0.16.0/openprotein/api/align.py +0 -400
- openprotein_python-0.16.0/openprotein/api/assaydata.py +0 -216
- openprotein_python-0.16.0/openprotein/api/deprecated/__init__.py +0 -5
- openprotein_python-0.16.0/openprotein/api/deprecated/design.py +0 -86
- openprotein_python-0.16.0/openprotein/api/deprecated/poet.py +0 -308
- openprotein_python-0.16.0/openprotein/api/deprecated/predict.py +0 -276
- openprotein_python-0.16.0/openprotein/api/deprecated/train.py +0 -224
- openprotein_python-0.16.0/openprotein/api/design.py +0 -86
- openprotein_python-0.16.0/openprotein/api/designer.py +0 -267
- openprotein_python-0.16.0/openprotein/api/embedding.py +0 -446
- openprotein_python-0.16.0/openprotein/api/error.py +0 -5
- openprotein_python-0.16.0/openprotein/api/fold.py +0 -157
- openprotein_python-0.16.0/openprotein/api/job.py +0 -94
- openprotein_python-0.16.0/openprotein/api/predict.py +0 -273
- openprotein_python-0.16.0/openprotein/api/predictor.py +0 -326
- openprotein_python-0.16.0/openprotein/api/prompt.py +0 -464
- openprotein_python-0.16.0/openprotein/api/svd.py +0 -203
- openprotein_python-0.16.0/openprotein/api/train.py +0 -222
- openprotein_python-0.16.0/openprotein/api/umap.py +0 -257
- openprotein_python-0.16.0/openprotein/app/__init__.py +0 -19
- openprotein_python-0.16.0/openprotein/app/deprecated.py +0 -8
- openprotein_python-0.16.0/openprotein/app/models/__init__.py +0 -33
- openprotein_python-0.16.0/openprotein/app/models/align/__init__.py +0 -4
- openprotein_python-0.16.0/openprotein/app/models/align/base.py +0 -20
- openprotein_python-0.16.0/openprotein/app/models/align/msa.py +0 -134
- openprotein_python-0.16.0/openprotein/app/models/align/prompt.py +0 -78
- openprotein_python-0.16.0/openprotein/app/models/assaydata.py +0 -176
- openprotein_python-0.16.0/openprotein/app/models/deprecated/__init__.py +0 -10
- openprotein_python-0.16.0/openprotein/app/models/deprecated/design.py +0 -109
- openprotein_python-0.16.0/openprotein/app/models/deprecated/poet.py +0 -204
- openprotein_python-0.16.0/openprotein/app/models/deprecated/predict.py +0 -232
- openprotein_python-0.16.0/openprotein/app/models/deprecated/train.py +0 -307
- openprotein_python-0.16.0/openprotein/app/models/design.py +0 -105
- openprotein_python-0.16.0/openprotein/app/models/designer.py +0 -143
- openprotein_python-0.16.0/openprotein/app/models/embeddings/__init__.py +0 -12
- openprotein_python-0.16.0/openprotein/app/models/embeddings/base.py +0 -337
- openprotein_python-0.16.0/openprotein/app/models/embeddings/esm.py +0 -32
- openprotein_python-0.16.0/openprotein/app/models/embeddings/future.py +0 -135
- openprotein_python-0.16.0/openprotein/app/models/embeddings/openprotein.py +0 -21
- openprotein_python-0.16.0/openprotein/app/models/embeddings/poet.py +0 -366
- openprotein_python-0.16.0/openprotein/app/models/embeddings/poet2.py +0 -385
- openprotein_python-0.16.0/openprotein/app/models/embeddings/test.py +0 -38
- openprotein_python-0.16.0/openprotein/app/models/fold/__init__.py +0 -6
- openprotein_python-0.16.0/openprotein/app/models/fold/alphafold2.py +0 -54
- openprotein_python-0.16.0/openprotein/app/models/fold/base.py +0 -81
- openprotein_python-0.16.0/openprotein/app/models/fold/boltz.py +0 -57
- openprotein_python-0.16.0/openprotein/app/models/fold/esmfold.py +0 -38
- openprotein_python-0.16.0/openprotein/app/models/fold/future.py +0 -56
- openprotein_python-0.16.0/openprotein/app/models/futures.py +0 -473
- openprotein_python-0.16.0/openprotein/app/models/predict.py +0 -246
- openprotein_python-0.16.0/openprotein/app/models/predictor/__init__.py +0 -4
- openprotein_python-0.16.0/openprotein/app/models/predictor/predict.py +0 -78
- openprotein_python-0.16.0/openprotein/app/models/predictor/predictor.py +0 -362
- openprotein_python-0.16.0/openprotein/app/models/predictor/validate.py +0 -37
- openprotein_python-0.16.0/openprotein/app/models/prompt.py +0 -141
- openprotein_python-0.16.0/openprotein/app/models/svd.py +0 -260
- openprotein_python-0.16.0/openprotein/app/models/train.py +0 -303
- openprotein_python-0.16.0/openprotein/app/models/umap.py +0 -156
- openprotein_python-0.16.0/openprotein/app/services/__init__.py +0 -16
- openprotein_python-0.16.0/openprotein/app/services/align.py +0 -356
- openprotein_python-0.16.0/openprotein/app/services/assaydata.py +0 -119
- openprotein_python-0.16.0/openprotein/app/services/deprecated/__init__.py +0 -9
- openprotein_python-0.16.0/openprotein/app/services/deprecated/design.py +0 -79
- openprotein_python-0.16.0/openprotein/app/services/deprecated/predict.py +0 -152
- openprotein_python-0.16.0/openprotein/app/services/deprecated/train.py +0 -140
- openprotein_python-0.16.0/openprotein/app/services/design.py +0 -79
- openprotein_python-0.16.0/openprotein/app/services/designer.py +0 -107
- openprotein_python-0.16.0/openprotein/app/services/embeddings.py +0 -137
- openprotein_python-0.16.0/openprotein/app/services/fold.py +0 -89
- openprotein_python-0.16.0/openprotein/app/services/job.py +0 -61
- openprotein_python-0.16.0/openprotein/app/services/predict.py +0 -145
- openprotein_python-0.16.0/openprotein/app/services/predictor.py +0 -192
- openprotein_python-0.16.0/openprotein/app/services/prompt.py +0 -133
- openprotein_python-0.16.0/openprotein/app/services/svd.py +0 -102
- openprotein_python-0.16.0/openprotein/app/services/train.py +0 -135
- openprotein_python-0.16.0/openprotein/app/services/umap.py +0 -97
- openprotein_python-0.16.0/openprotein/schemas/__init__.py +0 -74
- openprotein_python-0.16.0/openprotein/schemas/align.py +0 -61
- openprotein_python-0.16.0/openprotein/schemas/assaydata.py +0 -27
- openprotein_python-0.16.0/openprotein/schemas/deprecated/__init__.py +0 -21
- openprotein_python-0.16.0/openprotein/schemas/deprecated/design.py +0 -173
- openprotein_python-0.16.0/openprotein/schemas/deprecated/poet.py +0 -70
- openprotein_python-0.16.0/openprotein/schemas/deprecated/predict.py +0 -82
- openprotein_python-0.16.0/openprotein/schemas/deprecated/train.py +0 -34
- openprotein_python-0.16.0/openprotein/schemas/design.py +0 -202
- openprotein_python-0.16.0/openprotein/schemas/designer.py +0 -38
- openprotein_python-0.16.0/openprotein/schemas/embeddings.py +0 -102
- openprotein_python-0.16.0/openprotein/schemas/features.py +0 -7
- openprotein_python-0.16.0/openprotein/schemas/fold.py +0 -10
- openprotein_python-0.16.0/openprotein/schemas/job.py +0 -134
- openprotein_python-0.16.0/openprotein/schemas/predict.py +0 -82
- openprotein_python-0.16.0/openprotein/schemas/predictor.py +0 -96
- openprotein_python-0.16.0/openprotein/schemas/prompt.py +0 -28
- openprotein_python-0.16.0/openprotein/schemas/svd.py +0 -31
- openprotein_python-0.16.0/openprotein/schemas/train.py +0 -34
- openprotein_python-0.16.0/openprotein/schemas/umap.py +0 -35
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/.gitignore +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/LICENSE.txt +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/README.md +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/_version.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/align/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/align/future.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/auth_store.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/base.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/chains.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/clustering/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/clustering/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/clustering/clustering.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/clustering/models.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/clustering/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/common/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/common/features.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/common/model_metadata.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/common/reduction.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/common/residue_contants.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/config.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/csv.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/data/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/data/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/data/assaydataset.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/data/data.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/data/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/design/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/design/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/design/design.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/design/future.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/design/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/ablang.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/embeddings.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/esm.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/future.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/models.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/openprotein.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/poet.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/poet2.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/embeddings/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/errors.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fasta.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/alphafold2.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/boltz.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/common.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/complex.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/esmfold.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/esmfold2.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/fold.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/future.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/minifold.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/models.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/protenix.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/rosettafold3.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/fold/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/jobs/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/jobs/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/jobs/futures.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/jobs/jobs.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/jobs/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/base.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/foundation/boltzgen.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/foundation/boltzgen_schema.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/foundation/esmif1.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/foundation/proteinmpnn.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/foundation/rfdiffusion.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/foundation/solublempnn.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/models.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/models/structure_generation.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/molecules/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/molecules/structure.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/molecules/template.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/predictor/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/predictor/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/predictor/models.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/predictor/prediction.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/predictor/predictor.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/predictor/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/predictor/validate.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/prompt/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/prompt/models.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/prompt/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/protein.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/scaffolds.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/svd/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/svd/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/svd/models.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/svd/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/svd/svd.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/umap/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/umap/api.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/umap/models.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/umap/schemas.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/umap/umap.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/utils/__init__.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/utils/chain_id.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/utils/cif.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/utils/numpy.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/utils/sequence.py +0 -0
- {openprotein_python-0.16.0 → openprotein_python-0.17.0}/openprotein/utils/uuid.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: openprotein-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.17.0
|
|
4
4
|
Summary: OpenProtein Python interface.
|
|
5
5
|
Author-email: Mark Gee <markgee@ne47.bio>, "Timothy Truong Jr." <ttruong@ne47.bio>, Tristan Bepler <tbepler@ne47.bio>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,14 +8,14 @@ License-File: LICENSE.txt
|
|
|
8
8
|
Classifier: Development Status :: 4 - Beta
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Requires-Python: <3.15,>=3.10
|
|
11
|
-
Requires-Dist: filelock
|
|
11
|
+
Requires-Dist: filelock>=3.13
|
|
12
12
|
Requires-Dist: gemmi<0.8,>=0.6.0
|
|
13
|
-
Requires-Dist: numpy
|
|
14
|
-
Requires-Dist: pandas
|
|
15
|
-
Requires-Dist: pydantic
|
|
16
|
-
Requires-Dist: requests
|
|
17
|
-
Requires-Dist: tomli
|
|
18
|
-
Requires-Dist: tqdm
|
|
13
|
+
Requires-Dist: numpy>=1.9
|
|
14
|
+
Requires-Dist: pandas>=2.2.2
|
|
15
|
+
Requires-Dist: pydantic>=2.5
|
|
16
|
+
Requires-Dist: requests>=2.32.3
|
|
17
|
+
Requires-Dist: tomli>=2.3.0
|
|
18
|
+
Requires-Dist: tqdm>=4.66.4
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
|
|
21
21
|
[](https://pypi.org/project/openprotein-python/)
|
|
@@ -11,7 +11,7 @@ from openprotein.molecules import Protein
|
|
|
11
11
|
|
|
12
12
|
from . import api
|
|
13
13
|
from .msa import MSAFuture
|
|
14
|
-
from .schemas import AbNumberScheme, AlignType
|
|
14
|
+
from .schemas import AbNumberScheme, AlignType, UnnumberedPolicy
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class AlignAPI:
|
|
@@ -190,6 +190,7 @@ class AlignAPI:
|
|
|
190
190
|
names: Sequence[str] | None = None,
|
|
191
191
|
scheme: AbNumberScheme = AbNumberScheme.CHOTHIA,
|
|
192
192
|
drop_minority_chains: bool = False,
|
|
193
|
+
unnumbered_policy: UnnumberedPolicy = UnnumberedPolicy.ERROR,
|
|
193
194
|
) -> MSAFuture:
|
|
194
195
|
"""
|
|
195
196
|
Align antibody sequences using `AbNumber`.
|
|
@@ -210,6 +211,11 @@ class AlignAPI:
|
|
|
210
211
|
If True, drop sequences belonging to chain types that are in the
|
|
211
212
|
minority (e.g. heavy vs light) so the resulting alignment contains
|
|
212
213
|
only the dominant chain type.
|
|
214
|
+
unnumbered_policy : UnnumberedPolicy, default=UnnumberedPolicy.ERROR
|
|
215
|
+
What to do with residues outside the numbered variable domain --
|
|
216
|
+
a constant/Fc region, an N-terminal tag. ERROR fails the job, DROP
|
|
217
|
+
aligns the numbered residues only, RETAIN keeps them padded against
|
|
218
|
+
the numbered-domain boundary.
|
|
213
219
|
|
|
214
220
|
Returns
|
|
215
221
|
-------
|
|
@@ -241,7 +247,10 @@ class AlignAPI:
|
|
|
241
247
|
content = b"\n".join(lines)
|
|
242
248
|
stream = BytesIO(content)
|
|
243
249
|
return self.abnumber_file(
|
|
244
|
-
stream,
|
|
250
|
+
stream,
|
|
251
|
+
scheme=scheme,
|
|
252
|
+
drop_minority_chains=drop_minority_chains,
|
|
253
|
+
unnumbered_policy=unnumbered_policy,
|
|
245
254
|
)
|
|
246
255
|
|
|
247
256
|
def abnumber_file(
|
|
@@ -249,6 +258,7 @@ class AlignAPI:
|
|
|
249
258
|
file,
|
|
250
259
|
scheme: AbNumberScheme = AbNumberScheme.CHOTHIA,
|
|
251
260
|
drop_minority_chains: bool = False,
|
|
261
|
+
unnumbered_policy: UnnumberedPolicy = UnnumberedPolicy.ERROR,
|
|
252
262
|
) -> MSAFuture:
|
|
253
263
|
"""
|
|
254
264
|
Align antibody sequences using `AbNumber`.
|
|
@@ -267,6 +277,11 @@ class AlignAPI:
|
|
|
267
277
|
If True, drop sequences belonging to chain types that are in the
|
|
268
278
|
minority (e.g. heavy vs light) so the resulting alignment contains
|
|
269
279
|
only the dominant chain type.
|
|
280
|
+
unnumbered_policy : UnnumberedPolicy, default=UnnumberedPolicy.ERROR
|
|
281
|
+
What to do with residues outside the numbered variable domain --
|
|
282
|
+
a constant/Fc region, an N-terminal tag. ERROR fails the job, DROP
|
|
283
|
+
aligns the numbered residues only, RETAIN keeps them padded against
|
|
284
|
+
the numbered-domain boundary.
|
|
270
285
|
|
|
271
286
|
Returns
|
|
272
287
|
-------
|
|
@@ -278,6 +293,7 @@ class AlignAPI:
|
|
|
278
293
|
file,
|
|
279
294
|
scheme=scheme,
|
|
280
295
|
drop_minority_chains=drop_minority_chains,
|
|
296
|
+
unnumbered_policy=unnumbered_policy,
|
|
281
297
|
)
|
|
282
298
|
return MSAFuture.create(session=self.session, job=job)
|
|
283
299
|
|
|
@@ -11,7 +11,12 @@ from openprotein.base import APISession
|
|
|
11
11
|
from openprotein.errors import APIError, InvalidParameterError, MissingParameterError
|
|
12
12
|
from openprotein.jobs import Job
|
|
13
13
|
|
|
14
|
-
from .schemas import
|
|
14
|
+
from .schemas import (
|
|
15
|
+
AbNumberScheme,
|
|
16
|
+
AlignType,
|
|
17
|
+
MSASamplingMethod,
|
|
18
|
+
UnnumberedPolicy,
|
|
19
|
+
)
|
|
15
20
|
|
|
16
21
|
|
|
17
22
|
def get_align_job_inputs(
|
|
@@ -270,6 +275,7 @@ def abnumber_post(
|
|
|
270
275
|
sequence_file: BinaryIO,
|
|
271
276
|
scheme: AbNumberScheme | str = AbNumberScheme.IMGT,
|
|
272
277
|
drop_minority_chains: bool = False,
|
|
278
|
+
unnumbered_policy: UnnumberedPolicy | str = UnnumberedPolicy.ERROR,
|
|
273
279
|
) -> Job:
|
|
274
280
|
"""
|
|
275
281
|
Align antibody sequences using AbNumber.
|
|
@@ -289,6 +295,9 @@ def abnumber_post(
|
|
|
289
295
|
If True, drop sequences belonging to chain types that are in the
|
|
290
296
|
minority (e.g. heavy vs light) so the resulting alignment contains
|
|
291
297
|
only the dominant chain type. Default is False.
|
|
298
|
+
unnumbered_policy : UnnumberedPolicy, optional
|
|
299
|
+
What to do with residues outside the numbered variable domain.
|
|
300
|
+
Default is ERROR, which fails the job.
|
|
292
301
|
|
|
293
302
|
Returns
|
|
294
303
|
-------
|
|
@@ -300,18 +309,28 @@ def abnumber_post(
|
|
|
300
309
|
if isinstance(scheme, str):
|
|
301
310
|
if scheme not in {value.value for value in AbNumberScheme}:
|
|
302
311
|
raise InvalidParameterError(f"Antibody numbering {scheme} not recognized")
|
|
312
|
+
if isinstance(unnumbered_policy, str):
|
|
313
|
+
if unnumbered_policy not in {value.value for value in UnnumberedPolicy}:
|
|
314
|
+
raise InvalidParameterError(
|
|
315
|
+
f"Unnumbered residue policy {unnumbered_policy} not recognized"
|
|
316
|
+
)
|
|
303
317
|
|
|
304
318
|
files = {"file": sequence_file}
|
|
305
319
|
params = {
|
|
306
320
|
"scheme": scheme if isinstance(scheme, str) else scheme.value,
|
|
307
321
|
"drop_minority_chains": drop_minority_chains,
|
|
322
|
+
"unnumbered_policy": (
|
|
323
|
+
unnumbered_policy
|
|
324
|
+
if isinstance(unnumbered_policy, str)
|
|
325
|
+
else unnumbered_policy.value
|
|
326
|
+
),
|
|
308
327
|
}
|
|
309
328
|
|
|
310
329
|
response = session.post(endpoint, files=files, params=params)
|
|
311
330
|
return Job.model_validate(response.json())
|
|
312
331
|
|
|
313
332
|
|
|
314
|
-
def antibody_schema_get(session: APISession, job_id: str):
|
|
333
|
+
def antibody_schema_get(session: APISession, job_id: str) -> dict:
|
|
315
334
|
"""
|
|
316
335
|
Retrieve the antibody numbering for an AbNumber job.
|
|
317
336
|
|
|
@@ -322,16 +341,16 @@ def antibody_schema_get(session: APISession, job_id: str):
|
|
|
322
341
|
job_id : str
|
|
323
342
|
The job identifier.
|
|
324
343
|
|
|
325
|
-
Raises
|
|
326
|
-
------
|
|
327
|
-
NotImplementedError
|
|
328
|
-
This function is not yet implemented.
|
|
329
|
-
|
|
330
344
|
Returns
|
|
331
345
|
-------
|
|
332
|
-
|
|
346
|
+
dict
|
|
347
|
+
The job's extras: a ``chains`` entry per chain position carrying the
|
|
348
|
+
numbering and CDR regions, and a ``warnings`` list.
|
|
333
349
|
"""
|
|
334
|
-
|
|
350
|
+
endpoint = "v1/align/antibody_schema"
|
|
351
|
+
|
|
352
|
+
response = session.get(endpoint, params={"job_id": job_id})
|
|
353
|
+
return response.json()
|
|
335
354
|
|
|
336
355
|
|
|
337
356
|
def prompt_post(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""MSA results represented as a future."""
|
|
2
2
|
|
|
3
|
+
import warnings
|
|
3
4
|
from typing import Iterator
|
|
4
5
|
|
|
5
6
|
from openprotein import config
|
|
@@ -12,6 +13,7 @@ from .future import AlignFuture
|
|
|
12
13
|
from .schemas import (
|
|
13
14
|
AbNumberJob,
|
|
14
15
|
ClustalOJob,
|
|
16
|
+
JobWarning,
|
|
15
17
|
MafftJob,
|
|
16
18
|
MSAJob,
|
|
17
19
|
MSASamplingMethod,
|
|
@@ -44,6 +46,7 @@ class MSAFuture(AlignFuture, Future):
|
|
|
44
46
|
super().__init__(session, job)
|
|
45
47
|
self.page_size = page_size
|
|
46
48
|
self.msa_id = self.job.job_id
|
|
49
|
+
self._warned = False
|
|
47
50
|
|
|
48
51
|
def _get(self, verbose: bool = False) -> Iterator[tuple[str, str]]:
|
|
49
52
|
"""
|
|
@@ -59,8 +62,54 @@ class MSAFuture(AlignFuture, Future):
|
|
|
59
62
|
Iterator[tuple[str, str]]
|
|
60
63
|
An iterator over names and sequences of the MSA data.
|
|
61
64
|
"""
|
|
65
|
+
self._warn_once()
|
|
62
66
|
return api.get_msa(session=self.session, job_id=self.job.job_id)
|
|
63
67
|
|
|
68
|
+
def _warn_once(self) -> None:
|
|
69
|
+
"""Surface what the job reported about its own output, once."""
|
|
70
|
+
if self._warned or not isinstance(self.job, AbNumberJob):
|
|
71
|
+
return
|
|
72
|
+
self._warned = True
|
|
73
|
+
try:
|
|
74
|
+
job_warnings = self.get_warnings()
|
|
75
|
+
except Exception:
|
|
76
|
+
# reading the results cannot depend on the schema endpoint answering
|
|
77
|
+
return
|
|
78
|
+
for job_warning in job_warnings:
|
|
79
|
+
warnings.warn(f"{job_warning.code}: {job_warning.message}")
|
|
80
|
+
|
|
81
|
+
def get_antibody_schema(self) -> dict:
|
|
82
|
+
"""
|
|
83
|
+
Retrieve the antibody numbering for an AbNumber job.
|
|
84
|
+
|
|
85
|
+
Returns
|
|
86
|
+
-------
|
|
87
|
+
dict
|
|
88
|
+
One ``chains`` entry per chain position, carrying that position's
|
|
89
|
+
numbering, CDR regions and chain type, plus a ``warnings`` list.
|
|
90
|
+
|
|
91
|
+
Raises
|
|
92
|
+
------
|
|
93
|
+
HTTPError
|
|
94
|
+
If the job did not use AbNumber.
|
|
95
|
+
"""
|
|
96
|
+
return api.antibody_schema_get(session=self.session, job_id=self.job.job_id)
|
|
97
|
+
|
|
98
|
+
def get_warnings(self) -> list[JobWarning]:
|
|
99
|
+
"""
|
|
100
|
+
Retrieve what the job reported about its own output.
|
|
101
|
+
|
|
102
|
+
A job that succeeds can still have changed the data, e.g. by dropping
|
|
103
|
+
residues AbNumber could not number.
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
list[JobWarning]
|
|
108
|
+
Empty if the job had nothing to report.
|
|
109
|
+
"""
|
|
110
|
+
schema = self.get_antibody_schema()
|
|
111
|
+
return [JobWarning.model_validate(w) for w in schema.get("warnings", [])]
|
|
112
|
+
|
|
64
113
|
def sample_prompt(
|
|
65
114
|
self,
|
|
66
115
|
num_sequences: int | None = None,
|
|
@@ -180,3 +180,47 @@ class AbNumberScheme(str, Enum):
|
|
|
180
180
|
CHOTHIA = "chothia"
|
|
181
181
|
KABAT = "kabat"
|
|
182
182
|
AHO = "aho"
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class UnnumberedPolicy(str, Enum):
|
|
186
|
+
"""
|
|
187
|
+
What to do with residues the numbering scheme gives no antibody position.
|
|
188
|
+
|
|
189
|
+
ANARCI numbers one variable domain per sequence. Residues outside it -- a
|
|
190
|
+
constant/Fc region, an N-terminal tag -- have no antibody position and
|
|
191
|
+
cannot share the numbering coordinate system.
|
|
192
|
+
|
|
193
|
+
Attributes
|
|
194
|
+
----------
|
|
195
|
+
ERROR : str
|
|
196
|
+
Fail the job if any sequence carries unnumbered residues.
|
|
197
|
+
DROP : str
|
|
198
|
+
Align the numbered residues only, discarding the rest.
|
|
199
|
+
RETAIN : str
|
|
200
|
+
Keep the unnumbered residues, padded against the numbered-domain
|
|
201
|
+
boundary. They are preserved, not aligned to each other.
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
ERROR = "error"
|
|
205
|
+
DROP = "drop"
|
|
206
|
+
RETAIN = "retain"
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
class JobWarning(BaseModel):
|
|
210
|
+
"""
|
|
211
|
+
Something a job reports about its own output while still succeeding.
|
|
212
|
+
|
|
213
|
+
Attributes
|
|
214
|
+
----------
|
|
215
|
+
code : str
|
|
216
|
+
Machine-readable identifier, e.g. ``UNNUMBERED_RESIDUES_DROPPED``.
|
|
217
|
+
message : str
|
|
218
|
+
Human-readable description.
|
|
219
|
+
metadata : dict or None
|
|
220
|
+
Code-specific detail. For the unnumbered-residue codes this carries a
|
|
221
|
+
``chains`` list, one entry per affected chain position.
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
code: str
|
|
225
|
+
message: str
|
|
226
|
+
metadata: dict | None = None
|
|
@@ -109,6 +109,8 @@ class DNA(_BasicSerde):
|
|
|
109
109
|
def copy(self) -> "DNA":
|
|
110
110
|
return replace(self)
|
|
111
111
|
|
|
112
|
+
# TODO - support (&) and (|) operators for combining into Complexes (like Protein)
|
|
113
|
+
|
|
112
114
|
@staticmethod
|
|
113
115
|
def _from_structure_block(
|
|
114
116
|
structure_block: _cif_utils.StructureCIFBlock, chain_id: str, model_idx: int
|
|
@@ -159,6 +161,8 @@ class RNA(_BasicSerde):
|
|
|
159
161
|
def copy(self) -> "RNA":
|
|
160
162
|
return replace(self)
|
|
161
163
|
|
|
164
|
+
# TODO - support (&) and (|) operators for combining into Complexes (like Protein)
|
|
165
|
+
|
|
162
166
|
@staticmethod
|
|
163
167
|
def _from_structure_block(
|
|
164
168
|
structure_block: _cif_utils.StructureCIFBlock, chain_id: str, model_idx: int
|
|
@@ -210,6 +214,8 @@ class Ligand(_BasicSerde):
|
|
|
210
214
|
|
|
211
215
|
def copy(self) -> "Ligand":
|
|
212
216
|
return replace(self)
|
|
217
|
+
|
|
218
|
+
# TODO - support (&) and (|) operators for combining into Complexes (like Protein)
|
|
213
219
|
|
|
214
220
|
@staticmethod
|
|
215
221
|
def _from_structure_block(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import gzip
|
|
2
2
|
import operator
|
|
3
|
-
from collections.abc import Mapping, Sequence
|
|
3
|
+
from collections.abc import Mapping, Sequence, MutableMapping
|
|
4
4
|
from functools import reduce
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from types import MappingProxyType
|
|
@@ -20,8 +20,14 @@ if TYPE_CHECKING:
|
|
|
20
20
|
from .template import Template
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
Chain = Protein | DNA | RNA | Ligand | str
|
|
24
|
+
|
|
25
|
+
def _is_chain_type(chain):
|
|
26
|
+
return isinstance(chain, Chain)
|
|
27
|
+
|
|
28
|
+
|
|
23
29
|
# TODO: deserialization note about plddt parsed per residue
|
|
24
|
-
class Complex:
|
|
30
|
+
class Complex(MutableMapping):
|
|
25
31
|
def __init__(
|
|
26
32
|
self,
|
|
27
33
|
chains: Mapping[str, Protein | DNA | RNA | Ligand] | None = None,
|
|
@@ -33,10 +39,14 @@ class Complex:
|
|
|
33
39
|
if not isinstance(key, str):
|
|
34
40
|
raise TypeError(f"chain id must be str; got {key!r}")
|
|
35
41
|
collected[key] = value
|
|
36
|
-
|
|
42
|
+
# preserve insertion order of the chains by not sorting the dictionary
|
|
43
|
+
# Note that as of python 3.7 dicts preserve insertion order (OrderedDict not needed)
|
|
44
|
+
self._chains = collected
|
|
37
45
|
self._templates: "Sequence[Protein | Complex | Template]" = ()
|
|
38
46
|
self.name = name
|
|
39
47
|
|
|
48
|
+
# --- NAME methods ---
|
|
49
|
+
|
|
40
50
|
@property
|
|
41
51
|
def name(self) -> str | None:
|
|
42
52
|
return self._name
|
|
@@ -52,6 +62,8 @@ class Complex:
|
|
|
52
62
|
self.name = x
|
|
53
63
|
return self
|
|
54
64
|
|
|
65
|
+
# --- TEMPLATE methods ---
|
|
66
|
+
|
|
55
67
|
@property
|
|
56
68
|
def templates(self) -> "Sequence[Protein | Complex | Template]":
|
|
57
69
|
"""A list of templates for guiding the structure prediction of this molecular complex."""
|
|
@@ -70,9 +82,150 @@ class Complex:
|
|
|
70
82
|
self.templates = templates
|
|
71
83
|
return self
|
|
72
84
|
|
|
85
|
+
# --- dict-like methods and other general ops ---
|
|
86
|
+
|
|
87
|
+
def get_chain_ids(self):
|
|
88
|
+
"""Returns the Chain IDs in this Complex"""
|
|
89
|
+
return self._chains.keys()
|
|
90
|
+
|
|
73
91
|
def get_chains(self) -> Mapping[str, Protein | DNA | RNA | Ligand]:
|
|
92
|
+
"""Get all chains as a {chain_id: chain} mapping"""
|
|
74
93
|
return MappingProxyType(self._chains)
|
|
75
94
|
|
|
95
|
+
def get_chain(self, chain_id: str):
|
|
96
|
+
"""Get the chain for this chain_id"""
|
|
97
|
+
return self._chains[chain_id]
|
|
98
|
+
|
|
99
|
+
def set_chain(
|
|
100
|
+
self, chain_id: str, value: Protein | DNA | RNA | Ligand
|
|
101
|
+
) -> "Complex":
|
|
102
|
+
"""Add a new chain to this complex or overwrite an existing one with the same chain_id"""
|
|
103
|
+
self._chains[chain_id] = value
|
|
104
|
+
return self
|
|
105
|
+
|
|
106
|
+
def remove_chain(self, chain_id: str):
|
|
107
|
+
"""Remove a chain from this complex"""
|
|
108
|
+
del self._chains[chain_id]
|
|
109
|
+
|
|
110
|
+
def insert_chain(self, chain: Protein | DNA | RNA | Ligand | str):
|
|
111
|
+
"""Inserts a new chain into this Complex with an auto-generated chain_id. Casts strings into Proteins."""
|
|
112
|
+
assert _is_chain_type(chain)
|
|
113
|
+
id_gen = _chain_id_utils.id_generator(list(self._chains.keys()))
|
|
114
|
+
if isinstance(chain, str):
|
|
115
|
+
chain = Protein.from_expr(chain)
|
|
116
|
+
|
|
117
|
+
chain_id = next(id_gen)
|
|
118
|
+
self.set_chain(chain_id, chain)
|
|
119
|
+
return self
|
|
120
|
+
|
|
121
|
+
def __len__(self):
|
|
122
|
+
"""Returns the number of chains in the complex"""
|
|
123
|
+
return len(self._chains)
|
|
124
|
+
|
|
125
|
+
def __getitem__(self, key):
|
|
126
|
+
"""Retrieve the given chain"""
|
|
127
|
+
return self.get_chain(key)
|
|
128
|
+
|
|
129
|
+
def __setitem__(self, key, value):
|
|
130
|
+
"""Add a chain or overwrite a chain with the given chain_id"""
|
|
131
|
+
self.set_chain(key, value)
|
|
132
|
+
|
|
133
|
+
def __delitem__(self, key):
|
|
134
|
+
"""Remove the given chain from this complex"""
|
|
135
|
+
self.remove_chain(key)
|
|
136
|
+
|
|
137
|
+
def __contains__(self, chain_id):
|
|
138
|
+
return chain_id in self._chains
|
|
139
|
+
|
|
140
|
+
def __eq__(self, other):
|
|
141
|
+
if isinstance(other, Complex):
|
|
142
|
+
if self._chains != other._chains:
|
|
143
|
+
return False
|
|
144
|
+
if self._templates != other._templates:
|
|
145
|
+
return False
|
|
146
|
+
return True
|
|
147
|
+
return False
|
|
148
|
+
|
|
149
|
+
def __iter__(self):
|
|
150
|
+
"""Iterate the chains in this complex"""
|
|
151
|
+
return iter(self._chains)
|
|
152
|
+
|
|
153
|
+
def keys(self):
|
|
154
|
+
return self._chains.keys()
|
|
155
|
+
|
|
156
|
+
def values(self):
|
|
157
|
+
return self._chains.values()
|
|
158
|
+
|
|
159
|
+
def items(self):
|
|
160
|
+
return self._chains.items()
|
|
161
|
+
|
|
162
|
+
def update(self, **kwargs):
|
|
163
|
+
"""Add a collection of chains to this complex"""
|
|
164
|
+
overlapping_chain_ids = []
|
|
165
|
+
for key, value in kwargs.items():
|
|
166
|
+
if not isinstance(key, str):
|
|
167
|
+
raise TypeError(f"chain id must be str; got {key!r}")
|
|
168
|
+
# TODO - assert that chain objects are the right types too
|
|
169
|
+
# assert _is_chain_type(value)
|
|
170
|
+
|
|
171
|
+
# strictly do not allow replacing existing chain_ids
|
|
172
|
+
if key in self._chains:
|
|
173
|
+
overlapping_chain_ids.append(key)
|
|
174
|
+
if len(overlapping_chain_ids) > 0:
|
|
175
|
+
raise ValueError(
|
|
176
|
+
f"Trying to combine two sets of chains with overlapping chain ids: {overlapping_chain_ids}"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
# update chains
|
|
180
|
+
self._chains.update(**kwargs)
|
|
181
|
+
|
|
182
|
+
def clear(self):
|
|
183
|
+
"""Remove all chains and templates from this complex"""
|
|
184
|
+
self._chains.clear()
|
|
185
|
+
# also deletes the templates if you clear this complex
|
|
186
|
+
self._templates = ()
|
|
187
|
+
|
|
188
|
+
def copy(self) -> "Complex":
|
|
189
|
+
"""Copy this Complex. Returns a deep copy of the contained Chains"""
|
|
190
|
+
# TODO - should this deepcopy the chain objects themselves?
|
|
191
|
+
chains_copy: dict[str, Protein | DNA | RNA | Ligand] = {
|
|
192
|
+
chain_id: chain.copy() for chain_id, chain in self._chains.items()
|
|
193
|
+
}
|
|
194
|
+
return Complex(chains=chains_copy, name=self._name)
|
|
195
|
+
|
|
196
|
+
# --- other dictionary operators like set combine ---
|
|
197
|
+
|
|
198
|
+
# python actually uses the or operator for dict combine
|
|
199
|
+
def __ior__(self, other) -> "Complex":
|
|
200
|
+
"""In-place update to this Complex using |= """
|
|
201
|
+
|
|
202
|
+
# other is either a single Chain or a Complex
|
|
203
|
+
# if single chain, we insert it with an autogenerated ID
|
|
204
|
+
# if complex, we add all of its chains
|
|
205
|
+
if _is_chain_type(other):
|
|
206
|
+
self.insert_chain(other)
|
|
207
|
+
else:
|
|
208
|
+
self.update(**other)
|
|
209
|
+
return self
|
|
210
|
+
|
|
211
|
+
def __or__(self, right) -> "Complex":
|
|
212
|
+
"""Create a combined copy: self | right"""
|
|
213
|
+
a = self.copy()
|
|
214
|
+
a |= right # handles right being Complex or single Chain
|
|
215
|
+
return a
|
|
216
|
+
|
|
217
|
+
def __ror__(self, left) -> "Complex":
|
|
218
|
+
if isinstance(left, str):
|
|
219
|
+
left = Protein.from_expr(expr=left)
|
|
220
|
+
return left | self
|
|
221
|
+
|
|
222
|
+
# NOTE - python uses the or operator (|) for set and dict unions, but we also
|
|
223
|
+
# support this using the and operator (&)
|
|
224
|
+
__rand__ = __ror__
|
|
225
|
+
__and__ = __or__
|
|
226
|
+
|
|
227
|
+
# -- Chain-type specific methods ---
|
|
228
|
+
|
|
76
229
|
def get_proteins(self) -> Mapping[str, Protein]:
|
|
77
230
|
return MappingProxyType(
|
|
78
231
|
{k: v for k, v in self._chains.items() if isinstance(v, Protein)}
|
|
@@ -113,41 +266,7 @@ class Complex:
|
|
|
113
266
|
assert isinstance(chain, Ligand)
|
|
114
267
|
return chain
|
|
115
268
|
|
|
116
|
-
|
|
117
|
-
self, chain_id: str, value: Protein | DNA | RNA | Ligand
|
|
118
|
-
) -> "Complex":
|
|
119
|
-
self._chains[chain_id] = value
|
|
120
|
-
self._chains = dict(sorted(self._chains.items()))
|
|
121
|
-
return self
|
|
122
|
-
|
|
123
|
-
def __rand__(self, left: "Complex | Protein | str") -> "Complex":
|
|
124
|
-
if isinstance(left, str):
|
|
125
|
-
left = Protein.from_expr(expr=left)
|
|
126
|
-
return left & self
|
|
127
|
-
|
|
128
|
-
def __and__(self, right: "Complex | Protein | str") -> "Complex":
|
|
129
|
-
"""Combine multiple objects into a single Complex."""
|
|
130
|
-
|
|
131
|
-
assert (
|
|
132
|
-
isinstance(right, Complex)
|
|
133
|
-
or isinstance(right, Protein)
|
|
134
|
-
or isinstance(right, str)
|
|
135
|
-
)
|
|
136
|
-
id_gen = _chain_id_utils.id_generator(list(self._chains.keys()))
|
|
137
|
-
if isinstance(right, str):
|
|
138
|
-
right = Protein.from_expr(right)
|
|
139
|
-
if isinstance(right, Protein):
|
|
140
|
-
self.set_chain(chain_id=next(id_gen), value=right)
|
|
141
|
-
else:
|
|
142
|
-
if (
|
|
143
|
-
len(overlapping_chain_ids := self._chains.keys() & right._chains.keys())
|
|
144
|
-
> 0
|
|
145
|
-
):
|
|
146
|
-
raise ValueError(
|
|
147
|
-
f"Trying to combine two sets of chains with overlapping chain ids: {overlapping_chain_ids}"
|
|
148
|
-
)
|
|
149
|
-
self._chains = dict(sorted((self._chains | right._chains).items()))
|
|
150
|
-
return self
|
|
269
|
+
# --- structure comparison and geometry methods ---
|
|
151
270
|
|
|
152
271
|
@overload
|
|
153
272
|
def rmsd(
|
|
@@ -208,6 +327,8 @@ class Complex:
|
|
|
208
327
|
_, R, t = tgt.rmsd(self, backbone_only=backbone_only, return_transform=True)
|
|
209
328
|
return self.transform(R=R, t=t)
|
|
210
329
|
|
|
330
|
+
# --- read and write PDB and CIF files and strings ---
|
|
331
|
+
|
|
211
332
|
def to_string(self, format: Literal["cif", "pdb"] = "cif") -> str:
|
|
212
333
|
"""
|
|
213
334
|
Serialize this Complex to a string. Note that format="pdb" may not serialize all
|
|
@@ -268,12 +389,6 @@ class Complex:
|
|
|
268
389
|
verbose=verbose,
|
|
269
390
|
)
|
|
270
391
|
|
|
271
|
-
def copy(self) -> "Complex":
|
|
272
|
-
chains_copy: dict[str, Protein | DNA | RNA | Ligand] = {
|
|
273
|
-
chain_id: chain.copy() for chain_id, chain in self._chains.items()
|
|
274
|
-
}
|
|
275
|
-
return Complex(chains=chains_copy, name=self._name)
|
|
276
|
-
|
|
277
392
|
def _assert_valid_templates(self):
|
|
278
393
|
from .template import Template
|
|
279
394
|
|
|
@@ -216,6 +216,10 @@ class Protein:
|
|
|
216
216
|
}
|
|
217
217
|
return new
|
|
218
218
|
|
|
219
|
+
# --- complex set operations to support & and | operators between proteins and Complexes ---
|
|
220
|
+
# NOTE - in python, the or operator (|) is used to combine sets and dicts, but we also support
|
|
221
|
+
# the and operator (&) to do the same thing
|
|
222
|
+
|
|
219
223
|
def __rand__(self, left: "Complex | Protein | str") -> "Complex":
|
|
220
224
|
if isinstance(left, str):
|
|
221
225
|
left = self.from_expr(expr=left)
|
|
@@ -235,7 +239,15 @@ class Protein:
|
|
|
235
239
|
if isinstance(right, Protein):
|
|
236
240
|
id_gen = _chain_id_utils.id_generator()
|
|
237
241
|
return Complex({next(id_gen): self, next(id_gen): right})
|
|
238
|
-
|
|
242
|
+
# NOTE - this inserts this protein at the _end_ of the Complex even though the operation
|
|
243
|
+
# was Protein & Complex
|
|
244
|
+
return right & self
|
|
245
|
+
|
|
246
|
+
# map the (|) or operator to the and operators
|
|
247
|
+
__ror__ = __rand__
|
|
248
|
+
__or__ = __and__
|
|
249
|
+
|
|
250
|
+
# --- end set operator definitions ---
|
|
239
251
|
|
|
240
252
|
def at(self, positions: Sequence[int] | npt.NDArray[np.integer]) -> "Protein":
|
|
241
253
|
"""
|