Commit f60f9598 authored by Martin Larralde's avatar Martin Larralde
Browse files

Fix `hydrophobic_moment` when window is larger than the peptide length (#1)

parent 6bed9bc6
......@@ -657,6 +657,7 @@ class Peptide(typing.Sequence[str]):
:doi:`10.1073/pnas.81.1.140`. :pmid:`6582470`.
"""
window = min(window, len(self))
scale = tables.HYDROPHOBICITY["Eisenberg"]
lut = [scale.get(aa, 0.0) for aa in self._CODE1]
angles = [(angle * i) % 360 for i in range(window)]
......
import unittest
import peptides
class TestHydrophobicMoment(unittest.TestCase):
def test_small_peptides(self):
# https://github.com/althonos/peptides.py/issues/1
p1 = peptides.Peptide("MLK")
self.assertAlmostEqual(p1.hydrophobic_moment(window=5, angle=100), 0.8099386)
p2 = peptides.Peptide("AACQ")
self.assertAlmostEqual(p2.hydrophobic_moment(window=5, angle=100), 0.3152961)
p3 = peptides.Peptide("FGGIQ")
self.assertAlmostEqual(p3.hydrophobic_moment(window=5, angle=100), 0.3184719)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment