Skip to content

Mmseq

Sequence-identity clustering with MMseqs2 easy-cluster.

MMseqsClustering(params)

Bases: Clusterer[MMseqsParams]

MMseqs2 easy-cluster sequence-identity clustering.

Initialize the MMseqs2 clusterer.

PARAMETER DESCRIPTION
params

the MMseqsParams object containing the configuration for the clustering algorithm and output location.

TYPE: MMseqsParams

cluster(sequences)

Cluster sequences by sequence identity with MMseqs2.

PARAMETER DESCRIPTION
sequences

a dictionary with the keys being stable id of the sequence (used for fasta headers) and the values being the sequence string.

TYPE: dict[str, str]

RETURNS DESCRIPTION
ClusterResult

ClusterResult object whose labels and representatives are

ClusterResult

keyed by the keys in sequences.

cluster_fasta(*fasta_paths)

Cluster sequences already on disk as FASTA file(s) instead of in-memory dictionary.

PARAMETER DESCRIPTION
*fasta_paths

One or more paths to FASTA files.

TYPE: str DEFAULT: ()

RETURNS DESCRIPTION
ClusterResult

A ClusterResult object keyed by the FASTA headers (as MMseqs2 parses

ClusterResult

them, i.e. truncated at the first whitespace).

from_cluster_tsv(tsv_path, params)

Build a ClusterResult object from an existing MMseqs2 *_cluster.tsv result.

PARAMETER DESCRIPTION
tsv_path

Path to an MMseqs2 cluster TSV.

TYPE: str

params

The params used to produce it (recorded on the result).

TYPE: MMseqsParams

RETURNS DESCRIPTION
ClusterResult

A ClusterResult object keyed by the ids in the TSV.

MMseqsParams(min_seq_id=0.9, sensitivity=7.0, coverage_mode=0, cluster_mode=0, self_match=True, cluster_reassign=True, sort_results=True, output_dir=None)

Bases: ClusterParams

Parameters for MMseqs2 sequence-identity clustering.

cluster_mode = 0

Cluster mode (--cluster-mode), one of {0, 1, 2, 3}.

cluster_reassign = True

Whether to reassign members to their best cluster after cascaded clustering (--cluster-reassign). Kept as a param because it changes cluster assignment; if you never toggle it, it could instead be an internal constant.

coverage_mode = 0

Coverage mode (--cov-mode), one of {0, 1, 2, 3}.

method = ClusterMethod.MMSEQS2

The clustering method used, which is MMseqs2.

min_seq_id = 0.9

Minimum sequence identity for two sequences to cluster together (--min-seq-id). Must be between 0 and 1; higher values are stricter.

output_dir = None

Directory to write MMseqs2 outputs to. Default is None, which uses a temporary directory that is deleted after clustering. If a path is given, outputs are written there and kept after the run.

self_match = True

Whether to add self-matches (--add-self-matches).

sensitivity = 7.0

Search sensitivity (-s). Higher values find more remote homologs at higher cost. MMseqs2's scale runs 1.0 (faster), 4.0 (fast), to 7.5 (sensitive); accepted range is 1.0–7.5.

sort_results = True

Whether to sort alignment results by sequence identity (--sort-results). It sets the TSV row order that determines integer cluster-id assignment. Defaults is True.

__post_init__()