Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactions tests fixes #1762

Merged
merged 3 commits into from
Oct 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 51 additions & 48 deletions prody/tests/proteins/test_insty.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,60 @@
from prody.proteins.interactions import calcPiCationTrajectory, calcHydrophobicTrajectory
from prody.proteins.interactions import calcDisulfideBondsTrajectory, calcProteinInteractions

ATOMS = parseDatafile('2k39_insty')
ALL_INTERACTIONS = parseDatafile('2k39_all')
ALL_INTERACTIONS2 = parseDatafile('2k39_all2')
HBS_INTERACTIONS = parseDatafile('2k39_hbs')
SBS_INTERACTIONS = parseDatafile('2k39_sbs')
RIB_INTERACTIONS = parseDatafile('2k39_rib')
PISTACK_INTERACTIONS = parseDatafile('2k39_PiStack')
PICAT_INTERACTIONS = parseDatafile('2k39_PiCat')
HPH_INTERACTIONS = parseDatafile('2k39_hph')
HPH_INTERACTIONS2 = parseDatafile('2k39_hph2')
DISU_INTERACTIONS = parseDatafile('2k39_disu')

# Generating new data to compare it with the existing one:
INTERACTIONS_ALL = InteractionsTrajectory()
data_all = INTERACTIONS_ALL.calcProteinInteractionsTrajectory(ATOMS)
np.save('test_2k39_all.npy', data_all, allow_pickle=True)

data_hbs = calcHydrogenBondsTrajectory(ATOMS)
np.save('test_2k39_hbs.npy', data_hbs, allow_pickle=True)

data_sbs = calcSaltBridgesTrajectory(ATOMS)
np.save('test_2k39_sbs.npy', data_sbs, allow_pickle=True)

data_rib = calcRepulsiveIonicBondingTrajectory(ATOMS)
np.save('test_2k39_rib.npy', data_rib, allow_pickle=True)

data_PiStack = calcPiStackingTrajectory(ATOMS)
np.save('test_2k39_PiStack.npy', data_PiStack, allow_pickle=True)

data_PiCat = calcPiCationTrajectory(ATOMS)
np.save('test_2k39_PiCat.npy', data_PiCat, allow_pickle=True)

data_hph = calcHydrophobicTrajectory(ATOMS)
np.save('test_2k39_hph.npy', data_hph, allow_pickle=True)
class TestInteractions(unittest.TestCase):

data_disu = calcDisulfideBondsTrajectory(ATOMS)
np.save('test_2k39_disu.npy', data_disu, allow_pickle=True)
def setUp(self):
"""Generating new data to compare it with the existing one"""

if prody.PY3K:
self.ATOMS = parseDatafile('2k39_insty')
self.ALL_INTERACTIONS = parseDatafile('2k39_all')
self.ALL_INTERACTIONS2 = parseDatafile('2k39_all2')
self.HBS_INTERACTIONS = parseDatafile('2k39_hbs')
self.SBS_INTERACTIONS = parseDatafile('2k39_sbs')
self.RIB_INTERACTIONS = parseDatafile('2k39_rib')
self.PISTACK_INTERACTIONS = parseDatafile('2k39_PiStack')
self.PICAT_INTERACTIONS = parseDatafile('2k39_PiCat')
self.HPH_INTERACTIONS = parseDatafile('2k39_hph')
self.HPH_INTERACTIONS2 = parseDatafile('2k39_hph2')
self.DISU_INTERACTIONS = parseDatafile('2k39_disu')

self.INTERACTIONS_ALL = InteractionsTrajectory()
self.data_all = self.INTERACTIONS_ALL.calcProteinInteractionsTrajectory(self.ATOMS)
np.save('test_2k39_all.npy', self.data_all, allow_pickle=True)

self.data_hbs = calcHydrogenBondsTrajectory(self.ATOMS)
np.save('test_2k39_hbs.npy', self.data_hbs, allow_pickle=True)

self.data_sbs = calcSaltBridgesTrajectory(self.ATOMS)
np.save('test_2k39_sbs.npy', self.data_sbs, allow_pickle=True)

self.data_rib = calcRepulsiveIonicBondingTrajectory(self.ATOMS)
np.save('test_2k39_rib.npy', self.data_rib, allow_pickle=True)

self.data_PiStack = calcPiStackingTrajectory(self.ATOMS)
np.save('test_2k39_PiStack.npy', self.data_PiStack, allow_pickle=True)

