Sequences, pairs, and results¶
- protspect.transforms.transform_sequence(sequence, embedding=mappingproxy({'A': mappingproxy({'A': 8, 'R': -3, 'N': -4, 'D': -5, 'C': -2, 'Q': -2, 'E': -3, 'G': -1, 'H': -4, 'I': -4, 'L': -4, 'K': -2, 'M': -3, 'F': -5, 'P': -2, 'S': 1, 'T': -1, 'W': -6, 'Y': -5, 'V': -2}), 'R': mappingproxy({'A': -3, 'R': 10, 'N': -2, 'D': -5, 'C': -8, 'Q': 0, 'E': -2, 'G': -6, 'H': -1, 'I': -7, 'L': -6, 'K': 3, 'M': -4, 'F': -6, 'P': -5, 'S': -3, 'T': -3, 'W': -7, 'Y': -5, 'V': -6}), 'N': mappingproxy({'A': -4, 'R': -2, 'N': 11, 'D': 1, 'C': -5, 'Q': -1, 'E': -2, 'G': -2, 'H': 0, 'I': -7, 'L': -7, 'K': -1, 'M': -5, 'F': -7, 'P': -5, 'S': 0, 'T': -1, 'W': -8, 'Y': -5, 'V': -7}), 'D': mappingproxy({'A': -5, 'R': -5, 'N': 1, 'D': 10, 'C': -8, 'Q': -2, 'E': 2, 'G': -4, 'H': -3, 'I': -8, 'L': -8, 'K': -3, 'M': -8, 'F': -8, 'P': -5, 'S': -2, 'T': -4, 'W': -10, 'Y': -7, 'V': -8}), 'C': mappingproxy({'A': -2, 'R': -8, 'N': -5, 'D': -8, 'C': 14, 'Q': -7, 'E': -9, 'G': -7, 'H': -8, 'I': -3, 'L': -5, 'K': -8, 'M': -4, 'F': -4, 'P': -8, 'S': -3, 'T': -3, 'W': -7, 'Y': -6, 'V': -3}), 'Q': mappingproxy({'A': -2, 'R': 0, 'N': -1, 'D': -2, 'C': -7, 'Q': 11, 'E': 2, 'G': -5, 'H': 1, 'I': -6, 'L': -5, 'K': 2, 'M': -2, 'F': -6, 'P': -4, 'S': -2, 'T': -3, 'W': -5, 'Y': -4, 'V': -5}), 'E': mappingproxy({'A': -3, 'R': -2, 'N': -2, 'D': 2, 'C': -9, 'Q': 2, 'E': 10, 'G': -6, 'H': -2, 'I': -7, 'L': -7, 'K': 0, 'M': -5, 'F': -8, 'P': -4, 'S': -2, 'T': -3, 'W': -8, 'Y': -7, 'V': -5}), 'G': mappingproxy({'A': -1, 'R': -6, 'N': -2, 'D': -4, 'C': -7, 'Q': -5, 'E': -6, 'G': 9, 'H': -6, 'I': -9, 'L': -8, 'K': -5, 'M': -7, 'F': -8, 'P': -6, 'S': -2, 'T': -5, 'W': -7, 'Y': -8, 'V': -8}), 'H': mappingproxy({'A': -4, 'R': -1, 'N': 0, 'D': -3, 'C': -8, 'Q': 1, 'E': -2, 'G': -6, 'H': 13, 'I': -7, 'L': -6, 'K': -3, 'M': -5, 'F': -4, 'P': -5, 'S': -3, 'T': -4, 'W': -5, 'Y': 1, 'V': -7}), 'I': mappingproxy({'A': -4, 'R': -7, 'N': -7, 'D': -8, 'C': -3, 'Q': -6, 'E': -7, 'G': -9, 'H': -7, 'I': 8, 'L': 2, 'K': -6, 'M': 1, 'F': -2, 'P': -7, 'S': -5, 'T': -3, 'W': -6, 'Y': -4, 'V': 4}), 'L': mappingproxy({'A': -4, 'R': -6, 'N': -7, 'D': -8, 'C': -5, 'Q': -5, 'E': -7, 'G': -8, 'H': -6, 'I': 2, 'L': 8, 'K': -6, 'M': 3, 'F': 0, 'P': -7, 'S': -6, 'T': -4, 'W': -5, 'Y': -4, 'V': 0}), 'K': mappingproxy({'A': -2, 'R': 3, 'N': -1, 'D': -3, 'C': -8, 'Q': 2, 'E': 0, 'G': -5, 'H': -3, 'I': -6, 'L': -6, 'K': 10, 'M': -4, 'F': -6, 'P': -3, 'S': -2, 'T': -3, 'W': -8, 'Y': -5, 'V': -5}), 'M': mappingproxy({'A': -3, 'R': -4, 'N': -5, 'D': -8, 'C': -4, 'Q': -2, 'E': -5, 'G': -7, 'H': -5, 'I': 1, 'L': 3, 'K': -4, 'M': 12, 'F': -1, 'P': -5, 'S': -4, 'T': -2, 'W': -4, 'Y': -5, 'V': 0}), 'F': mappingproxy({'A': -5, 'R': -6, 'N': -7, 'D': -8, 'C': -4, 'Q': -6, 'E': -8, 'G': -8, 'H': -4, 'I': -2, 'L': 0, 'K': -6, 'M': -1, 'F': 11, 'P': -7, 'S': -5, 'T': -5, 'W': 0, 'Y': 4, 'V': -3}), 'P': mappingproxy({'A': -2, 'R': -5, 'N': -5, 'D': -5, 'C': -8, 'Q': -4, 'E': -4, 'G': -6, 'H': -5, 'I': -7, 'L': -7, 'K': -3, 'M': -5, 'F': -7, 'P': 12, 'S': -3, 'T': -4, 'W': -8, 'Y': -7, 'V': -6}), 'S': mappingproxy({'A': 1, 'R': -3, 'N': 0, 'D': -2, 'C': -3, 'Q': -2, 'E': -2, 'G': -2, 'H': -3, 'I': -5, 'L': -6, 'K': -2, 'M': -4, 'F': -5, 'P': -3, 'S': 9, 'T': 2, 'W': -7, 'Y': -5, 'V': -4}), 'T': mappingproxy({'A': -1, 'R': -3, 'N': -1, 'D': -4, 'C': -3, 'Q': -3, 'E': -3, 'G': -5, 'H': -4, 'I': -3, 'L': -4, 'K': -3, 'M': -2, 'F': -5, 'P': -4, 'S': 2, 'T': 9, 'W': -7, 'Y': -5, 'V': -1}), 'W': mappingproxy({'A': -6, 'R': -7, 'N': -8, 'D': -10, 'C': -7, 'Q': -5, 'E': -8, 'G': -7, 'H': -5, 'I': -6, 'L': -5, 'K': -8, 'M': -4, 'F': 0, 'P': -8, 'S': -7, 'T': -7, 'W': 17, 'Y': 2, 'V': -5}), 'Y': mappingproxy({'A': -5, 'R': -5, 'N': -5, 'D': -7, 'C': -6, 'Q': -4, 'E': -7, 'G': -8, 'H': 1, 'I': -4, 'L': -4, 'K': -5, 'M': -5, 'F': 4, 'P': -7, 'S': -5, 'T': -5, 'W': 2, 'Y': 12, 'V': -5}), 'V': mappingproxy({'A': -2, 'R': -6, 'N': -7, 'D': -8, 'C': -3, 'Q': -5, 'E': -5, 'G': -8, 'H': -7, 'I': 4, 'L': 0, 'K': -5, 'M': 0, 'F': -3, 'P': -6, 'S': -4, 'T': -1, 'W': -5, 'Y': -5, 'V': 8})}), *, method='fourier', transform=None, length=None, normalization='none', center=False, radius=1.0, mellin_c=0.0, wavelet='db2', level=None, mode='symmetric')[source]¶
Embed a protein sequence and transform each channel on a fixed grid.
- Parameters:
sequence (str) – Nonempty residue sequence; all residues must occur in every channel.
embedding (mapping) – Channel-to-residue mappings, including AAindex and Kidera mappings.
method ({'fourier', 'z', 'mellin', 'wavelet'}) – Fourier uses shifted DFT bins. Z evaluates sum x[n] z**(-n) at z=radius*exp(2*pi*i*f), n starting at zero. Mellin uses the finite sum sum x[n]*(n+1)**(c-1-2*pi*i*nu), n starting at zero. It is a unit-spacing quadrature convention on positive positions, not an exact continuous transform or an assertion of sequence-length invariance.
length (int, optional) – Shared padded signal length, at least the residue count; defaults to the next power of two. Never truncate sequences. Mellin uses only real residue positions; length fixes its common log-frequency grid.
normalization (str) – ‘none’, ‘length’, ‘sqrt_length’, or ‘energy’, applied before padding.
center (bool) – Subtract each channel’s mean over real residues before normalization.
radius (float) – Positive finite Z-plane radius. One reproduces Fourier; smaller radii emphasize later residues and may overflow on long sequences.
mellin_c (float) – Real part of the Mellin contour. Positive positions are measured from the N terminus in residue units; reversing/shifting changes results.
wavelet (str) – Discrete PyWavelets wavelet name; requires Protspect[wavelets].
level (int, optional) – Decomposition depth, bounded by dwt_max_level of the padded grid. None uses that maximum; zero returns the undecomposed padded signal.
mode (str) – PyWavelets boundary extension mode, applied after explicit zero-padding.
- Returns:
Raw coefficients, coordinates, and provenance. features exports selected coefficients and/or within-channel products. cross(other) forms ordered paired products. No selector is implicitly applied. The previous
transform=spelling remains a compatibility alias for method.- Return type:
- protspect.transforms.transform_pair(first, second, embedding=mappingproxy({'A': mappingproxy({'A': 8, 'R': -3, 'N': -4, 'D': -5, 'C': -2, 'Q': -2, 'E': -3, 'G': -1, 'H': -4, 'I': -4, 'L': -4, 'K': -2, 'M': -3, 'F': -5, 'P': -2, 'S': 1, 'T': -1, 'W': -6, 'Y': -5, 'V': -2}), 'R': mappingproxy({'A': -3, 'R': 10, 'N': -2, 'D': -5, 'C': -8, 'Q': 0, 'E': -2, 'G': -6, 'H': -1, 'I': -7, 'L': -6, 'K': 3, 'M': -4, 'F': -6, 'P': -5, 'S': -3, 'T': -3, 'W': -7, 'Y': -5, 'V': -6}), 'N': mappingproxy({'A': -4, 'R': -2, 'N': 11, 'D': 1, 'C': -5, 'Q': -1, 'E': -2, 'G': -2, 'H': 0, 'I': -7, 'L': -7, 'K': -1, 'M': -5, 'F': -7, 'P': -5, 'S': 0, 'T': -1, 'W': -8, 'Y': -5, 'V': -7}), 'D': mappingproxy({'A': -5, 'R': -5, 'N': 1, 'D': 10, 'C': -8, 'Q': -2, 'E': 2, 'G': -4, 'H': -3, 'I': -8, 'L': -8, 'K': -3, 'M': -8, 'F': -8, 'P': -5, 'S': -2, 'T': -4, 'W': -10, 'Y': -7, 'V': -8}), 'C': mappingproxy({'A': -2, 'R': -8, 'N': -5, 'D': -8, 'C': 14, 'Q': -7, 'E': -9, 'G': -7, 'H': -8, 'I': -3, 'L': -5, 'K': -8, 'M': -4, 'F': -4, 'P': -8, 'S': -3, 'T': -3, 'W': -7, 'Y': -6, 'V': -3}), 'Q': mappingproxy({'A': -2, 'R': 0, 'N': -1, 'D': -2, 'C': -7, 'Q': 11, 'E': 2, 'G': -5, 'H': 1, 'I': -6, 'L': -5, 'K': 2, 'M': -2, 'F': -6, 'P': -4, 'S': -2, 'T': -3, 'W': -5, 'Y': -4, 'V': -5}), 'E': mappingproxy({'A': -3, 'R': -2, 'N': -2, 'D': 2, 'C': -9, 'Q': 2, 'E': 10, 'G': -6, 'H': -2, 'I': -7, 'L': -7, 'K': 0, 'M': -5, 'F': -8, 'P': -4, 'S': -2, 'T': -3, 'W': -8, 'Y': -7, 'V': -5}), 'G': mappingproxy({'A': -1, 'R': -6, 'N': -2, 'D': -4, 'C': -7, 'Q': -5, 'E': -6, 'G': 9, 'H': -6, 'I': -9, 'L': -8, 'K': -5, 'M': -7, 'F': -8, 'P': -6, 'S': -2, 'T': -5, 'W': -7, 'Y': -8, 'V': -8}), 'H': mappingproxy({'A': -4, 'R': -1, 'N': 0, 'D': -3, 'C': -8, 'Q': 1, 'E': -2, 'G': -6, 'H': 13, 'I': -7, 'L': -6, 'K': -3, 'M': -5, 'F': -4, 'P': -5, 'S': -3, 'T': -4, 'W': -5, 'Y': 1, 'V': -7}), 'I': mappingproxy({'A': -4, 'R': -7, 'N': -7, 'D': -8, 'C': -3, 'Q': -6, 'E': -7, 'G': -9, 'H': -7, 'I': 8, 'L': 2, 'K': -6, 'M': 1, 'F': -2, 'P': -7, 'S': -5, 'T': -3, 'W': -6, 'Y': -4, 'V': 4}), 'L': mappingproxy({'A': -4, 'R': -6, 'N': -7, 'D': -8, 'C': -5, 'Q': -5, 'E': -7, 'G': -8, 'H': -6, 'I': 2, 'L': 8, 'K': -6, 'M': 3, 'F': 0, 'P': -7, 'S': -6, 'T': -4, 'W': -5, 'Y': -4, 'V': 0}), 'K': mappingproxy({'A': -2, 'R': 3, 'N': -1, 'D': -3, 'C': -8, 'Q': 2, 'E': 0, 'G': -5, 'H': -3, 'I': -6, 'L': -6, 'K': 10, 'M': -4, 'F': -6, 'P': -3, 'S': -2, 'T': -3, 'W': -8, 'Y': -5, 'V': -5}), 'M': mappingproxy({'A': -3, 'R': -4, 'N': -5, 'D': -8, 'C': -4, 'Q': -2, 'E': -5, 'G': -7, 'H': -5, 'I': 1, 'L': 3, 'K': -4, 'M': 12, 'F': -1, 'P': -5, 'S': -4, 'T': -2, 'W': -4, 'Y': -5, 'V': 0}), 'F': mappingproxy({'A': -5, 'R': -6, 'N': -7, 'D': -8, 'C': -4, 'Q': -6, 'E': -8, 'G': -8, 'H': -4, 'I': -2, 'L': 0, 'K': -6, 'M': -1, 'F': 11, 'P': -7, 'S': -5, 'T': -5, 'W': 0, 'Y': 4, 'V': -3}), 'P': mappingproxy({'A': -2, 'R': -5, 'N': -5, 'D': -5, 'C': -8, 'Q': -4, 'E': -4, 'G': -6, 'H': -5, 'I': -7, 'L': -7, 'K': -3, 'M': -5, 'F': -7, 'P': 12, 'S': -3, 'T': -4, 'W': -8, 'Y': -7, 'V': -6}), 'S': mappingproxy({'A': 1, 'R': -3, 'N': 0, 'D': -2, 'C': -3, 'Q': -2, 'E': -2, 'G': -2, 'H': -3, 'I': -5, 'L': -6, 'K': -2, 'M': -4, 'F': -5, 'P': -3, 'S': 9, 'T': 2, 'W': -7, 'Y': -5, 'V': -4}), 'T': mappingproxy({'A': -1, 'R': -3, 'N': -1, 'D': -4, 'C': -3, 'Q': -3, 'E': -3, 'G': -5, 'H': -4, 'I': -3, 'L': -4, 'K': -3, 'M': -2, 'F': -5, 'P': -4, 'S': 2, 'T': 9, 'W': -7, 'Y': -5, 'V': -1}), 'W': mappingproxy({'A': -6, 'R': -7, 'N': -8, 'D': -10, 'C': -7, 'Q': -5, 'E': -8, 'G': -7, 'H': -5, 'I': -6, 'L': -5, 'K': -8, 'M': -4, 'F': 0, 'P': -8, 'S': -7, 'T': -7, 'W': 17, 'Y': 2, 'V': -5}), 'Y': mappingproxy({'A': -5, 'R': -5, 'N': -5, 'D': -7, 'C': -6, 'Q': -4, 'E': -7, 'G': -8, 'H': 1, 'I': -4, 'L': -4, 'K': -5, 'M': -5, 'F': 4, 'P': -7, 'S': -5, 'T': -5, 'W': 2, 'Y': 12, 'V': -5}), 'V': mappingproxy({'A': -2, 'R': -6, 'N': -7, 'D': -8, 'C': -3, 'Q': -5, 'E': -5, 'G': -8, 'H': -7, 'I': 4, 'L': 0, 'K': -5, 'M': 0, 'F': -3, 'P': -6, 'S': -4, 'T': -1, 'W': -5, 'Y': -5, 'V': 8})}), *, method='fourier', transform=None, length=None, **options)[source]¶
Transform two chains on one grid and return all ordered coefficient products.
Options follow transform_sequence. The default grid covers both chains; preprocessing is applied to each chain independently. Products retain the transform’s actual coordinates (including wavelet band/position).
- class protspect.transforms.TransformResult(coefficients, coordinates, metadata)[source]¶
Channel coefficients and shared axes; no periodic-closure duplicate bin.
coordinatesmaps axis names to coefficient-length arrays. Wavelet band and within-band index are coefficient coordinates, not frequencies. Metadata records preprocessing and transform conventions. Arrays belong to this result.- Parameters:
coefficients (dict)
coordinates (dict)
metadata (dict)
- features(component='amplitude', *, kinds=('coefficients',), selector=None)[source]¶
Export channel-major values/names for any transform.
component is amplitude, phase, real, imaginary, or an ordered tuple of these. kinds selects coefficients and/or cross_coefficients (upper triangle, including auto-products). selector is a boolean mask or a callable receiving independent coordinate arrays in a dictionary. For example, lambda c: c[‘frequency’] >= 0 for Fourier/Z, or lambda c: c[‘band’] == ‘D1’ for wavelets. No selector means all bins. Cross-products outside Fourier are aligned coefficient products, not estimates of frequency-domain cross-spectral density.
- cross(other=None)[source]¶
Return aligned conjugate products with explicit within/paired provenance.
With no other result, take the upper triangle including auto-products. With another result, take every ordered A/B channel product. Transform settings and coordinate grids must match; residue counts may differ. Products are not averaged. Their interpretation depends on the backend.
- class protspect.features.Sequence(sequence, attributes=None)[source]¶
Encode a sequence using numeric channels and a selectable transform.
- Parameters:
sequence (str) – Nonempty, case-sensitive residue string. All symbols must be present in every supplied embedding channel; no unknown-residue imputation is done.
attributes (mapping, optional) – Metadata exposed as attributes. Names colliding with API or computed state are rejected.
- embed_sequence(embeddings)[source]¶
Store one numeric vector per channel from a mapping of mappings.
embeddings[channel][residue]must be a finite real number for every residue in the sequence. Missing symbols raise ValueError. Re-embedding invalidates previously computed spectra.
- compute_transform(length=None, *, method='fourier', normalization='none', center=False, **options)[source]¶
Store and return a TransformResult from any supported transform.
Embed first. All backends share centering/normalization, coordinate-aware feature export, within-sequence products, and explicit fixed-grid rules. Recomputing invalidates Fourier compatibility attributes, even on failure.