biotrainer-core 2.0.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.
Files changed (39) hide show
  1. biotrainer_core-2.0.0/.gitignore +79 -0
  2. biotrainer_core-2.0.0/LICENSE +9 -0
  3. biotrainer_core-2.0.0/PKG-INFO +68 -0
  4. biotrainer_core-2.0.0/README.md +53 -0
  5. biotrainer_core-2.0.0/biotrainer_core/__init__.py +7 -0
  6. biotrainer_core-2.0.0/biotrainer_core/data_classes/__init__.py +16 -0
  7. biotrainer_core-2.0.0/biotrainer_core/data_classes/autoeval/__init__.py +17 -0
  8. biotrainer_core-2.0.0/biotrainer_core/data_classes/autoeval/autoeval_flip_datasets.py +61 -0
  9. biotrainer_core-2.0.0/biotrainer_core/data_classes/autoeval/autoeval_mode.py +8 -0
  10. biotrainer_core-2.0.0/biotrainer_core/data_classes/autoeval/autoeval_pbc_datasets.py +44 -0
  11. biotrainer_core-2.0.0/biotrainer_core/data_classes/autoeval/autoeval_progress.py +11 -0
  12. biotrainer_core-2.0.0/biotrainer_core/data_classes/autoeval/autoeval_report.py +618 -0
  13. biotrainer_core-2.0.0/biotrainer_core/data_classes/autoeval/autoeval_supervised_dataset.py +13 -0
  14. biotrainer_core-2.0.0/biotrainer_core/data_classes/autoeval/autoeval_task.py +30 -0
  15. biotrainer_core-2.0.0/biotrainer_core/data_classes/bioengineer_data_classes.py +279 -0
  16. biotrainer_core-2.0.0/biotrainer_core/data_classes/biotrainer_model_result.py +88 -0
  17. biotrainer_core-2.0.0/biotrainer_core/data_classes/biotrainer_prediction.py +115 -0
  18. biotrainer_core-2.0.0/biotrainer_core/data_classes/contact.py +62 -0
  19. biotrainer_core-2.0.0/biotrainer_core/data_classes/embedding_stats.py +36 -0
  20. biotrainer_core-2.0.0/biotrainer_core/data_classes/metrics.py +58 -0
  21. biotrainer_core-2.0.0/biotrainer_core/data_classes/protocol.py +55 -0
  22. biotrainer_core-2.0.0/biotrainer_core/data_classes/sequence_data.py +297 -0
  23. biotrainer_core-2.0.0/biotrainer_core/functions/__init__.py +7 -0
  24. biotrainer_core-2.0.0/biotrainer_core/functions/bootstrapping.py +59 -0
  25. biotrainer_core-2.0.0/biotrainer_core/functions/hashing.py +94 -0
  26. biotrainer_core-2.0.0/biotrainer_core/functions/ranking.py +393 -0
  27. biotrainer_core-2.0.0/biotrainer_core/functions/seeding.py +22 -0
  28. biotrainer_core-2.0.0/biotrainer_core/h5_files/__init__.py +8 -0
  29. biotrainer_core-2.0.0/biotrainer_core/h5_files/emb_db_dto.py +90 -0
  30. biotrainer_core-2.0.0/biotrainer_core/h5_files/h5_db.py +100 -0
  31. biotrainer_core-2.0.0/biotrainer_core/h5_files/h5_handling.py +82 -0
  32. biotrainer_core-2.0.0/biotrainer_core/input_files/__init__.py +14 -0
  33. biotrainer_core-2.0.0/biotrainer_core/input_files/csv.py +33 -0
  34. biotrainer_core-2.0.0/biotrainer_core/input_files/fasta.py +99 -0
  35. biotrainer_core-2.0.0/biotrainer_core/input_files/npy.py +30 -0
  36. biotrainer_core-2.0.0/biotrainer_core/input_files/utils.py +74 -0
  37. biotrainer_core-2.0.0/biotrainer_core/utils/__init__.py +3 -0
  38. biotrainer_core-2.0.0/biotrainer_core/utils/constants.py +22 -0
  39. biotrainer_core-2.0.0/pyproject.toml +33 -0