self.data_PiCat = calcPiCationTrajectory(self.ATOMS)
np.save('test_2k39_PiCat.npy', self.data_PiCat, allow_pickle=True)

self.data_hph = calcHydrophobicTrajectory(self.ATOMS)
np.save('test_2k39_hph.npy', self.data_hph, allow_pickle=True)

self.data_disu = calcDisulfideBondsTrajectory(self.ATOMS)
np.save('test_2k39_disu.npy', self.data_disu, allow_pickle=True)

class TestInteractions(unittest.TestCase):

def testAllInsteractions(self):
"""Test for all types of interactions."""

if prody.PY3K:
data_test = np.load('test_2k39_all.npy', allow_pickle=True)

try:
assert_equal(data_test, ALL_INTERACTIONS2,
assert_equal(data_test, self.ALL_INTERACTIONS2,
'failed to get correct interactions without hpb.so')
except:
assert_equal(data_test, ALL_INTERACTIONS,
assert_equal(data_test, self.ALL_INTERACTIONS,
'failed to get correct interactions with hpb.so')

def testHydrogenBonds(self):
Expand All @@ -72,39 +75,39 @@ def testHydrogenBonds(self):

if prody.PY3K:
data_test = np.load('test_2k39_hbs.npy', allow_pickle=True)
assert_equal(sorted([i[-1][-1] for i in data_test]), sorted([i[-1][-1] for i in HBS_INTERACTIONS]),
assert_equal(sorted([i[-1][-1] for i in data_test]), sorted([i[-1][-1] for i in self.HBS_INTERACTIONS]),
'failed to get correct hydrogen bonds')

def testSaltBridges(self):
"""Test for salt bridges."""

if prody.PY3K:
data_test = np.load('test_2k39_sbs.npy', allow_pickle=True)
assert_equal(sorted([i[-1][-1] for i in data_test]), sorted([i[-1][-1] for i in SBS_INTERACTIONS]),
assert_equal(sorted([i[-1][-1] for i in data_test]), sorted([i[-1][-1] for i in self.SBS_INTERACTIONS]),
'failed to get correct salt bridges')

def testRepulsiveIonicBonding(self):
"""Test for repulsive ionic bonding."""

if prody.PY3K:
data_test = np.load('test_2k39_rib.npy', allow_pickle=True)
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in RIB_INTERACTIONS if i]),
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in self.RIB_INTERACTIONS if i]),
'failed to get correct repulsive ionic bonding')

def testPiStacking(self):
"""Test for pi-stacking interactions."""

if prody.PY3K:
data_test = np.load('test_2k39_PiStack.npy', allow_pickle=True)
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in PISTACK_INTERACTIONS if i]),
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in self.PISTACK_INTERACTIONS if i]),
'failed to get correct pi-stacking interactions')

def testPiCation(self):
"""Test for pi-stacking interactions."""

if prody.PY3K:
data_test = np.load('test_2k39_PiCat.npy', allow_pickle=True)
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in PICAT_INTERACTIONS if i]),
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in self.PICAT_INTERACTIONS if i]),
'failed to get correct pi-cation interactions')


Expand All @@ -114,10 +117,10 @@ def testHydrophobicInteractions(self):
if prody.PY3K:
data_test = np.load('test_2k39_hph.npy', allow_pickle=True)
try:
assert_equal(sorted([i[-1][-1] for i in data_test]), sorted([i[-1][-1] for i in HPH_INTERACTIONS2]),
assert_equal(sorted([i[-1][-1] for i in data_test]), sorted([i[-1][-1] for i in self.HPH_INTERACTIONS2]),
'failed to get correct hydrophobic interactions without hpb.so')
except:
assert_equal(sorted([i[-1][-1] for i in data_test]), sorted([i[-1][-1] for i in HPH_INTERACTIONS]),
assert_equal(sorted([i[-1][-1] for i in data_test]), sorted([i[-1][-1] for i in self.HPH_INTERACTIONS]),
'failed to get correct hydrophobic interactions with hpb.so')


Expand All @@ -126,7 +129,7 @@ def testDisulfideBonds(self):

if prody.PY3K:
data_test = np.load('test_2k39_disu.npy', allow_pickle=True)
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in DISU_INTERACTIONS if i]),
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in self.DISU_INTERACTIONS if i]),
'failed to get correct disulfide bonds')


Loading