Example #1
0
    def setUpClass(self):
        super(MainTest, self).setUpClass()
        self.dirpath = os.path.dirname(os.path.abspath(__file__))
        self.medium = ENCoM(str(os.path.join(
            self.dirpath, "test_medium.pdb")))  # small 2-segment protein

        # open and closed states of citrate synthase, cleaned to have exact same number of masses
        self.cs_open = ENCoM(str(os.path.join(self.dirpath, "open_clean.pdb")))
        self.cs_closed = ENCoM(
            str(os.path.join(self.dirpath, "closed_clean.pdb")))
Example #2
0
    new_p = np.zeros((len(p), 3))
    for i in range(len(p)):
        for j in range(3):
            new_p[i][j] = p[i][j]
    return new_p


def get_centroid(p):
    """ Returns the centroid of a set of point p (in the form of an Nx3 matrix).
    """
    n = len(p)
    xyz = np.array([0, 0, 0])
    for i in range(n):
        xyz = xyz + np.array([p[i][0], p[i][1], p[i][2]])
    return xyz/n




if __name__ == "__main__":
    # test_boltzmann_squares()


    open_state = ENCoM("../../tests/open_clean.pdb")
    closed_state = ENCoM("../../tests/closed_clean.pdb")
    print(get_amplitudes_for_fit(open_state, closed_state, 10))
    # print(overlap(open_state, closed_state, 10))
    # print(overlap(closed_state, open_state, 10))
    # print(open_state.compute_bfactors()[:15])

Example #3
0
try:
    from nrgten.encom import ENCoM
    from nrgten.metrics import pca_ensemble, rmsip
except ImportError as e:
    print(
        "NRGTEN is not installed on your machine. To install, run the following command:\npip install nrgten"
    )
    raise e

if __name__ == "__main__":
    insulin_nmr = ENCoM("2lwz.pdb")
    variances, pcs = pca_ensemble(insulin_nmr, variance_to_explain=0.9)
    print(rmsip(pcs, insulin_nmr.eigvecs[6:16]))
from nrgten.encom import ENCoM
from nrgten.metrics import get_overlaps

if __name__ == "__main__":
    open = ENCoM("open_clean.pdb")
    # closed = ENCoM("closed_clean.pdb")
    # print(overlap(open, closed, 10))
    # print(overlap(closed, open, 10))
Example #5
0
try:
    from nrgten.encom import ENCoM
except ImportError as e:
    print(
        "NRGTEN is not installed on your machine. To install, run the following command:\npip install nrgten"
    )
    raise e

if __name__ == "__main__":
    model = ENCoM("test_medium.pdb")
    svib = model.compute_vib_entropy()
    expected = 504.8468148072965
    diff = abs(expected - svib)
    if diff < 0.01:
        print("NRGTEN is properly installed on your system!")
    else:
        raise ValueError(
            "NRGTEN seems installed on your system, but does not give the proper value for this test. The"
            +
            " expected Svib value is {:.6f} and your installation produces {:.6f}."
            .format(expected, svib) +
            "If the difference is small enough, you can ignore this message.")
try:
    from nrgten.encom import ENCoM
    from nrgten.metrics import get_transit_probs
except ImportError as e:
    print(
        "NRGTEN is not installed on your machine. To install, run the following command:\npip install nrgten"
    )
    raise e

if __name__ == "__main__":
    open_cs = ENCoM("open_clean.pdb")
    closed_cs = ENCoM("closed_clean.pdb")
    prob_open, prob_closed = get_transit_probs(open_cs, closed_cs)
    print("prob_open : {}, prob_closed : {}".format(prob_open, prob_closed))

    open_cs_mut = ENCoM("open_clean_LYS239.pdb")
    closed_cs_mut = ENCoM("closed_clean_LYS239.pdb")
    prob_open_mut, prob_closed_mut = get_transit_probs(open_cs_mut,
                                                       closed_cs_mut)
    print("prob_open_mut : {}, prob_closed_mut : {}".format(
        prob_open_mut, prob_closed_mut))
try:
    from nrgten.encom import ENCoM
except ImportError as e:
    print(
        "NRGTEN is not installed on your machine. To install, run the following command:\npip install nrgten"
    )
    raise e

if __name__ == "__main__":
    wt = ENCoM("6r74.pdb")
    tyr103 = ENCoM("6r74_TYR103.pdb")
    wt_entropy = wt.compute_vib_entropy(beta=1)
    tyr103_entropy = tyr103.compute_vib_entropy(beta=1)
    diff_entropy = wt_entropy - tyr103_entropy
    print(diff_entropy)
Example #8
0
try:
	from nrgten.encom import ENCoM
	from nrgten.metrics import get_overlaps
except ImportError as e:
	print("NRGTEN is not installed on your machine. To install, run the following command:\npip install nrgten")
	raise e

if __name__ == "__main__":
	closed_cs = ENCoM("closed_clean.pdb")
	open_cs = ENCoM("open_clean.pdb", solve=False) # no need to solve the target
	overlaps = get_overlaps(closed_cs, open_cs, 10)
	print(overlaps)
Example #9
0
class MainTest(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        super(MainTest, self).setUpClass()
        self.dirpath = os.path.dirname(os.path.abspath(__file__))
        self.medium = ENCoM(str(os.path.join(
            self.dirpath, "test_medium.pdb")))  # small 2-segment protein

        # open and closed states of citrate synthase, cleaned to have exact same number of masses
        self.cs_open = ENCoM(str(os.path.join(self.dirpath, "open_clean.pdb")))
        self.cs_closed = ENCoM(
            str(os.path.join(self.dirpath, "closed_clean.pdb")))

    def test_entropy(self):
        self.assertAlmostEqual(self.medium.compute_vib_entropy(),
                               504.8449418766389)

    def test_eigenvalues(self):
        """Ensuring ENCoM consistency

        The passing of this test ensures that the ENCoM model implemented here is the same as in the 2014 Frappier &
        Najmanovich paper (doi: 10.1371/journal.pcbi.1003569)
        """
        expected_first10_eigvals = [
            395.13213997, 705.84751463, 1051.3377265, 1717.77386711,
            2334.71773081, 3180.41535126, 3367.29667647, 3732.73424169,
            4395.60062344, 5646.29249956
        ]
        for i, v in enumerate(self.medium.eigvals[6:16]):
            self.assertAlmostEqual(v, expected_first10_eigvals[i])

    def test_overlap(self):
        tolerance_big = 0.05  # for some occult reason (probably small numeric errors), overlaps vary from
        # execution to execution (even on the same system with exact same configuration)
        tolerance_medium = 0.1
        tolerance_small = 0.2

        # expected overlaps
        o_to_c_expected = [
            0.48219475776961046, 0.22445345494422506, 0.13626771118348027,
            0.40620100897625844, 0.4269350823318777, 0.3252500318424115,
            0.050714322164735454, 0.15852890110829515, 0.11657022472204998,
            0.04085067373729564
        ]

        c_to_o_expected = [
            0.2572247945186605, 0.4417530982984568, 0.2676782798408168,
            0.16980479771422188, 0.4857802255735633, 0.2866088336257986,
            0.25885548397562513, 0.08276471832051029, 0.16543958904525702,
            0.007655844355325302
        ]

        # computed overlaps
        o_to_c = get_overlaps(self.cs_open, self.cs_closed, 10)
        c_to_o = get_overlaps(self.cs_closed, self.cs_open, 10)

        for expected, observed in zip([o_to_c_expected, c_to_o_expected],
                                      [o_to_c, c_to_o]):
            for i in range(10):
                diff = abs(observed[i] - expected[i])
                if expected[i] > 0.3:
                    self.assertLess(diff / expected[i], tolerance_big)
                elif expected[i] > 0.1:
                    self.assertLess(diff / expected[i], tolerance_medium)
                else:
                    self.assertLess(diff / expected[i], tolerance_small)

    def test_bfactors(self):
        tolerance = 0.02  # b-factors also vary a little, but less than overlaps

        expected = [
            17.915181389368097, 9.807507859742454, 5.6361432619585985,
            4.478888248023526, 3.8351524693259593, 3.503278027646238,
            4.584754887889988, 4.75555282481797, 3.949012476056274,
            3.690415817549934, 4.913395104757805, 5.45099864816634,
            4.7258998263711804, 4.325912357234571, 6.385333388587485
        ]
        computed = self.cs_open.compute_bfactors()[:15]
        for i in range(15):
            diff = abs(computed[i] - expected[i])
            self.assertLess(diff / expected[i], tolerance)
Example #10
0
try:
    from nrgten.encom import ENCoM
    from nrgten.metrics import cumulative_overlap
except ImportError as e:
    print(
        "NRGTEN is not installed on your machine. To install, run the following command:\npip install nrgten"
    )
    raise e

if __name__ == "__main__":
    closed_cs = ENCoM("closed_clean.pdb")
    open_cs = ENCoM("open_clean.pdb")
    print("Cumulative overlap 10 modes, from closed to open: {}".format(
        cumulative_overlap(closed_cs, open_cs, 10)))
    print("Cumulative overlap 10 modes, from open to closed: {}".format(
        cumulative_overlap(open_cs, closed_cs, 10)))