Transforms

Transforms modify dataset shards, splits, and assets offline or at load time. Summaries below are taken from each class docstring.

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: Transform

Compute 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: 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.

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: Transform

Compute 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_count node features per residue.

Depends on batch.residues.residue_backbone from ResidueBackboneAtoms. Writes batch.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: Transform

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.

Requires:
  • batch.residue_pos with shape [N_res, 3] containing Cα positions, e.g. from ResiduePositions(mode="CA").

  • batch.residues.residue_is_surface boolean mask from IsSurfaceResidue.

Produces:
  • batch.residues.residue_core_distance_rbf with shape [N_res, D_count]

  • batch.residues.residue_surface_distance_rbf with 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: Transform

Concatenate 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”

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: Transform

Approximate 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_pos with shape [N_res, 3] containing Cα positions, e.g. from ResiduePositions(mode="CA").

  • batch.residues.residue_is_surface boolean mask from IsSurfaceResidue.

Produces:
  • batch.residues.residue_curvature with shape [N_res], where non-surface residues are set to default_value.

Compute or add deduplicate atoms features to batches.

class bioverse.transforms.deduplicate_atoms.DeduplicateAtoms[source]

Bases: Transform

Compute or add deduplicate atoms features to batches.

Compute or add dihedrals features to batches.

class bioverse.transforms.dihedrals.Dihedrals(eps=1e-07)[source]

Bases: Transform

Compute or add dihedrals features to batches.

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: Transform

Per-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: Transform

Compute or add edge pos emb features to batches.

Compute or add edge vectors features to batches.

class bioverse.transforms.edge_vectors.EdgeVectors[source]

Bases: Transform

Compute or add edge vectors features to batches.

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: Transform

Filter 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: Transform

Filter batches or scenes based on filter sequence length.

No-op transform that returns inputs unchanged.

class bioverse.transforms.identity.Identity[source]

Bases: Transform

No-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: Transform

Classify 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_pos with shape [N_res, 3] containing Cα positions, e.g. from ResiduePositions(mode="CA").

Produces:
  • batch.residues.residue_is_surface as 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_fraction of residues are classified as surface.

  • surface_fraction – Target upper bound on the fraction of surface residues per chain when adaptive is True.

Build a graph representation from knn graph.

class bioverse.transforms.knn_graph.KnnGraph(k=5, symmetric=True, mode='connectivity', resolution='atom')[source]

Bases: Transform

Build a graph representation from knn graph.

Build a graph representation from linear residue graph.

class bioverse.transforms.linear_residue_graph.LinearResidueGraph[source]

Bases: Transform

Build 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: Transform

Compute or add local reference frames features to batches.

L2-normalize vector features.

class bioverse.transforms.normalize_vector.NormalizeVector(field)[source]

Bases: Transform

L2-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: Transform

One-hot encode atom features from token indices.

One-hot encode residues features.

class bioverse.transforms.one_hot_residue_features.OneHotResidueFeatures(alphabet='ARNDCQEGHILKMFPSTWYV')[source]

Bases: Transform

One-hot encode residues features.

Compute or add orientations features to batches.

class bioverse.transforms.orientations.Orientations[source]

Bases: Transform

Compute or add orientations features to batches.

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: Transform

Compute 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: Transform

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.

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.

Compute or add residue backbone atoms features to batches.

class bioverse.transforms.residue_backbone_atoms.ResidueBackboneAtoms[source]

Bases: Transform

Compute or add residue backbone atoms features to batches.

Compute or add residue frames features to batches.

class bioverse.transforms.residue_frames.ResidueFrames[source]

Bases: Transform

Compute 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: Transform

Per-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 or add residue positions features to batches.

class bioverse.transforms.residue_positions.ResiduePositions(mode='CA')[source]

Bases: Transform

Compute or add residue positions features to batches.

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: Transform

Compute 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.

Assign split partitions at the scene level.

class bioverse.transforms.scene_split.SceneSplit(train_size=0.8, test_size=0.1, val_size=0.1)[source]

Bases: Transform

Assign split partitions at the scene level.

Compute or add sidechains features to batches.

class bioverse.transforms.sidechains.Sidechains[source]

Bases: Transform

Compute or add sidechains features to batches.

Standardize features to zero mean and unit variance.

class bioverse.transforms.standardize.Standardize(field)[source]

Bases: Transform

Standardize 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: Transform

Standardize pairwise targets stored in assets (e.g. lDDT matrices).

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: Transform

Tokenize atoms into integer indices using dataset assets.

Tokenize properties into integer indices using dataset assets.

class bioverse.transforms.tokenize_property.TokenizeProperty(field, alphabet)[source]

Bases: Transform

Tokenize properties into integer indices using dataset assets.

Tokenize residues into integer indices using dataset assets.

class bioverse.transforms.tokenize_residues.TokenizeResidues(alphabet='ARNDCQEGHILKMFPSTWYV')[source]

Bases: Transform

Tokenize residues into integer indices using dataset assets.