module adabmDCA.api.splitting
High-level API for homology-aware alignment splitting.
function split_alignment
split_alignment(
alignment: 'AlignmentInput',
method: 'str' = 'clustering',
identity: 'float' = 0.8,
train_fraction: 'float' = 0.8,
t1: 'float' = 0.5,
t2: 'float' = 0.5,
t3: 'float' = 1.0,
max_train: 'int | None' = None,
max_test: 'int | None' = None,
attempts: 'int' = 1,
alphabet: 'str' = 'protein',
seed: 'int' = 0,
device: 'str' = 'auto'
) → ProfileSplitResult
Split an alignment into training and test sets that are not too similar.
method="clustering" clusters sequences at identity (MMseqs2 when installed and there are at least 100 sequences, otherwise a built-in greedy clustering) and assigns whole clusters to the training set until about train_fraction of the sequences are in it. method="cobalt" runs the Cobalt algorithm (Petti and Eddy, 2022), whose thresholds t1-t3 bound the identities between and within the two sets.
Args:
alignment: Alignment to split (path,Alignmentor sequences).method:"clustering"or"cobalt".identity: Clustering: sequence identity, in(0, 1], that joins two sequences into one cluster.train_fraction: Clustering: target fraction of sequences in the training set.t1: Cobalt: no test sequence is more thant1identical to a training sequence.t2: Cobalt: no two test sequences are more thant2identical.t3: Cobalt: no two training sequences are more thant3identical.max_train: Cobalt: largest training set, orNonefor no limit.max_test: Cobalt: largest test set, orNonefor no limit.attempts: Cobalt: random attempts; the one maximizinglen(training) * len(test)is kept.alphabet:"protein","rna","dna"or a custom token string.seed: Random seed.device:"auto","cpu","cuda"or"mps"for identity computations.
Returns:
A ProfileSplitResult with the two alignments.
Raises:
InputValidationError: If a setting is out of range or the alignment has invalid sequences.ConvergenceError: If Cobalt finds no split with both sets non-empty.
Example:
split = split_alignment("family.fasta", alphabet="rna", identity=0.8)
split.save_bundle("splits/family")
This file was automatically generated via lazydocs.