Transforms
Transforms modify dataset shards, splits, and assets offline or at load time. Summaries below are taken from each class docstring.
Write residue_is_peptide from chain_type (last chain if missing).
- class bioverse.transforms.annotate_peptide_residues.AnnotatePeptideResidues(peptide_type='peptide')[source]
Bases:
TransformWrite
residue_is_peptidefromchain_type(last chain if missing).
Write residue_contact and residue_pocket_distance from peptide Cαs.
- class bioverse.transforms.annotate_pocket_contacts.AnnotatePocketContacts(radius=8.0, peptide_type='peptide')[source]
Bases:
TransformWrite
residue_contactandresidue_pocket_distancefrom peptide Cαs.Contacts are protein residues within
radiusÅ of any peptide Cα. Peptide residues are labeled 0 / inf. Apply before dropping the peptide so the encoder never sees ligand coordinates.
Choose an AlphaFold file for each scene’s UniProt candidates.
- class bioverse.transforms.attach_alpha_fold_structure.AttachAlphaFoldStructure(name: str = 'swissprot_pdb', version: str = 'v4', api_fallback: bool = True, api_workers: int | None = None)[source]
Bases:
MarkedFilterChoose an AlphaFold file for each scene’s UniProt candidates.
Local Swiss-Prot files win. With
api_fallback, missing accessions are fetched once duringfitand reused. Kept scenes are then ordered as local hits followed by API hits, which is the order the former adapter used before shuffling inside each split.Writes
molecule_uniprot,molecule_ranges,molecule_structure_path,molecule_structure_source, andmolecule_structure_origin.
Compute backbone bond-angle features (alpha, beta, gamma) per residue, encoded as [cos(theta), sin(theta)] for each angle, analogous to PiFold.
- class bioverse.transforms.backbone_bond_angles.BackboneBondAngles(eps: float = 1e-07)[source]
Bases:
TransformCompute backbone bond-angle features (alpha, beta, gamma) per residue, encoded as [cos(theta), sin(theta)] for each angle, analogous to PiFold.
This is the “Angle_features” part of _dihedrals in the provided PiFold featuriser, factored out as a standalone transform.
Compute RBF-expanded backbone distance features for multiple atom pairs along residue-residue edges, matching the pair-types used in the MPNN / PiFold featurisers.
- class bioverse.transforms.backbone_edge_rbf.BackboneEdgeRbf(D_min: float = 2.0, D_max: float = 22.0, D_count: int = 16, feature_type: str = 'mpnn')[source]
Bases:
TransformCompute RBF-expanded backbone distance features for multiple atom pairs along residue-residue edges, matching the pair-types used in the MPNN / PiFold featurisers.
- Requires:
batch.molecules.residue_backbone with shape [n_res, 4, 3] per molecule (N, CA, C, O) from ResidueBackboneAtoms
batch.molecules.residue_cb with shape [n_res, 3] per molecule from ResiduePseudoCB
batch.molecules.molecule_edges with shape [n_edges, 2] per molecule
- Produces:
batch.molecules.molecule_edge_rbf_all of shape [n_edges, num_pairs * D_count] per molecule.
Compute per-residue RBF-expanded within-residue backbone distance features.
- class bioverse.transforms.backbone_node_rbf.BackboneNodeRbf(D_min: float = 0.0, D_max: float = 20.0, D_count: int = 16)[source]
Bases:
TransformCompute per-residue RBF-expanded within-residue backbone distance features.
For each residue, computes Euclidean distances between the six intra-residue backbone atom pairs (Ca-N, Ca-C, Ca-O, N-C, N-O, O-C), expands each distance with a Gaussian RBF basis, and concatenates the result into
6 * D_countnode features per residue.Depends on
batch.residues.residue_backbonefromResidueBackboneAtoms. Writesbatch.residues.residue_node_rbf.
RBF-encode per-residue distances to (a) the center-of-geometry of each chain/molecule and (b) the nearest surface residue, using only Cα atoms.
- class bioverse.transforms.core_and_surface_distance.CoreAndSurfaceDistance(D_min: float = 0.0, D_max: float = 30.0, D_count: int = 16)[source]
Bases:
TransformRBF-encode per-residue distances to (a) the center-of-geometry of each chain/molecule and (b) the nearest surface residue, using only Cα atoms.
- Requires:
batch.residue_poswith shape [N_res, 3] containing Cα positions, e.g. fromResiduePositions(mode="CA").batch.residues.residue_is_surfaceboolean mask fromIsSurfaceResidue.
- Produces:
batch.residues.residue_core_distance_rbfwith shape [N_res, D_count]batch.residues.residue_surface_distance_rbfwith shape [N_res, D_count]
Concatenate existing attributes into a single feature tensor.
- class bioverse.transforms.create_feature_from_others.CreateFeatureFromOthers(feature_level: str, source_attrs: list[str], target_attr: str)[source]
Bases:
TransformConcatenate existing attributes into a single feature tensor.
- Parameters:
feature_level ({"vertex", "edge"}) – Whether to create a vertex-level (per residue / atom) or edge-level (per edge) feature.
source_attrs (list[str]) – List of attribute names to concatenate, e.g. - vertex level: [“residue_dihedrals”, “residue_bond_angles”] - edge level: [“molecule_edge_rbf”, “molecule_edge_vectors”]
target_attr (str) – Name of the new attribute to write into the batch. The correct prefix is inferred from feature_level: - “vertex”: prefix “vertex” is mapped to “residue” or “atom” - “edge”: you should pass a full name, e.g. “molecule_edge_features”
Crop each scene to the inclusive ranges in molecule_ranges.
- class bioverse.transforms.crop_residues_to_ranges.CropResiduesToRanges[source]
Bases:
MarkedFilterCrop each scene to the inclusive ranges in
molecule_ranges.Residue numbers are the UniProt numbers on an AlphaFold structure. Scenes whose crop is empty are dropped.
Drop non-pocket protein residues.
- class bioverse.transforms.crop_to_pocket.CropToPocket(radius=8.0, peptide_type='peptide')[source]
Bases:
TransformDrop non-pocket protein residues.
Remaining nodes are the peptide (or peptide atoms, after explode) plus every protein residue whose Cα is within
radiusÅ of a peptide Cα. Apply this before kNN so the graph is built on the cropped complex.
Approximate backbone curvature at each residue from Cα positions and mask it to surface residues.
- class bioverse.transforms.curvature.Curvature(default_value: float = 0.0, eps: float = 1e-07)[source]
Bases:
TransformApproximate backbone curvature at each residue from Cα positions and mask it to surface residues.
Curvature is estimated per chain from triples of consecutive Cα atoms (p_{i-1}, p_i, p_{i+1}) as the inverse radius of the circle through the three points:
- κ_i = 2 * ||(p_i - p_{i-1}) × (p_{i+1} - p_i)|| /
(||p_i - p_{i-1}|| * ||p_{i+1} - p_i|| * ||(p_{i+1} - p_{i-1})||)
Endpoints (residues without both neighbors) are assigned zero curvature.
- Requires:
batch.residue_poswith shape [N_res, 3] containing Cα positions, e.g. fromResiduePositions(mode="CA").batch.residues.residue_is_surfaceboolean mask fromIsSurfaceResidue.
- Produces:
batch.residues.residue_curvaturewith shape [N_res], where non-surface residues are set todefault_value.
Compute or add deduplicate atoms features to batches.
- class bioverse.transforms.deduplicate_atoms.DeduplicateAtoms[source]
Bases:
TransformCompute or add deduplicate atoms features to batches.
Compute or add dihedrals features to batches.
- class bioverse.transforms.dihedrals.Dihedrals(eps=1e-07)[source]
Bases:
TransformCompute or add dihedrals features to batches.
Keep protein residues only. Contact labels computed earlier are filtered too.
- class bioverse.transforms.drop_peptide_residues.DropPeptideResidues(peptide_type='peptide')[source]
Bases:
TransformKeep protein residues only. Contact labels computed earlier are filtered too.
Per-edge local backbone directions expressed in the source residue frame, analogous to E_direct in the PiFold featuriser.
- class bioverse.transforms.edge_local_directions.EdgeLocalDirections[source]
Bases:
TransformPer-edge local backbone directions expressed in the source residue frame, analogous to E_direct in the PiFold featuriser.
- Requires:
batch.molecules.residue_backbone [n_res, 4, 3] (N, CA, C, O)
batch.molecules.residue_frame_R [n_res, 3, 3] from ResidueFrames
batch.molecules.molecule_edges [n_edges, 2]
- Produces:
batch.molecules.molecule_edge_direct with shape [n_edges, 12] per molecule (4 unit vectors × 3 coordinates, flattened), where the 4 vectors are from source CA to neighbor CA, N, C, O.
Compute or add edge pos emb features to batches.
- class bioverse.transforms.edge_pos_emb.EdgePosEmb(num_embeddings=16, period_range=[2, 1000])[source]
Bases:
TransformCompute or add edge pos emb features to batches.
Compute or add edge vectors features to batches.
- class bioverse.transforms.edge_vectors.EdgeVectors[source]
Bases:
TransformCompute or add edge vectors features to batches.
Turn each ligand atom into its own residue.
- class bioverse.transforms.explode_ligand_atoms.ExplodeLigandAtoms(chain_type='ligand')[source]
Bases:
TransformTurn each ligand atom into its own residue.
Protein chains are unchanged. On ligand chains,
residue_labelbecomes the atom element and each new residue holds exactly one atom, so a residue-level k-NN graph can connect protein residues to ligand atoms.
Keep or drop polymer chains by chain_label.
- class bioverse.transforms.filter_chains.FilterChains(keep=None, drop=None)[source]
Bases:
TransformKeep or drop polymer chains by
chain_label.Apply this before live graph transforms. Filtering after kNN leaves edges that point at removed nodes.
- Parameters:
keep (str or sequence of str, optional) – Chain labels to retain. If omitted, every chain is eligible.
drop (str or sequence of str, optional) – Chain labels to remove. Applied after
keep.
Filter batches or scenes based on filter residues by value.
- class bioverse.transforms.filter_residues_by_value.FilterResiduesByValue(attribute: str, value: any | None = None, below: float | None = None, above: float | None = None)[source]
Bases:
TransformFilter batches or scenes based on filter residues by value.
Filter batches or scenes based on filter sequence length.
- class bioverse.transforms.filter_sequence_length.FilterSequenceLength(max_length: int)[source]
Bases:
TransformFilter batches or scenes based on filter sequence length.
Hide peptide sequence while leaving coordinates and protein letters intact.
- class bioverse.transforms.hide_peptide_residues.HidePeptideResidues(mask='?', peptide_type='peptide')[source]
Bases:
TransformHide peptide sequence while leaving coordinates and protein letters intact.
Write residue_features: protein geometry + peptide element one-hot.
- class bioverse.transforms.hybrid_pocket_features.HybridPocketFeatures(element_alphabet=('C', 'N', 'O', 'S', 'P', 'H', 'X'))[source]
Bases:
TransformWrite
residue_features: protein geometry + peptide element one-hot.
No-op transform that returns inputs unchanged.
- class bioverse.transforms.identity.Identity[source]
Bases:
TransformNo-op transform that returns inputs unchanged.
Classify residues as surface or core using only Cα coordinates.
- class bioverse.transforms.is_surface_residue.IsSurfaceResidue(probe_radius: float = 10.0, min_neighbors: int = 24, adaptive: bool = True, surface_fraction: float = 0.3)[source]
Bases:
TransformClassify residues as surface or core using only Cα coordinates.
- This implements a simple, density-based rolling-ball style heuristic:
For each residue, we count how many other Cα atoms lie within a spherical neighborhood of radius
probe_radius.Residues with comparatively few neighbors are marked as surface.
- Requires:
batch.residue_poswith shape [N_res, 3] containing Cα positions, e.g. fromResiduePositions(mode="CA").
- Produces:
batch.residues.residue_is_surfaceas a boolean array of shape [N_res], flattened over higher axes.
- __init__(probe_radius: float = 10.0, min_neighbors: int = 24, adaptive: bool = True, surface_fraction: float = 0.3)[source]
- Parameters:
probe_radius – Neighborhood radius (in Å) for counting nearby Cα atoms.
min_neighbors – Minimum neighbor count below which residues are considered surface.
adaptive – If True, the threshold per chain is adapted so that at most
surface_fractionof residues are classified as surface.surface_fraction – Target upper bound on the fraction of surface residues per chain when
adaptiveis True.
Build a k-NN graph over nodes in each molecule.
- class bioverse.transforms.knn_graph.KnnGraph(k=5, symmetric=True, mode='connectivity', resolution='atom', link_chains=True)[source]
Bases:
TransformBuild a k-NN graph over nodes in each molecule.
Edges are stored on the molecule. By default every chain in a molecule shares one graph; set
link_chains=Falseto build a separate k-NN graph per chain (still indexed in molecule-local node order).
Build a graph representation from linear residue graph.
- class bioverse.transforms.linear_residue_graph.LinearResidueGraph[source]
Bases:
TransformBuild a graph representation from linear residue graph.
Compute or add local reference frames features to batches.
- class bioverse.transforms.local_reference_frames.LocalReferenceFrames(resolution='atom')[source]
Bases:
TransformCompute or add local reference frames features to batches.
Drop scenes whose scene_filter entry is false and record their ids.
- class bioverse.transforms.marked_filter.MarkedFilter[source]
Bases:
TransformDrop scenes whose
scene_filterentry is false and record their ids.Subclasses set
skip_reason.count_origincounts kept scenes bymolecule_structure_origin(localorapi).
L2-normalize vector features.
- class bioverse.transforms.normalize_vector.NormalizeVector(field)[source]
Bases:
TransformL2-normalize vector features.
One-hot encode atom features from token indices.
- class bioverse.transforms.one_hot_atom_features.OneHotAtomFeatures(alphabet=['H', 'C', 'N', 'O', 'P', 'S', 'Na', 'K', 'Mg', 'Ca', 'Cl', 'Fe', 'Zn', 'Cu', 'Mn', 'Co', 'Mo', 'Ni', 'Se', 'I', 'B', 'F', 'Cr', 'V'])[source]
Bases:
TransformOne-hot encode atom features from token indices.
One-hot encode residues features.
- class bioverse.transforms.one_hot_residue_features.OneHotResidueFeatures(alphabet='ARNDCQEGHILKMFPSTWYV', unk='%')[source]
Bases:
TransformOne-hot encode residues features.
transform_assetsstores the identity table for VirtualBatch.featurize after an offline apply.transform_batchwritesresidue_onehotso live graphs can concatenate it with geometry.
Compute or add orientations features to batches.
- class bioverse.transforms.orientations.Orientations[source]
Bases:
TransformCompute or add orientations features to batches.
Explode peptide residues into heavy-atom nodes.
- class bioverse.transforms.peptide_atom_context.PeptideAtomContext(sidechains=True, peptide_type='peptide')[source]
Bases:
TransformExplode peptide residues into heavy-atom nodes.
Protein residues stay in Awkward. Only the peptide chain is materialized in Python. Set
sidechains=Falsefor backbone atoms only.
Map molecule_seqres_ranges through SIFTS onto UniProt coordinates.
- class bioverse.transforms.project_ranges_through_sifts.ProjectRangesThroughSifts[source]
Bases:
MarkedFilterMap
molecule_seqres_rangesthrough SIFTS onto UniProt coordinates.Writes
molecule_candidates, a JSON list of{uniprot, ranges}objects. A chain whose ranges hit no SIFTS segment is dropped.
Compute or add rbf features to batches.
- class bioverse.transforms.rbf.Rbf(D_min=0.0, D_max=20.0, D_count=16)[source]
Bases:
TransformCompute or add rbf features to batches.
Compute relative rotations between residue frames along edges, expressed as quaternions, analogous to E_angles in the PiFold featuriser but using the current edge set (molecule_edges) instead of a fixed linear graph.
- class bioverse.transforms.relative_edge_frame_positions.RelativeEdgeFramePositions[source]
Bases:
TransformCompute relative rotations between residue frames along edges, expressed as quaternions, analogous to E_angles in the PiFold featuriser but using the current edge set (molecule_edges) instead of a fixed linear graph.
- Requires:
batch.molecules.residue_frame_R [n_res, 3, 3] from ResidueFrames
batch.molecules.molecule_edges [n_edges, 2]
- Produces:
batch.molecules.molecule_edge_quaternions with shape [n_edges, 4] per molecule.
Parse molecule_structure_path and adopt its residue and atom fields.
- class bioverse.transforms.replace_with_structure_file.ReplaceWithStructureFile[source]
Bases:
TransformParse
molecule_structure_pathand adopt its residue and atom fields.Molecule-level columns already on the scene, including
molecule_id, are kept. The filename written by the PDB parser is not.
Compute or add residue backbone atoms features to batches.
- class bioverse.transforms.residue_backbone_atoms.ResidueBackboneAtoms[source]
Bases:
TransformCompute or add residue backbone atoms features to batches.
Compute or add residue frames features to batches.
- class bioverse.transforms.residue_frames.ResidueFrames[source]
Bases:
TransformCompute or add residue frames features to batches.
Per-residue local backbone directions (N, C, O) expressed in the residue local frame, analogous to V_direct in the PiFold featuriser.
- class bioverse.transforms.residue_local_directions.ResidueLocalDirections[source]
Bases:
TransformPer-residue local backbone directions (N, C, O) expressed in the residue local frame, analogous to V_direct in the PiFold featuriser.
- Requires:
batch.residues.residue_backbone with shape [n_res, 4, 3] (N, CA, C, O)
batch.residues.residue_frame_T and batch.residues.residue_frame_R from ResidueFrames
- Produces:
batch.residues.residue_direct with shape [n_res, 9] per batch (3 unit vectors × 3 coordinates, flattened).
Compute residue positions from atom coordinates.
- class bioverse.transforms.residue_positions.ResiduePositions(mode='CA')[source]
Bases:
TransformCompute residue positions from atom coordinates.
CAuses the Cα atom when present and otherwise the atom centroid, so residues without backbone (ligands, missing CA) stay in the batch.
Compute pseudo Cβ coordinates from backbone atoms (N, CA, C), as in _compute_cb from the PiFold featuriser.
- class bioverse.transforms.residue_pseudo_cb.ResiduePseudoCb[source]
Bases:
TransformCompute pseudo Cβ coordinates from backbone atoms (N, CA, C), as in _compute_cb from the PiFold featuriser.
The resulting coordinates are stored as batch.residues.residue_cb.
Resolve molecule_id PDB chains to CATH domain boundaries.
- class bioverse.transforms.resolve_cath_domain.ResolveCathDomain(pick: str = 'closest_sequence_length')[source]
Bases:
MarkedFilterResolve
molecule_idPDB chains to CATH domain boundaries.molecule_idvalues look like12as.A. The domain id and its SEQRES ranges are written tomolecule_domain_idandmolecule_seqres_ranges. Chains with no domain are dropped.- Parameters:
pick ({"closest_sequence_length", "first"}) – How to choose when a chain contains more than one domain.
closest_sequence_lengthmatches the ProteinInvBench convention: the domain whose SEQRES length is closest to the chain sequence.
Assign shuffled, class-balanced split partitions at the scene level.
- class bioverse.transforms.scene_split.SceneSplit(train_size=0.8, test_size=0.1, val_size=0.1, seed=0)[source]
Bases:
TransformAssign shuffled, class-balanced split partitions at the scene level.
Shuffle scenes inside each partition of an existing split.
- class bioverse.transforms.shuffle_within_split.ShuffleWithinSplit(split: str = 'ProteinInvBench_scene_split', seed: int | None = None)[source]
Bases:
TransformShuffle scenes inside each partition of an existing split.
Partitions are emitted in
train,val,testorder. The shuffle inside a partition follows the order scenes already have, so callers that need the historical AlphaFold ProteinInvBench order should feed file order with local structures before API structures.- Parameters:
split (str) – Split column to read and rewrite. Defaults to the ProteinInvBench split.
seed (int, optional) – Generator seed. The library seed is used when this is omitted.
Compute or add sidechains features to batches.
- class bioverse.transforms.sidechains.Sidechains[source]
Bases:
TransformCompute or add sidechains features to batches.
Standardize features to zero mean and unit variance.
- class bioverse.transforms.standardize.Standardize(field)[source]
Bases:
TransformStandardize features to zero mean and unit variance.
Standardize pairwise targets stored in assets (e.g. lDDT matrices).
- class bioverse.transforms.standardize_pairwise.StandardizePairwise(meta: str = 'lddt')[source]
Bases:
TransformStandardize pairwise targets stored in assets (e.g. lDDT matrices).
Predict 3D coordinates for each molecule with a folding model.
- class bioverse.transforms.structure_prediction.StructurePredictionTransform(model: str = 'boltz2', use_msa_server: bool = True, cache_dir: Path | str | None = None)[source]
Bases:
TransformPredict 3D coordinates for each molecule with a folding model.
Currently supports Boltz 2. Each batch is written as a directory of YAML inputs and predicted in a single
boltz predictcall. Parsed coordinates are written as a standard scene / frame / molecule / chain batch, including denseresidue_pos/residue_token/residue_backbone. Mutation tables and other molecule annotations are preserved. Residue counts must match the input sequences.- run_predictor(input_dir: Path, out_dir: Path) None[source]
Run Boltz 2 on a directory of YAML inputs.
Tokenize atoms into integer indices using dataset assets.
- class bioverse.transforms.tokenize_atoms.TokenizeAtoms(alphabet=['H', 'C', 'N', 'O', 'P', 'S', 'Na', 'K', 'Mg', 'Ca', 'Cl', 'Fe', 'Zn', 'Cu', 'Mn', 'Co', 'Mo', 'Ni', 'Se', 'I', 'B', 'F', 'Cr', 'V'])[source]
Bases:
TransformTokenize atoms into integer indices using dataset assets.
Tokenize residues with disjoint protein and ligand alphabets.
- class bioverse.transforms.tokenize_by_chain_type.TokenizeByChainType(protein_alphabet='ARNDCQEGHILKMFPSTWYV', ligand_alphabet=['H', 'C', 'N', 'O', 'P', 'S', 'Na', 'K', 'Mg', 'Ca', 'Cl', 'Fe', 'Zn', 'Cu', 'Mn', 'Co', 'Mo', 'Ni', 'Se', 'I', 'B', 'F', 'Cr', 'V'], protein_type='protein', ligand_type='ligand', unk='%')[source]
Bases:
TransformTokenize residues with disjoint protein and ligand alphabets.
Protein chains use
protein_alphabet(plus UNK). Ligand chains useligand_alphabetwith indices offset so cysteineCand carbonCare different tokens. Writes matchingresidue_features.
Tokenize properties into integer indices using dataset assets.
- class bioverse.transforms.tokenize_property.TokenizeProperty(field, alphabet)[source]
Bases:
TransformTokenize properties into integer indices using dataset assets.
Tokenize residues into integer indices using dataset assets.