@@ -0,0 +1,79 @@
1
+ # Temporary and binary files
2
+ *~
3
+ *.py[cod]
4
+ *.so
5
+ *.cfg
6
+ !setup.cfg
7
+ *.orig
8
+ *.log
9
+ *.pot
10
+ __pycache__/*
11
+ webcrawling/__pycache__/*
12
+ .cache/*
13
+ .*.swp
14
+ */.ipynb_checkpoints/*
15
+ .ipynb_checkpoints/
16
+ *.pyc
17
+ /poetry.lock
18
+ uv.lock
19
+
20
+
21
+ # Project files
22
+ .ropeproject
23
+ .project
24
+ .pydevproject
25
+ .settings
26
+ .idea
27
+
28
+ # Package files
29
+ *.egg
30
+ *.eggs/
31
+ .installed.cfg
32
+ *.egg-info
33
+ node_modules/
34
+ package-lock.json
35
+
36
+ # Unittest and coverage
37
+ htmlcov/*
38
+ .coverage
39
+ .tox
40
+ junit.xml
41
+ coverage.xml
42
+
43
+ # Build and docs folder/files
44
+ biotrainer-core/build/*
45
+ biotrainer-core/dist/*
46
+ build/*
47
+ dist/*
48
+ sdist/*
49
+ docs/api/*
50
+ docs/_build/*
51
+ docs/build/*
52
+ cover/*
53
+ MANIFEST
54
+ .mypy_cache/*
55
+
56
+ # Unused code
57
+ backup/*
58
+
59
+ # macOS Desktop Services Store
60
+ .DS_Store
61
+
62
+ # plots
63
+ *.png
64
+
65
+ venv
66
+
67
+ !.keep
68
+
69
+ private/
70
+
71
+ # tensorboard output
72
+ runs/
73
+
74
+ # large files
75
+ *.h5
76
+
77
+ # local files
78
+ .venv/
79
+ rough_work/
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2026 biocentral (Sebastian Franz)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,68 @@
1
+ Metadata-Version: 2.4
2
+ Name: biotrainer-core
3
+ Version: 2.0.0
4
+ Summary: Core data classes and I/O utilities for biotrainer.
5
+ Author-email: Sebastian Franz <sebastian.franz@tum.de>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: <3.14,>=3.11
9
+ Requires-Dist: h5py<4.0.0,>=3.15.0
10
+ Requires-Dist: numpy<2.5.0,>=2.4.1
11
+ Requires-Dist: pandas>=2.3.3
12
+ Requires-Dist: pydantic>=2.12.3
13
+ Requires-Dist: ruamel-yaml<0.18.0,>=0.17.40
14
+ Description-Content-Type: text/markdown
15
+
16
+ # biotrainer-core
17
+
18
+ A lightweight Python package providing shared data classes, I/O utilities, and helper functions for protein-related
19
+ projects.
20
+
21
+ ## Purpose
22
+
23
+ `biotrainer-core` is designed as a minimal, dependency-light foundation that can be reused across multiple protein ML
24
+ projects (e.g. [biotrainer](https://github.com/sacdallago/biotrainer)) without pulling in heavy frameworks like PyTorch
25
+ or Transformers.
26
+
27
+ ## Features
28
+
29
+ ### Data Classes
30
+
31
+ Pydantic-based data models shared across protein ML workflows:
32
+
33
+ - **Sequence data** — representations for protein sequences and their metadata
34
+ - **Protocols** — supported task types (residue-level, sequence-level, contact prediction, …)
35
+ - **Metrics** — structured containers for evaluation metrics
36
+ - **Model results & predictions** — standardised output formats for biotrainer models
37
+ - **Embedding statistics** — summary statistics over embedding spaces
38
+ - **AutoEval** — data classes for automated evaluation tasks, reports, and benchmark datasets (FLIP, PBC)
39
+
40
+ ### H5 File Handling
41
+
42
+ Utilities for reading and writing HDF5 files used to store protein embeddings:
43
+
44
+ - `H5Database` — high-level interface for embedding databases
45
+ - Low-level helpers for chunked I/O and dataset management
46
+
47
+ ### Functions
48
+
49
+ Pure utility functions with no side effects:
50
+
51
+ - **Hashing** — deterministic sequence hashing
52
+ - **Seeding** — reproducible random seed management
53
+ - **Ranking** — ranking helpers for evaluation
54
+ - **Bootstrapping** — confidence interval estimation via bootstrapping
55
+
56
+ ### Input Files
57
+
58
+ - **FASTA parsing** — read and validate FASTA files into typed sequence objects
59
+
60
+ ## Installation
61
+
62
+ ```bash
63
+ pip install biotrainer-core
64
+ ```
65
+
66
+ ## License
67
+
68
+ *MIT* — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,53 @@
1
+ # biotrainer-core
2
+
3
+ A lightweight Python package providing shared data classes, I/O utilities, and helper functions for protein-related
4
+ projects.
5
+
6
+ ## Purpose
7
+
8
+ `biotrainer-core` is designed as a minimal, dependency-light foundation that can be reused across multiple protein ML
9
+ projects (e.g. [biotrainer](https://github.com/sacdallago/biotrainer)) without pulling in heavy frameworks like PyTorch
10
+ or Transformers.
11
+
12
+ ## Features
13
+
14
+ ### Data Classes
15
+
16
+ Pydantic-based data models shared across protein ML workflows:
17
+
18
+ - **Sequence data** — representations for protein sequences and their metadata
19
+ - **Protocols** — supported task types (residue-level, sequence-level, contact prediction, …)
20
+ - **Metrics** — structured containers for evaluation metrics
21
+ - **Model results & predictions** — standardised output formats for biotrainer models
22
+ - **Embedding statistics** — summary statistics over embedding spaces
23
+ - **AutoEval** — data classes for automated evaluation tasks, reports, and benchmark datasets (FLIP, PBC)
24
+
25
+ ### H5 File Handling
26
+
27
+ Utilities for reading and writing HDF5 files used to store protein embeddings:
28
+
29
+ - `H5Database` — high-level interface for embedding databases
30
+ - Low-level helpers for chunked I/O and dataset management
31
+
32
+ ### Functions
33
+
34
+ Pure utility functions with no side effects:
35
+
36
+ - **Hashing** — deterministic sequence hashing
37
+ - **Seeding** — reproducible random seed management
38
+ - **Ranking** — ranking helpers for evaluation
39
+ - **Bootstrapping** — confidence interval estimation via bootstrapping
40
+
41
+ ### Input Files
42
+
43
+ - **FASTA parsing** — read and validate FASTA files into typed sequence objects
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install biotrainer-core
49
+ ```
50
+
51
+ ## License
52
+
53
+ *MIT* — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,7 @@
1
+ import biotrainer_core.utils
2
+ import biotrainer_core.functions
3
+ import biotrainer_core.data_classes
4
+ import biotrainer_core.h5_files
5
+ import biotrainer_core.input_files
6
+
7
+ __all__ = ["utils", "functions", "data_classes", "h5_files", "input_files"]
@@ -0,0 +1,16 @@
1
+ from .protocol import Protocol
2
+ from .sequence_data import SequenceData
3
+ from .embedding_stats import EmbeddingStats
4
+ from .biotrainer_model_result import BiotrainerModelResult, DerivedValues, TrainingResult, TestResult, \
5
+ BiotrainerModelUpdate
6
+ from .biotrainer_prediction import BiotrainerPrediction, BiotrainerInferenceResult
7
+ from .metrics import EpochMetrics, MetricEstimate, BootstrappedMetric
8
+ from .bioengineer_data_classes import ZeroShotMethod, Mutation, SingleMutationScore, VariantScore, Variant, \
9
+ RankingResult, AggregatedRankingResult
10
+ from .contact import ContactDatasetResult, ContactSingleProteinResult
11
+
12
+ __all__ = ["BiotrainerModelResult", "BiotrainerPrediction", "Protocol", "EmbeddingStats",
13
+ "EpochMetrics", "MetricEstimate", "BootstrappedMetric", "SequenceData", "TestResult", "TrainingResult",
14
+ "DerivedValues", "BiotrainerModelUpdate", "BiotrainerInferenceResult",
15
+ "ZeroShotMethod", "Mutation", "SingleMutationScore", "VariantScore", "Variant", "RankingResult",
16
+ "AggregatedRankingResult", "ContactDatasetResult", "ContactSingleProteinResult"]
@@ -0,0 +1,17 @@
1
+ from .autoeval_flip_datasets import all_flip_datasets, FLIPDatasetName
2
+ from .autoeval_pbc_datasets import all_pbc_supervised_datasets, PBCSupervisedDatasetName
3
+ from .autoeval_progress import AutoEvalProgress
4
+ from .autoeval_report import (AutoEvalReport, SupervisedFrameworkReport, ContactFrameworkReport,
5
+ ZeroShotFrameworkReport,
6
+ ZeroShotCachedResults, ZeroShotContactCachedResults, FrameworkReport)
7
+ from .autoeval_supervised_dataset import AutoEvalSupervisedDataset
8
+ from .autoeval_task import AutoEvalTask
9
+ from .autoeval_mode import AutoEvalMode
10
+
11
+ __all__ = [
12
+ "AutoEvalProgress", "AutoEvalReport", "SupervisedFrameworkReport", "ContactFrameworkReport",
13
+ "ZeroShotFrameworkReport",
14
+ "ZeroShotCachedResults", "AutoEvalSupervisedDataset", "AutoEvalTask", "FLIPDatasetName", "all_flip_datasets",
15
+ "PBCSupervisedDatasetName", "all_pbc_supervised_datasets", "AutoEvalMode", "ZeroShotContactCachedResults",
16
+ "FrameworkReport"
17
+ ]
@@ -0,0 +1,61 @@
1
+ from typing import Dict
2
+ from enum import Enum
3
+
4
+ from .autoeval_supervised_dataset import AutoEvalSupervisedDataset
5
+ from ..protocol import Protocol
6
+
7
+
8
+ class FLIPDatasetName(str, Enum):
9
+ AAV = "aav"
10
+ BIND = "bind"
11
+ CONSERVATION = "conservation"
12
+ GB1 = "gb1"
13
+ MELTOME = "meltome"
14
+ SCL = "scl"
15
+ SAV = "sav"
16
+ SECONDARY_STRUCTURE = "secondary_structure"
17
+
18
+
19
+ def all_flip_datasets() -> Dict[str, AutoEvalSupervisedDataset]:
20
+ datasets = [AutoEvalSupervisedDataset(
21
+ name=f"{FLIPDatasetName.AAV}",
22
+ evaluation_metric="spearmans-corr-coeff",
23
+ protocol=Protocol.sequence_to_value,
24
+ splits=["des_mut", "mut_des", "one_vs_many", "two_vs_many", "seven_vs_many", "low_vs_high", "sampled"]
25
+ ), AutoEvalSupervisedDataset(
26
+ name=f"{FLIPDatasetName.BIND}",
27
+ evaluation_metric="macro-f1_score",
28
+ protocol=Protocol.residue_to_class,
29
+ splits=["one_vs_many", "two_vs_many", "from_publication", "one_vs_sm", "one_vs_mn", "one_vs_sn"]
30
+ ), AutoEvalSupervisedDataset(
31
+ name=f"{FLIPDatasetName.CONSERVATION}/sampled",
32
+ evaluation_metric="accuracy",
33
+ protocol=Protocol.residue_to_class
34
+ ), AutoEvalSupervisedDataset(
35
+ name=f"{FLIPDatasetName.GB1}",
36
+ evaluation_metric="spearmans-corr-coeff",
37
+ protocol=Protocol.sequence_to_value,
38
+ splits=["one_vs_rest", "two_vs_rest", "three_vs_rest", "low_vs_high", "sampled"]
39
+ ), AutoEvalSupervisedDataset(
40
+ name=f"{FLIPDatasetName.MELTOME}",
41
+ evaluation_metric="spearmans-corr-coeff",
42
+ protocol=Protocol.sequence_to_value,
43
+ splits=["mixed_split", "human", "human_cell"]
44
+ ), AutoEvalSupervisedDataset(
45
+ name=f"{FLIPDatasetName.SCL}",
46
+ evaluation_metric="accuracy",
47
+ protocol=Protocol.sequence_to_class,
48
+ splits=["mixed_soft", "mixed_hard", "human_soft", "human_hard", "balanced", "mixed_vs_human_2"]
49
+ ), AutoEvalSupervisedDataset(
50
+ name=f"{FLIPDatasetName.SAV}",
51
+ evaluation_metric="f1_score",
52
+ protocol=Protocol.sequence_to_class,
53
+ splits=["mixed", "human", "only_savs"]
54
+ ), AutoEvalSupervisedDataset(
55
+ name=f"{FLIPDatasetName.SECONDARY_STRUCTURE}",
56
+ evaluation_metric="accuracy",
57
+ protocol=Protocol.residue_to_class,
58
+ splits=["sampled"]
59
+ )]
60
+
61
+ return {d.name: d for d in datasets}
@@ -0,0 +1,8 @@
1
+ from enum import Enum
2
+
3
+
4
+ class AutoEvalMode(Enum):
5
+ SUPERVISED = "SUPERVISED"
6
+ ZERO_SHOT = "ZERO_SHOT"
7
+ ZERO_SHOT_CONTACT = "ZERO_SHOT_CONTACT"
8
+ SUPERVISED_CONTACT_ATTENTION = "SUPERVISED_CONTACT_ATTENTION"
@@ -0,0 +1,44 @@
1
+ from typing import Dict
2
+
3
+ from enum import Enum
4
+ from .autoeval_supervised_dataset import AutoEvalSupervisedDataset
5
+
6
+ from ..protocol import Protocol
7
+
8
+
9
+ class PBCSupervisedDatasetName(str, Enum):
10
+ CONSERVATION = "conservation"
11
+ DISORDER_CHEZOD = "disorder_chezod"
12
+ # DISORDER_TRIZOD = "disorder_trizod" Currently not used
13
+ FRUSTRATION_CLASSIFICATION = "frustration-classification"
14
+ FRUSTRATION_REGRESSION = "frustration-regression"
15
+ # MEMBRANE = "membrane" Currently not used
16
+ PHAGES = "phages"
17
+ SCL = "scl"
18
+ SECONDARY_STRUCTURE = "secondary_structure"
19
+
20
+
21
+ def all_pbc_supervised_datasets() -> Dict[str, AutoEvalSupervisedDataset]:
22
+ datasets = [AutoEvalSupervisedDataset(name=PBCSupervisedDatasetName.CONSERVATION,
23
+ evaluation_metric="accuracy",
24
+ protocol=Protocol.residue_to_class),
25
+ AutoEvalSupervisedDataset(name=PBCSupervisedDatasetName.DISORDER_CHEZOD,
26
+ evaluation_metric="spearmans-corr-coeff",
27
+ protocol=Protocol.residue_to_value),
28
+ AutoEvalSupervisedDataset(name=PBCSupervisedDatasetName.FRUSTRATION_CLASSIFICATION,
29
+ evaluation_metric="macro-f1_score",
30
+ protocol=Protocol.residue_to_class),
31
+ AutoEvalSupervisedDataset(name=PBCSupervisedDatasetName.FRUSTRATION_REGRESSION,
32
+ evaluation_metric="spearmans-corr-coeff",
33
+ protocol=Protocol.residue_to_value),
34
+ AutoEvalSupervisedDataset(name=PBCSupervisedDatasetName.PHAGES,
35
+ evaluation_metric="accuracy",
36
+ protocol=Protocol.sequence_to_class),
37
+ AutoEvalSupervisedDataset(name=PBCSupervisedDatasetName.SCL,
38
+ evaluation_metric="balanced-accuracy",
39
+ protocol=Protocol.sequence_to_class),
40
+ AutoEvalSupervisedDataset(name=PBCSupervisedDatasetName.SECONDARY_STRUCTURE,
41
+ evaluation_metric="accuracy",
42
+ protocol=Protocol.residue_to_class),
43
+ ]
44
+ return {d.name: d for d in datasets}
@@ -0,0 +1,11 @@
1
+ from typing import Optional
2
+ from pydantic import BaseModel, Field
3
+
4
+ from .autoeval_report import FrameworkReport
5
+
6
+ class AutoEvalProgress(BaseModel):
7
+ completed_tasks: int = Field(description="Number of completed autoeval tasks", ge=0)
8
+ total_tasks: int = Field(description="Total number of autoeval tasks", ge=0)
9
+ current_framework_name: str = Field(description="Name of the current framework that is being evaluated")
10
+ current_task_name: str = Field(description="Name of the current task that is being executed")
11
+ final_report: Optional[FrameworkReport] = Field(default=None, description="Final Framework Report")