openprotein.align
SDK release/v0.18.0Some tools (e.g. PoET, AlphaFold2) require an MSA to be generated. The tools below will help you achieve this.
Create an alignment, inspect its first few rows, and attach it to a protein:
from itertools import islice
from openprotein.molecules import Protein
sequence = "ACDEFGHIK"
msa = session.align.create_msa(sequence)
for name, aligned_sequence in islice(msa.wait(timeout=600), 3):
print(name, aligned_sequence)
protein = Protein(sequence)
protein.msa = msawait() returns an iterator of (name, aligned_sequence) pairs. Attach the future msa itself; reading the rows is optional. Protein.msa also accepts a stored MSA handle or an ID. For a single-sequence model, protein.msa = Protein.single_sequence_mode explicitly selects no MSA; do not use that sentinel in place of an alignment for an MSA-requiring model. Model support varies.
For prompt sampling, MSAFuture.sample_prompt uses num_sequences and num_residues; session.data.prompts.sample_msa calls the corresponding limits max_msa_sequences and max_msa_tokens. Their defaults and validation differ.
12source
Align API interface for creating alignments and MSAs (multiple sequence alignments) which can be used for other protein tasks.
sessionAPISessionmethodmafft(sequences, names=None, auto=True, ep=None, op=None)→MSAFuturesource
Align sequences using the mafft algorithm.
Set auto to True to automatically attempt the best parameters. Leave a parameter as None to use system defaults.
sequencesSequence[bytes or str]Sequences to align.
namesSequence[str]= NoneRow labels for the aligned output, same length as sequences. Omit them and the aligner labels the rows itself.
autobool= TrueSet to True to automatically set algorithm parameters.
epfloat= NoneMAFFT "ep" parameter. Sets the offset value for the scoring matrix; lower values make gap opening more difficult. If None, uses system default.
opfloat= NoneMAFFT "op" parameter. Sets the gap opening penalty; higher values increase the cost of opening gaps. If None, uses system default.
Future object awaiting the contents of the MSA upload.
methodmafft_file(file, auto=True, ep=None, op=None)→MSAFuturesource
Align sequences from a file using the mafft algorithm.
Deprecated since 0.18.0:
Use AlignAPI.mafft with sequences and names instead.
Sequences can be provided as FASTA or CSV formats. If CSV, the file must be headerless with either a single sequence column or name, sequence columns.
Set auto to True to automatically attempt the best parameters. Leave a parameter as None to use system defaults.
filefile-like object, bytes, bytearray, str, tuple or listSequences to align in FASTA or CSV format. A tuple or list is
(filename, fileobj) or (filename, fileobj, content_type).
autobool= TrueSet to True to automatically set algorithm parameters.
epfloat= NoneMAFFT "ep" parameter. Sets the offset value for the scoring matrix; lower values make gap opening more difficult. If None, uses system default.
opfloat= NoneMAFFT "op" parameter. Sets the gap opening penalty; higher values increase the cost of opening gaps. If None, uses system default.
Future object awaiting the contents of the MSA upload.
If the file has no sequences or a CSV has more than two columns.
methodclustalo(sequences, names=None, clustersize=None, iterations=None)→MSAFuturesource
Align sequences using the clustal omega algorithm.
sequencesSequence[bytes or str]Sequences to align.
namesSequence[str]= NoneRow labels for the aligned output, same length as sequences. Omit them and the aligner labels the rows itself.
clustersizeint= NoneMaximum number of sequences per cluster during guide tree generation. If None, uses the default value.
iterationsint= NoneNumber of refinement iterations performed during alignment. If None, uses the default value.
Future object awaiting the contents of the MSA upload.
methodclustalo_file(file, clustersize=None, iterations=None)→MSAFuturesource
Align sequences from a file using the clustal omega algorithm.
Deprecated since 0.18.0:
Use AlignAPI.clustalo with sequences and names instead.
Sequences can be provided as FASTA or CSV formats. If CSV, the file must be headerless with either a single sequence column or name, sequence columns.
filefile-like object, bytes, bytearray, str, tuple or listSequences to align in FASTA or CSV format. A tuple or list is
(filename, fileobj) or (filename, fileobj, content_type).
clustersizeint= NoneMaximum number of sequences per cluster during guide tree generation. If None, uses the default value.
iterationsint= NoneNumber of refinement iterations performed during alignment. If None, uses the default value.
Future object awaiting the contents of the MSA upload.
If the file has no sequences or a CSV has more than two columns.
methodabnumber(sequences, names=None, scheme=AbNumberScheme.CHOTHIA, drop_minority_chains=False, unnumbered_policy=UnnumberedPolicy.ERROR)→MSAFuturesource
Align antibody sequences using AbNumber.
The antibody numbering scheme can be specified.
sequencesSequence[bytes or str]Sequences to align.
namesSequence[str]= NoneRow labels for the aligned output, same length as sequences. Omit them and the aligner labels the rows itself.
Antibody numbering scheme.
drop_minority_chainsbool= FalseIf True, drop sequences belonging to chain types that are in the minority (e.g. heavy vs light) so the resulting alignment contains only the dominant chain type.
What to do with residues outside the numbered variable domain -- a constant/Fc region, an N-terminal tag. ERROR fails the job, DROP aligns the numbered residues only, RETAIN keeps them padded against the numbered-domain boundary.
Future object awaiting the contents of the MSA upload.
methodabnumber_file(file, scheme=AbNumberScheme.CHOTHIA, drop_minority_chains=False, unnumbered_policy=UnnumberedPolicy.ERROR)→MSAFuturesource
Align antibody sequences from a file using AbNumber.
Deprecated since 0.18.0:
Use AlignAPI.abnumber with sequences and names instead.
Sequences can be provided as FASTA or CSV formats. If CSV, the file must be headerless with either a single sequence column or name, sequence columns.
filefile-like object, bytes, bytearray, str, tuple or listSequences to align in FASTA or CSV format. A tuple or list is
(filename, fileobj) or (filename, fileobj, content_type).
Antibody numbering scheme.
drop_minority_chainsbool= FalseIf True, drop sequences belonging to chain types that are in the minority (e.g. heavy vs light) so the resulting alignment contains only the dominant chain type.
What to do with residues outside the numbered variable domain -- a constant/Fc region, an N-terminal tag. ERROR fails the job, DROP aligns the numbered residues only, RETAIN keeps them padded against the numbered-domain boundary.
Future object awaiting the contents of the MSA upload.
If the file has no sequences or a CSV has more than two columns.
methodupload_msa(msa_file)→MSAFuturesource
Upload a ready-made MSA.
Deprecated since 0.18.0:
Use session.data.msa.create and session.data.prompts.sample_msa
instead.
The returned future samples prompts with sample_prompt. For a
complex, join the chains of each row with :, or use the a3m
#<lengths> <cardinalities> header.
msa_fileBinaryIOThe MSA as FASTA, a3m or a headerless CSV of names and sequences.
Future for the upload.
If there is an issue with the API request.
methodcreate_msa(seed, pairing=Pairing.BOTH)→MSAFuturesource
Construct an MSA via homology search with the seed sequence.
seedbytesSeed sequence for the MSA construction.
Cross-chain pairing strategy for a complex (:-separated) seed;
has no effect on a single-chain seed. Defaults to both.
Future object awaiting the contents of the MSA upload.
If there is an issue with the API request.
methodupload_prompt(prompt_file)source
Directly upload a prompt.
This method is deprecated. Use create_prompt on the prompt module instead.
prompt_fileBinaryIOBinary I/O object representing the prompt file.
An object representing the status and results of the prompt job.
Always. Use create_prompt on the prompt module instead.
methodget_prompt(job, prompt_index=None)→Iterator[list[str]]source
Get prompts for a given job.
This method is deprecated. Use get_prompt on the prompt module instead.
jobJobThe job for which to retrieve data.
prompt_indexint= NoneThe replicate number for the prompt (input_type=-PROMPT only).
An iterator over rows of the prompt data.
Always. Use get_prompt on the prompt module instead.
AbNumber supports the following schemes:
4source
Bases: str, Enum
Antibody numbering scheme.
attributeIMGT= 'imgt'source
IMGT numbering scheme, a standardized system unifying numbering across all immunoglobulin and T-cell receptor variable domains.
attributeCHOTHIA= 'chothia'source
Chothia numbering scheme, based on the structural location of canonical loops in antibody variable domains.
attributeKABAT= 'kabat'source
Kabat numbering scheme, based on sequence variability across antibody variable domains.
attributeAHO= 'aho'source
AHo numbering scheme, a structure-based unified numbering scheme for antibody variable domains.
3source
Bases: str, Enum
What to do with residues the numbering scheme gives no antibody position.
ANARCI numbers one variable domain per sequence. Residues outside it -- a constant/Fc region, an N-terminal tag -- have no antibody position and cannot share the numbering coordinate system.
attributeERROR= 'error'source
Fail the job if any sequence carries unnumbered residues.
attributeDROP= 'drop'source
Align the numbered residues only, discarding the rest.
attributeRETAIN= 'retain'source
Keep the unnumbered residues, padded against the numbered-domain boundary. They are preserved, not aligned to each other.
5source
Bases: str, Enum
Enumeration of MSA sampling methods.
attributeRANDOM= 'RANDOM'source
Random sampling.
attributeNEIGHBORS= 'NEIGHBORS'source
Sampling based on neighbors.
attributeNEIGHBORS_NO_LIMIT= 'NEIGHBORS_NO_LIMIT'source
Neighbor sampling without limit.
attributeNEIGHBORS_NONGAP_NORM_NO_LIMIT= 'NEIGHBORS_NONGAP_NORM_NO_LIMIT'source
Neighbor sampling without gap normalization and without limit.
attributeTOP= 'TOP'source
Top scoring sampling.
3source
Bases: BaseModel
Something a job reports about its own output while still succeeding.
attributecode:strsource
Machine-readable identifier, e.g. UNNUMBERED_RESIDUES_DROPPED.
attributemessage:strsource
Human-readable description.
attributemetadata:dict | None= Nonesource
Code-specific detail. For the unnumbered-residue codes this carries a
chains list, one entry per affected chain position.
4source
Bases: AlignFuture, Future
Represents a future for MSA (Multiple Sequence Alignment) results.
methodget_antibody_schema()→dictsource
Retrieve the antibody numbering for an AbNumber job.
One chains entry per chain position, carrying that position's
numbering, CDR regions and chain type, plus a warnings list.
If the job did not use AbNumber.
methodget_warnings()→list[JobWarning]source
Retrieve what the job reported about its own output.
A job that succeeds can still have changed the data, e.g. by dropping residues AbNumber could not number.
Empty if the job had nothing to report.
methodsample_prompt(num_sequences=None, num_residues=None, method=MSASamplingMethod.NEIGHBORS_NONGAP_NORM_NO_LIMIT, homology_level=0.8, max_similarity=1.0, min_similarity=0.0, always_include_seed_sequence=False, num_ensemble_prompts=1, random_seed=None)→Promptsource
Create a protein sequence prompt from the linked MSA for PoET Jobs.
num_sequencesint= NoneMaximum number of sequences in the prompt. Must be less than 100.
num_residuesint= NoneMaximum number of residues (tokens) in the prompt. Must be less than 24577.
Method to use for MSA sampling. Defaults to NEIGHBORS_NONGAP_NORM_NO_LIMIT.
homology_levelfloat= 0.8Level of homology for sequences in the MSA (neighbors methods only). Must be between 0 and 1. Defaults to 0.8.
max_similarityfloat= 1.0Maximum similarity between sequences in the MSA and the seed. Must be between 0 and 1. Defaults to 1.0.
min_similarityfloat= 0.0Minimum similarity between sequences in the MSA and the seed. Must be between 0 and 1. Defaults to 0.0.
always_include_seed_sequencebool= FalseWhether to always include the seed sequence in the MSA. Defaults to False.
num_ensemble_promptsint= 1Number of ensemble jobs to run. Defaults to 1.
random_seedint= NoneSeed for random number generation. Defaults to a random number between 0 and 2**32-1.
If provided parameter values are not in the allowed range.
If both or none of 'num_sequences' and 'num_residues' are specified.
A Prompt instance for the created prompt job.
methodget(verbose=False, **kwargs)→Iterator[tuple[str, str]]source
inherited from openprotein.jobs.Future
Retrieve the MSA of the job.
verbosebool= FalseWhether to print verbose output. Defaults to False.
An iterator over names and sequences of the MSA data.
3source
A future object representing an alignment job, providing methods to retrieve job inputs and seed sequences.
methodget_input(input_type)source
Retrieve input data for this alignment job.
input_typeAlignTypeThe type of input data to retrieve.
An iterator over the input data rows.
methodget_seed()source
Retrieve the seed sequence for this alignment job.
The seed sequence.
propertyidsource
The job ID for this alignment job.
The job ID.
Types referenced by the interfaces above.
3source
Bases: str, Enum
Cross-chain pairing strategy for a complex (multi-chain) MSA search.
Has no effect on a single-chain query.