Skip to content

Commit

Permalink
more stable test for non empty lists
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Sep 30, 2024
1 parent 0c6e55e commit e0edf04
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions prody/tests/proteins/test_insty.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""This module contains unit tests for :mod:`~prody.proteins.interactions`."""

import numpy as np
from numpy import arange
from prody import *
from prody.tests import unittest
from prody.tests.datafiles import *
Expand Down Expand Up @@ -91,7 +90,7 @@ def testSaltBridgesSave(self):
np.save('test_2k39_sbs.npy', np.array(self.data_sbs, dtype=object), allow_pickle=True)

data_test = np.load('test_2k39_sbs.npy', allow_pickle=True)
assert_equal(sorted([i[-1][-1] for i in data_test if i]), sorted([i[-1][-1] for i in self.SBS_INTERACTIONS if i]),
assert_equal(sorted([i[-1][-1] for i in data_test if len(i) > 0]), sorted([i[-1][-1] for i in self.SBS_INTERACTIONS if len(i) > 0]),
'failed to get correct salt bridges from saving and loading')


Expand All @@ -100,23 +99,23 @@ def testRepulsiveIonicBonding(self):

if prody.PY3K:
data_test = calcRepulsiveIonicBondingTrajectory(self.ATOMS)
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]),
assert_equal(sorted([i[-1][-1] for i in data_test if len(i) > 0]), sorted([i[-1][-1] for i in self.RIB_INTERACTIONS if len(i) > 0]),
'failed to get correct repulsive ionic bonding')

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

if prody.PY3K:
data_test = calcPiStackingTrajectory(self.ATOMS)
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]),
assert_equal(sorted([i[-1][-1] for i in data_test if len(i) > 0]), sorted([i[-1][-1] for i in self.PISTACK_INTERACTIONS if len(i) > 0]),
'failed to get correct pi-stacking interactions')

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

if prody.PY3K:
data_test = calcPiCationTrajectory(self.ATOMS)
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]),
assert_equal(sorted([i[-1][-1] for i in data_test if len(i) > 0]), sorted([i[-1][-1] for i in self.PICAT_INTERACTIONS if len(i) > 0]),
'failed to get correct pi-cation interactions')


Expand All @@ -137,20 +136,20 @@ def testDisulfideBondsCalc(self):
"""Test for disulfide bonds interactions without saving and loading."""
if prody.PY3K:
data_test = calcDisulfideBondsTrajectory(self.ATOMS)
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]),
assert_equal(sorted([i[-1][-1] for i in data_test if len(i) > 0]), sorted([i[-1][-1] for i in self.DISU_INTERACTIONS if len(i) > 0]),
'failed to get correct disulfide bonds from calculation')

def testDisulfideBondsSave(self):
"""Test for disulfide bonds interactions with saving and loading (one type of interactions with 0)."""
if prody.PY3K:
data_test = calcDisulfideBondsTrajectory(self.ATOMS)
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]),
assert_equal(sorted([i[-1][-1] for i in data_test if len(i) > 0]), sorted([i[-1][-1] for i in self.DISU_INTERACTIONS if len(i) > 0]),
'failed to get correct disulfide bonds from calculation')

np.save('test_2k39_disu.npy', np.array(data_test, dtype=object), allow_pickle=True)

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 self.DISU_INTERACTIONS if i]),
assert_equal(sorted([i[-1][-1] for i in data_test if len(i) > 0]), sorted([i[-1][-1] for i in self.DISU_INTERACTIONS if len(i) > 0]),
'failed to get correct disulfide bonds from saving and loading')

def testImportHpb(self):
Expand Down

0 comments on commit e0edf04

Please sign in to comment.