Protein
Protein-related classes and subpackages.
Defines the Protein class, representing proteins with main and side chains, including sequence validation and chain initialization.
- class protein.protein.Protein(main_protein_sequence, side_protein_sequence, valid_symbols)
Bases:
objectRepresents a protein with main and side chains.
The main chain is defined as a sequence of amino acid residues. Side chains are optional and can be empty; if present, they follow the same residue types. Side chains cannot be attached to the first or last main bead.
- Variables:
main_chain (_MainChain) – The main chain of the protein.
side_chain (_SideChain) – The optional side chain of the protein.
- __init__(main_protein_sequence, side_protein_sequence, valid_symbols)
Initialize a Protein instance with given main and side chain sequences.
Validates that both sequences have the same length and initializes the corresponding chain objects.
- Parameters:
main_protein_sequence (str) – Sequence of residues for the main chain.
side_protein_sequence (str) – Sequence of residues for the side chain.
valid_symbols (set[str]) – Set of valid amino acid symbols for the protein (This information comes from the interaction model).
- Raises:
ChainLengthError – If main and side chain sequences are not of the same length.
Subpackage: bead
Bead abstraction for quantum protein folding.
Defines the base class Bead, representing a single amino acid in the peptide chain and responsible for constructing turn-related quantum operators used in the folding model.
- class protein.bead.bead.Bead(symbol, index, parent_chain_len)
Bases:
ABCAn abstract class defining a bead of a peptide.
- Variables:
symbol (str) – One-letter amino acid symbol.
index (int) – Position of the bead in the parent chain.
turn_qubits (tuple[SparsePauliOp, ...]) – Quantum turn qubits associated with this bead.
sublattice (SubLattice) – Sublattice type (A or B) based on bead index.
- __init__(symbol, index, parent_chain_len)
Initialize a bead instance.
Sets symbol, index, sublattice type, and initializes turn qubits if applicable.
- Parameters:
symbol (str) – One-letter amino acid symbol.
index (int) – Position of the bead in the parent chain.
parent_chain_len (int) – Total number of beads in the parent chain.
- _abc_impl = <_abc._abc_data object>
- _initialize_turn_qubits()
Initializes the quantum turn qubits associated with this bead based on the selected conformation encoding.
For each bead (except the last in the chain), the function builds a set of Pauli operators representing directional turns in the protein structure. The number of initialized qubits depends on whether the encoding is dense or sparse.
- Return type:
None- Raises:
ConformationEncodingError – If conformation encoding or qubit count is not set.
- abstractmethod turn_0()
Return Pauli operator representing turn in direction 0.
- Return type:
SparsePauliOp
- abstractmethod turn_1()
Return Pauli operator representing turn in direction 1.
- Return type:
SparsePauliOp
- abstractmethod turn_2()
Return Pauli operator representing turn in direction 2.
- Return type:
SparsePauliOp
- abstractmethod turn_3()
Return Pauli operator representing turn in direction 3.
- Return type:
SparsePauliOp
- turn_funcs()
Return Pauli operators representing directional turns.
- Return type:
None|tuple[SparsePauliOp,SparsePauliOp,SparsePauliOp,SparsePauliOp]- Returns:
Tuple of Pauli operators for turns (0-3), or None if no turn qubits exist.
- Return type:
tuple[SparsePauliOp, SparsePauliOp, SparsePauliOp, SparsePauliOp] | None
Module defining the _MainBead class for protein backbone representation.
- class protein.bead.main_bead._MainBead(symbol, index, parent_chain_len)
Bases:
BeadRepresents a main bead in the protein’s backbone.
- __init__(symbol, index, parent_chain_len)
Initialize the main bead and set up its turn qubits.
- Parameters:
symbol (str) – Amino acid symbol.
index (int) – Position of the bead in the chain.
parent_chain_len (int) – Total number of beads in the parent chain.
- _abc_impl = <_abc._abc_data object>
- _dense_turn_fun_0()
Compute the dense encoding operator for direction 0.
- Return type:
SparsePauliOp- Returns:
Dense-encoded Pauli operator for direction 0.
- Return type:
SparsePauliOp
- _dense_turn_fun_1()
Compute the dense encoding operator for direction 1.
- Return type:
SparsePauliOp- Returns:
Dense-encoded Pauli operator for direction 1.
- Return type:
SparsePauliOp
- _dense_turn_fun_2()
Compute the dense encoding operator for direction 2.
- Return type:
SparsePauliOp- Returns:
Dense-encoded Pauli operator for direction 2.
- Return type:
SparsePauliOp
- _dense_turn_fun_3()
Compute the dense encoding operator for direction 3.
- Return type:
SparsePauliOp- Returns:
Dense-encoded Pauli operator for direction 3.
- Return type:
SparsePauliOp
- turn_0()
Return the Pauli operator for the turn in direction 0.
- Return type:
SparsePauliOp- Returns:
Pauli operator representing direction 0.
- Return type:
SparsePauliOp
- Raises:
ConformationEncodingError – If the conformation encoding is invalid.
- turn_1()
Return the Pauli operator for the turn in direction 1.
- Return type:
SparsePauliOp- Returns:
Pauli operator representing direction 1.
- Return type:
SparsePauliOp
- Raises:
ConformationEncodingError – If the conformation encoding is invalid.
- turn_2()
Return the Pauli operator for the turn in direction 2.
- Return type:
SparsePauliOp- Returns:
Pauli operator representing direction 2.
- Return type:
SparsePauliOp
- Raises:
ConformationEncodingError – If the conformation encoding is invalid.
- turn_3()
Return the Pauli operator for the turn in direction 3.
- Return type:
SparsePauliOp- Returns:
Pauli operator representing direction 3.
- Return type:
SparsePauliOp
- Raises:
ConformationEncodingError – If the conformation encoding is invalid.
Module defining the _SideBead class for protein side bead representation.
- class protein.bead.side_bead._SideBead(_symbol, _index, _parent_chain_len)
Bases:
BeadRepresents a side bead attached to a protein’s main chain.
- __init__(_symbol, _index, _parent_chain_len)
Initialize a side bead with its symbol and position in the chain.
- Parameters:
symbol (str) – Amino acid symbol representing the side bead.
index (int) – Position of the bead in the chain.
parent_chain_len (int) – Total number of beads in the parent chain.
- _abc_impl = <_abc._abc_data object>
- turn_0()
Return the Pauli operator for a turn in direction 0.
- Return type:
SparsePauliOp- Raises:
NotImplementedError – Always raised since side bead turns are not implemented.
- turn_1()
Return the Pauli operator for a turn in direction 1.
- Return type:
SparsePauliOp- Raises:
NotImplementedError – Always raised since side bead turns are not implemented.
- turn_2()
Return the Pauli operator for a turn in direction 2.
- Return type:
SparsePauliOp- Raises:
NotImplementedError – Always raised since side bead turns are not implemented.
- turn_3()
Return the Pauli operator for a turn in direction 3.
- Return type:
SparsePauliOp- Raises:
NotImplementedError – Always raised since side bead turns are not implemented.
Module defining the _PlaceholderSideBead class for representing empty side beads in protein structures.
- class protein.bead.placeholder_side_bead._PlaceholderSideBead(symbol, index, parent_chain_len)
Bases:
BeadRepresents a empty side bead - not attached to a protein’s main chain, used as a placeholder for storing empty symbols and padding.
- Variables:
symbol (str) – Empty symbol.
index (int) – Position of the bead in the side chain.
parent_chain_len (int) – Total number of beads in the parent chain.
- __init__(symbol, index, parent_chain_len)
Initialize the placeholder side bead.
Note
Placeholder side beads do not have turn qubit operators. Any attempt to access them will raise NotImplementedError. Symbol of the placeholder bead is set to EMPTY_SIDECHAIN_PLACEHOLDER constant, as initialized in SideChain. The “parent_chain_len” arg is used for consistency with other bead types, although it has no functional impact on placeholder beads.
- Parameters:
symbol (str) – Empty symbol.
index (int) – Position of the bead in the side chain.
parent_chain_len (int) – Total number of beads in the parent chain.
- _abc_impl = <_abc._abc_data object>
- turn_0()
Return the Pauli operator for a turn in direction 0.
- Return type:
SparsePauliOp- Raises:
NotImplementedError – Always raised since placeholder side beads do not have turn qubits.
- turn_1()
Return the Pauli operator for a turn in direction 1.
- Return type:
SparsePauliOp- Raises:
NotImplementedError – Always raised since placeholder side beads do not have turn qubits.
- turn_2()
Return the Pauli operator for a turn in direction 2.
- Return type:
SparsePauliOp- Raises:
NotImplementedError – Always raised since placeholder side beads do not have turn qubits.
- turn_3()
Return the Pauli operator for a turn in direction 3.
- Return type:
SparsePauliOp- Raises:
NotImplementedError – Always raised since placeholder side beads do not have turn qubits.
Subpackage: chain
Base abstraction for protein chains.
Provides the abstract Chain class, representing a sequence of Bead objects and defining common operations such as indexing, iteration, and string conversion.
- class protein.chain.chain.Chain(protein_sequence)
Bases:
ABCAbstract base class for protein chains, defining shared behavior for all chain types.
- Variables:
beads (list[Bead]) – List of beads comprising the protein chain.
- __init__(protein_sequence)
Initialize the chain with an empty list of beads.
- Parameters:
protein_sequence (str) – The amino acid sequence representing the protein chain.
- _abc_impl = <_abc._abc_data object>
- abstractmethod _initialize_beads(protein_sequence)
Abstract method to initialize beads based on the protein sequence.
This method should be implemented by subclasses to populate the beads attribute.
- Return type:
None- Parameters:
protein_sequence (str) – The amino acid sequence representing the protein chain.
- get_symbol_at(index)
Return the symbol of the bead at the given chain index.
- Return type:
str- Parameters:
index (int) – Index of the bead in the chain.
- Returns:
The symbol of the bead located at the specified index.
- Return type:
str
Defines the MainChain class for representing the main chain of a protein.
- class protein.chain.main_chain._MainChain(protein_sequence)
Bases:
ChainRepresents the main chain of a protein, a linear sequence of amino acids forming its backbone.
- Variables:
beads (list[_MainBead]) – List of main beads in the protein’s backbone.
- __init__(protein_sequence)
Initialize the main chain with beads corresponding to the protein sequence.
- Parameters:
protein_sequence (str) – Amino acid sequence of the protein backbone.
- _abc_impl = <_abc._abc_data object>
- _initialize_beads(protein_sequence)
Initialize main beads (_MainBead) based on the protein sequence.
- Return type:
None- Parameters:
protein_sequence (str) – The amino acid sequence representing the protein chain.
Defines the SideChain class for representing the side chain of a protein.
- class protein.chain.side_chain._SideChain(protein_sequence)
Bases:
ChainRepresents the side chain of a protein, consisting of amino acids attached to residues of the main chain.
- Variables:
beads (list[_SideBead | _PlaceholderSideBead]) – List of side beads in the protein’s side chain.
- __init__(protein_sequence)
Initialize the side chain with beads corresponding to the protein sequence.
If a bead symbol matches the EMPTY_SIDECHAIN_PLACEHOLDER, a PlaceholderSideBead is created instead.
- Parameters:
protein_sequence (str) – Amino acid sequence of the protein side chain.
- _abc_impl = <_abc._abc_data object>
- _initialize_beads(protein_sequence)
Initialize side beads (_SideBead) and placeholder side beads (_PlaceholderSideBead) based on the protein sequence.
- Return type:
None- Parameters:
protein_sequence (str) – The amino acid sequence representing the protein chain.