-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresidue.py
More file actions
58 lines (45 loc) · 2.34 KB
/
Copy pathresidue.py
File metadata and controls
58 lines (45 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# === residue.py ===
"""
Residue: a single amino acid within a peptide sequence.
A Residue bundles the physicochemical properties of one amino acid, looked up
from the Scales tables by its one-letter code: charge, volume, mass,
hydrophobicity (on a chosen scale), and a group classification. It also records
its position (index) within the parent sequence.
Residue holds only per-residue scalar properties. Geometry and any spatial
computation (helix positions, hydrophobic moment, etc.) are handled externally
by the GenMethod subclasses, not here.
"""
import logging
from scales import Scales
logger = logging.getLogger(__name__)
class Residue:
"""
Represents a single amino acid residue within a peptide sequence.
Stores physicochemical properties looked up from Scales, indexed by the
residue's position. Geometry and spatial calculations are handled
externally by GenMethod subclasses.
"""
def __init__(self, letter: str, index: int = 0, scale: str = 'eisenberg') -> None:
"""
Build a Residue from its one-letter code and position.
Args:
letter (str): One-letter amino acid code (used as the Scales key).
index (int): Position of the residue within the parent sequence.
scale (str): Hydrophobicity scale name used to look up the
residue's hydrophobicity value.
"""
self.letter: str = letter
self.index: int = index
self.charge: float = Scales.aa_charges[self.letter] # net charge of the residue
self.volume: float = Scales.aa_volumes[self.letter] # side-chain volume
self.mass: float = Scales.aa_masses[self.letter] # residue mass
self.hydrophobicity: float = Scales.hydrophobicity_scales[scale][self.letter] # hydrophobicity on the chosen scale
self.group: int = Scales.aa_group[self.letter] # signed chemical-group id (-3 neg, -2 amide, -1 polar, 0 non-polar, 1 aliphatic, 2 aromatic, 3 positive)
def __str__(self) -> str:
"""Return the one-letter code."""
return self.letter
def __repr__(self) -> str:
"""Return an unambiguous representation with letter and index."""
return f"Residue(letter={self.letter!r}, index={self.index})"
if __name__ == '__main__':
pass