module adabmDCA.api.results
Result objects returned by the high-level adabmDCA API.
Global Variables
- TYPE_CHECKING
class ModelMetadata
Portable description of a loaded DCA model.
Attributes:
length: Number of sitesL.alphabet: Alphabet name or custom token string given when loading.tokens: Ordered token string of lengthq.device: Device of the parameters, e.g."cpu"or"cuda:0".dtype: Precision of the parameters, e.g."float32".source: Path of the file the model was loaded from, if any.package_version: adabmDCA version that loaded the model.schema_version: Version of this metadata format.
method __init__
__init__(
length: 'int',
alphabet: 'str',
tokens: 'str',
device: 'str',
dtype: 'str',
source: 'str | None' = None,
package_version: 'str | None' = None,
schema_version: 'str' = '1.0'
) → None
property num_states
Number of states per site, q.
method to_dict
to_dict() → dict[str, Any]
Return a JSON-compatible document with the result type and schema version.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write the metadata as a versioned JSON document.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
class EnergyResult
DCA energies of scored sequences, returned by score_sequences.
Attributes:
sequences: Scored sequences, in input order.energies: Energy of each sequence (lower is more probable).model: Metadata of the scoring model.names: Sequence names when read from an alignment, else empty.warnings: Non-fatal issues found while scoring.cde_sum: Summed context-dependent entropy of each sequence, orNone.local_free_energies:energies - local_lambda * cde_sum, orNone.local_lambda: Weight used for the local free energies, orNone.
method __init__
__init__(
sequences: 'tuple[str, ]',
energies: 'ndarray',
model: 'ModelMetadata',
names: 'tuple[str, ]' = (),
warnings: 'tuple[str, ]' = (),
cde_sum: 'ndarray | None' = None,
local_free_energies: 'ndarray | None' = None,
local_lambda: 'float | None' = None
) → None
method save
save(path: 'str | Path', format: 'str | None' = None) → Path
Write the result in the format given by format or by the file extension.
Args:
path: Output file.format: One of"csv","fasta"or"json"; inferred from the extension whenNone.
Returns: The written path.
method save_bundle
save_bundle(directory: 'str | Path', stem: 'str' = 'energies') → dict[str, Path]
Write <stem>.fasta, <stem>.csv and <stem>.json to directory.
Args:
directory: Output folder.stem: File-name stem.
Returns:
The written paths, keyed by kind (fasta, csv and summary).
method to_csv
to_csv(path: 'str | Path') → Path
Write to_dataframe as CSV.
Args:
path: Output file.
Returns: The written path.
method to_dataframe
to_dataframe() → DataFrame
Return one row per sequence: name (if known), sequence, energy and CDE columns.
method to_dict
to_dict() → dict[str, Any]
Return a portable representation of the result.
method to_fasta
to_fasta(path: 'str | Path') → Path
Write the sequences to FASTA, with energies in the headers.
Args:
path: Output file.
Returns: The written path.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write to_dict as JSON.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
class ContactMapResult
Contact scores returned by predict_contacts.
Attributes:
scores: Symmetric(L, L)array of APC-corrected scores, zero diagonal.method:"model"for a trained model,"mean_field"for an alignment.alphabet: Alphabet used.tokens: Ordered token string.model: Metadata of the model, formethod="model".warnings: Non-fatal issues found while scoring.
method __init__
__init__(
scores: 'ndarray',
method: 'str',
alphabet: 'str',
tokens: 'str',
model: 'ModelMetadata | None' = None,
warnings: 'tuple[str, ]' = ()
) → None
method save
save(path: 'str | Path', format: 'str | None' = None) → Path
Write the result in the format given by format or by the file extension.
Args:
path: Output file.format: One of"csv","json"or"npy"; inferred from the extension whenNone.
Returns: The written path.
method save_bundle
save_bundle(
directory: 'str | Path',
label: 'str | None' = None
) → dict[str, Path]
Write the matrix (.txt, .csv, .npy) and a JSON summary to directory.
Args:
directory: Output folder.label: Optional file-name prefix, giving<label>_contact_map.*.
Returns:
The written paths, keyed by kind (matrix, csv, npy and summary).
method save_matrix
save_matrix(path: 'str | Path') → Path
Write the scores as headerless i,j,score lines, the format of adabmDCA contacts.
Args:
path: Output file.
Returns: The written path.
method to_csv
to_csv(path: 'str | Path') → Path
Write to_long_dataframe as CSV with a header.
Args:
path: Output file.
Returns: The written path.
method to_dict
to_dict() → dict[str, Any]
Return a JSON-compatible document with the result type and schema version.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write to_dict as JSON.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
method to_long_dataframe
to_long_dataframe() → DataFrame
Return one row per matrix entry: position_i, position_j (0-based) and score.
method to_npy
to_npy(path: 'str | Path') → Path
Write the (L, L) score matrix as a NumPy .npy file.
Args:
path: Output file.
Returns: The written path.
class MutationRecord
One single-site mutant from scan_mutations.
Attributes:
position: 0-based site of the substitution.wild_type: Wild-type token at that site.mutant: Substituted token.sequence: Full mutant sequence.delta_energy:E(mutant) - E(wild type); negative values favour the mutant.
method __init__
__init__(
position: 'int',
wild_type: 'str',
mutant: 'str',
sequence: 'str',
delta_energy: 'float'
) → None
property label
Historical, zero-based mutation label used by the CLI.
property position_1based
1-based site of the substitution.
method to_dict
to_dict() → dict[str, Any]
Return the record as a flat dictionary, one row of MutationScanResult.to_dataframe.
class MutationScanResult
All single-site mutants of a sequence, returned by scan_mutations.
Attributes:
wild_type: The scanned sequence.wild_type_energy: Its DCA energy.mutations: OneMutationRecordper mutant, by site then token.model: Metadata of the scoring model.name: Label of the scan, used in file names.warnings: Non-fatal issues found while scoring.
method __init__
__init__(
wild_type: 'str',
wild_type_energy: 'float',
mutations: 'tuple[MutationRecord, ]',
model: 'ModelMetadata',
name: 'str' = 'wild_type',
warnings: 'tuple[str, ]' = ()
) → None
property delta_energies
Energy differences of all mutants, in the order of mutations.
method save
save(path: 'str | Path', format: 'str | None' = None) → Path
Write the result in the format given by format or by the file extension.
Args:
path: Output file.format: One of"csv","fasta"or"json"; inferred from the extension whenNone.
Returns: The written path.
method save_bundle
save_bundle(
directory: 'str | Path',
stem: 'str | None' = None
) → dict[str, Path]
Write the FASTA library, CSV table and JSON summary to directory.
Args:
directory: Output folder.stem: File-name stem; defaults to<name>_DMS.
Returns:
The written paths, keyed by kind (fasta, csv and summary).
method to_csv
to_csv(path: 'str | Path') → Path
Write to_dataframe as CSV.
Args:
path: Output file.
Returns: The written path.
method to_dataframe
to_dataframe() → DataFrame
Return one row per mutant, with 0- and 1-based positions and delta_energy.
method to_dict
to_dict() → dict[str, Any]
Return a JSON-compatible document with the result type and schema version.
method to_fasta
to_fasta(path: 'str | Path') → Path
Write the mutant sequences as FASTA, headers <wt><pos><mut> | DCAscore: <delta>.
Positions in the headers are 0-based, as in adabmDCA dms.
Args:
path: Output file.
Returns: The written path.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write to_dict as JSON.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
class SamplingProgress
Progress event passed to the progress callback of sample_sequences.
Attributes:
stage:"sampling", or a"ptt_*"stage when sampling with PTT.completed: Work done in this phase (sweeps or exchange rounds).total: Work planned for this phase.pearson: Current Cij Pearson correlation with the reference, if measured.slope: Current Cij regression slope, if measured.details: Extra phase-specific values (PTT renewal fractions, ...).
method __init__
__init__(
stage: 'str',
completed: 'int',
total: 'int',
pearson: 'float | None' = None,
slope: 'float | None' = None,
details: 'dict[str, Any]' = <factory>
) → None
class ProfileSplitResult
Training/test split of an alignment, returned by split_alignment.
Attributes:
training: Training alignment.test: Test alignment.score:len(training) * len(test); Cobalt keeps the attempt maximizing it.attempts: Number of attempts made.tokens: Alphabet tokens.seed: Random seed used.method:"cobalt"or"clustering".identity: Sequence-identity threshold of the clustering method.train_fraction: Requested training fraction of the clustering method.
method __init__
__init__(
training: 'Alignment',
test: 'Alignment',
score: 'int',
attempts: 'int',
tokens: 'str',
seed: 'int',
method: 'str' = 'cobalt',
identity: 'float | None' = None,
train_fraction: 'float | None' = None
) → None
method save_bundle
save_bundle(output_prefix: 'str | Path') → dict[str, Path]
Write <prefix>.train.fasta, <prefix>.test.fasta and <prefix>.split.json.
Args:
output_prefix: Path prefix of the three files.
Returns:
The written paths, keyed by kind (training, test and summary).
method to_dict
to_dict() → dict[str, Any]
Return a JSON-compatible document with the result type and schema version.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write to_dict as JSON.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
class SamplingResult
Generated sequences and diagnostics, returned by sample_sequences.
Attributes:
sequences: Generated sequences.energies: DCA energy of each sequence.num_sweeps: Monte Carlo sweeps performed (all replicas, for PTT).sampler: Local sampler used, or"ptt".beta: Inverse temperature.seed: Random seed.model: Metadata of the sampled model.mixing_history: Mixing-time measurements, by quantity.sampling_history: Pearson and slope of the Cij against the reference during generation, when a reference was given.warnings: Non-fatal issues, e.g. an unconverged mixing estimate.sampling_dtype: Precision used for sampling.ptt_diagnostics: PTT only: mixing, renewal and ladder-health diagnostics.cde_sum: Summed context-dependent entropy of each sequence.local_lambda_fit: Least-squares fit of energy againstcde_sum, if identifiable.cij_reference: Reference connected correlations, when diagnostics were collected.cij_generated: Generated connected correlations, when diagnostics were collected.pca_reference: Reference sequences projected on their principal components.pca_generated: Generated sequences projected on the same components.data_comparison: With diagnostics and a reference: the share of data and samples in each cluster of the data (k-means on the principal components) and their energy distributions under the model.distance_comparison: With diagnostics and a reference: Hamming distances (fraction of sites) within and between natural and generated sequences, all pairs and nearest neighbours, plus held-out -> reference and generated -> held-out nearest distances when a test alignment was given;privetholds the PRIVET fit and per-sample scores (also columns ofto_dataframe).pca_explained_variance_ratio: Variance explained by each component.steering_potentials: Steered sampling only:V(x, steering_strength)of each sequence.log_importance_weights: Steered sampling only: log weights that turn averages over these sequences into averages under the unsteered model,<g>_p = mean(exp(log_w) * g). PTT normalizes them with its estimate oflog Z_s - log Z_0; ordinary sampling self-normalizes them to mean 1.steering: Steered sampling only:strength,input, proposal block length and acceptance,effective_sample_sizeof the weights, and for PTTlog_z_ratioand the rungstrengths.ladder_samples: PTT withptt_return_full_ladderonly:sequences(models, n, L)token indices of every ladder model, from the profile (first) to the endpoint (last, the same samples assequences), theirenergies(models, n)under their own model,tokens, themodelsrows ofptt_diagnosticsand, when steered,steering_potentials. Written byto_ladder_hdf5.
method __init__
__init__(
sequences: 'tuple[str, ]',
energies: 'ndarray',
num_sweeps: 'int',
sampler: 'str',
beta: 'float',
seed: 'int',
model: 'ModelMetadata',
mixing_history: 'dict[str, Sequence[float]]' = <factory>,
sampling_history: 'dict[str, Sequence[float]]' = <factory>,
warnings: 'tuple[str, ]' = (),
sampling_dtype: 'str' = 'float32',
ptt_diagnostics: 'dict[str, Any]' = <factory>,
cde_sum: 'ndarray | None' = None,
local_lambda_fit: 'dict[str, float | int] | None' = None,
cij_reference: 'ndarray | None' = None,
cij_generated: 'ndarray | None' = None,
pca_reference: 'ndarray | None' = None,
pca_generated: 'ndarray | None' = None,
pca_explained_variance_ratio: 'ndarray | None' = None,
data_comparison: 'dict[str, Any]' = <factory>,
distance_comparison: 'dict[str, Any]' = <factory>,
steering_potentials: 'ndarray | None' = None,
log_importance_weights: 'ndarray | None' = None,
steering: 'dict[str, Any]' = <factory>,
ladder_samples: 'dict[str, Any] | None' = None
) → None
method save
save(path: 'str | Path', format: 'str | None' = None) → Path
Write the result in the format given by format or by the file extension.
Args:
path: Output file.format: One of"csv","fasta"or"json"; inferred from the extension whenNone.
Returns: The written path.
method save_bundle
save_bundle(
directory: 'str | Path',
label: 'str | None' = None
) → dict[str, Path]
Write samples (FASTA and CSV), a JSON summary and, in logs/, the mixing/sampling logs.
PTT results also get logs/ptt.log and, when available, ladder-health and renewal logs; diagnostics add the data-comparison and distance logs. Results with ladder samples also get <label>_ladder_samples.h5.
Args:
directory: Output folder.label: Optional file-name prefix, giving<label>_samples.fastaetc.
Returns: The written paths by kind.
method save_diagnostic_plots
save_diagnostic_plots(
directory: 'str | Path',
label: 'str | None' = None
) → dict[str, Path]
Save diagnostic plots as PNG files: mixing, Cij scatter, PCA and energy against CDE.
Plots whose data were not collected (see collect_diagnostics of sample_sequences) are skipped.
Args:
directory: Output folder.label: Optional file-name prefix.
Returns: The written paths by plot kind.
method to_csv
to_csv(path: 'str | Path') → Path
Write to_dataframe as CSV.
Args:
path: Output file.
Returns: The written path.
method to_dataframe
to_dataframe() → DataFrame
Return one row per sequence: name, sequence, energy, and cde_sum, steering and PRIVET columns when present.
PRIVET columns are NaN for sequences left out of the comparison (beyond n_measure).
method to_dict
to_dict() → dict[str, Any]
Return a JSON-compatible document with the result type and schema version.
method to_fasta
to_fasta(path: 'str | Path') → Path
Write the sequences as FASTA, with energies in the headers.
Args:
path: Output file.
Returns: The written path.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write to_dict as JSON.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
method to_ladder_hdf5
to_ladder_hdf5(path: 'str | Path') → Path
Write the samples of every PTT ladder model as HDF5.
The file holds sequences (uint8 token indices, (models, n, L)), energies ((models, n), each under its own model) and, when steered, steering_potentials; the models group has one dataset per column of the ladder table (training_step, flag, log_z, log_likelihood, ...), with NaN for missing values. Model 0 is the profile and the last model the endpoint. The root attributes give tokens, n_models and n_sequences.
Args:
path: Output file.
Returns: The written path.
Raises:
OutputSerializationError: If the result has no ladder samples.
class TrainingProgress
One accepted update, passed to the progress callback of train_model.
Attributes:
epoch: Step number of the record (gradient steps, or graph steps for PCD eaDCA/edDCA).metrics: Numeric values of the history row:Pearson,LL_val,Density, ...stage: Current training phase.gradient_steps: Accepted parameter updates so far.structure_steps: Graph activations or decimations so far.sweeps: Monte Carlo sweeps so far.partition_estimate: PTT only: log Z and its provenance.
method __init__
__init__(
epoch: 'int',
metrics: 'dict[str, Any]',
stage: 'str' = 'optimization',
gradient_steps: 'int' = 0,
structure_steps: 'int' = 0,
sweeps: 'int' = 0,
partition_estimate: 'dict[str, Any] | None' = None
) → None
class TrainingDatasetSummary
Size and filtering of one training or validation alignment.
Attributes:
source: Path of the alignment, if read from a file.original_sequences: Sequences in the file.retained_sequences: Sequences kept after filtering.removed_invalid: Sequences dropped for unknown tokens or wrong length.removed_duplicates: Duplicate sequences dropped.sequence_length: Number of sitesL.num_states: Number of statesq.effective_sequences: Sum of the sequence weights (Meff).
method __init__
__init__(
source: 'str | None',
original_sequences: 'int',
retained_sequences: 'int',
removed_invalid: 'int',
removed_duplicates: 'int',
sequence_length: 'int',
num_states: 'int',
effective_sequences: 'float'
) → None
class TrainingInitialization
Resolved training setup, passed to on_initialized of train_model.
Attributes:
training: Summary of the training alignment.validation: Summary of the validation alignment, if any.device: Device used for training.dtype: Precision of the parameters.n_chains: Number of Markov chains.effective_pseudocount: Pseudocount applied to the statistics.config: The validatedTrainingConfig.
method __init__
__init__(
training: 'TrainingDatasetSummary',
validation: 'TrainingDatasetSummary | None',
device: 'str',
dtype: 'str',
n_chains: 'int',
effective_pseudocount: 'float',
config: 'TrainingConfig'
) → None
class TrainingResult
Outcome of train_model.
Attributes:
model: The trainedDCAModel.history: One list per quantity, one entry per recorded update (seehistory_dataframe).chains: Final Markov chains, one-hot, shape(n_chains, L, q).pseudocount: Pseudocount applied to the training statistics.num_sequences: Training sequences after filtering.effective_sequences: Effective number of training sequences (Meff).artifacts: Written files by kind (params,history,ptt_archive, ...).warnings: Non-fatal issues found during training.converged: Whether training stopped at its target (Pearson, density, validation plateau or converged graph) rather than at a step limit.stop_reason: Why training stopped, e.g."target_pearson".gradient_steps: Accepted parameter updates.structure_steps: Graph activations or decimations.sweeps: Monte Carlo sweeps performed.config: The validatedTrainingConfig.input_report: Filtering report of the training alignment.initialization: Resolved setup, seeTrainingInitialization.partition_estimate: PTT only: estimate of log Z for the final model.ptt_sampler: PTT only: the sampler, usable to draw more sequences.
method __init__
__init__(
model: 'DCAModel',
history: 'dict[str, Sequence[float]]',
chains: 'Tensor',
pseudocount: 'float',
num_sequences: 'int',
effective_sequences: 'float',
artifacts: 'dict[str, Path]' = <factory>,
warnings: 'tuple[str, ]' = (),
converged: 'bool' = False,
stop_reason: 'str | None' = None,
gradient_steps: 'int' = 0,
structure_steps: 'int' = 0,
sweeps: 'int' = 0,
config: 'TrainingConfig | None' = None,
input_report: 'dict[str, Any]' = <factory>,
initialization: 'TrainingInitialization | None' = None,
partition_estimate: 'PartitionEstimate | None' = None,
ptt_sampler: 'PTTSampler | None' = None
) → None
property final_metrics
Last value of every history quantity, or an empty mapping before any update.
method history_dataframe
history_dataframe() → DataFrame
Return the history as a DataFrame, one row per recorded update.
method save_bundle
save_bundle(
directory: 'str | Path',
label: 'str | None' = None
) → dict[str, Path]
Write a JSON summary, and the history table unless training already wrote it.
Args:
directory: Output folder.label: Optional file-name prefix.
Returns:
The written paths, keyed by kind (summary and possibly history).
method to_csv
to_csv(path: 'str | Path') → Path
Write the history with the columns and names of history.csv.
Args:
path: Output file.
Returns: The written path.
method to_dict
to_dict() → dict[str, Any]
Return a portable summary without embedding model or chain tensors.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write to_dict as JSON.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
class ReintegrationResult
Outcome of reintegrate_model.
Attributes:
training: Result of training on the combined alignment.alignment: Natural plus experimental sequences used for training.weights: Signed weight of each sequence ofalignment.lambda_value: Weight of the experimental data.scaling_factor: Factor applied to the experimental weights.label: File-name prefix of the written files.artifacts: Written files by kind.
method __init__
__init__(
training: 'TrainingResult',
alignment: 'Alignment',
weights: 'ndarray',
lambda_value: 'float',
scaling_factor: 'float',
label: 'str',
artifacts: 'dict[str, Path]' = <factory>
) → None
method save_bundle
save_bundle(directory: 'str | Path') → dict[str, Path]
Write the combined alignment, its weights and a JSON summary to directory.
Files are named <label>_msa.fasta, <label>_weights.dat and <label>_reintegration.json.
Args:
directory: Output folder.
Returns:
The written paths, keyed by kind (alignment, weights and summary).
method to_dict
to_dict() → dict[str, Any]
Return a JSON-compatible document with the result type and schema version.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write to_dict as JSON.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
class ThermodynamicIntegrationProgress
Progress event passed to the progress callback of estimate_entropy.
Attributes:
stage:"theta_search"while raisingtheta_max, then"integration".completed: Steps done in this stage.total: Largest number of steps of this stage.theta: Current bias strength.entropy: Current entropy estimate (integration stage only).mean_sequence_identity: Mean identity of the chains with the target.
method __init__
__init__(
stage: 'str',
completed: 'int',
total: 'int',
theta: 'float',
entropy: 'float | None' = None,
mean_sequence_identity: 'float | None' = None
) → None
class ThermodynamicIntegrationResult
Outcome of estimate_entropy.
Attributes:
entropy: Estimated model entropy, in nats.free_energy: Free energy attheta = 0from the integration.theta_max: Largest bias strength reached.target_fraction: Fraction of chains matching the target attheta_max.history: Per integration step:theta,free_energy,entropy,mean_sequence_identityandelapsed_seconds.model: Metadata of the model.artifacts: Written files by kind, whenoutput_dirwas given.
method __init__
__init__(
entropy: 'float',
free_energy: 'float',
theta_max: 'float',
target_fraction: 'float',
history: 'dict[str, Sequence[float]]',
model: 'ModelMetadata',
artifacts: 'dict[str, Path]' = <factory>
) → None
method history_dataframe
history_dataframe() → DataFrame
Return the integration history as a DataFrame, one row per step.
method save_bundle
save_bundle(directory: 'str | Path', label: 'str' = 'entropy') → dict[str, Path]
Write <label>.log, <label>.csv and <label>.json to directory.
Args:
directory: Output folder.label: File-name stem.
Returns:
The written paths, keyed by kind (log, csv and summary).
method to_csv
to_csv(path: 'str | Path') → Path
Write the integration history as CSV.
Args:
path: Output file.
Returns: The written path.
method to_dict
to_dict() → dict[str, Any]
Return a JSON-compatible document with the result type and schema version.
method to_json
to_json(path: 'str | Path', indent: 'int' = 2) → Path
Write to_dict as JSON.
Args:
path: Output file.indent: JSON indentation.
Returns: The written path.
method to_log
to_log(path: 'str | Path') → Path
Write the integration history as an aligned, space-separated text table.
Args:
path: Output file.
Returns: The written path.
This file was automatically generated via lazydocs.