memprod 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {memprod-0.2.1/src/memprod.egg-info → memprod-0.2.2}/PKG-INFO +1 -1
- {memprod-0.2.1 → memprod-0.2.2}/pyproject.toml +1 -1
- {memprod-0.2.1 → memprod-0.2.2}/src/memprod/MemPrOD.py +14 -31
- {memprod-0.2.1 → memprod-0.2.2/src/memprod.egg-info}/PKG-INFO +1 -1
- {memprod-0.2.1 → memprod-0.2.2}/src/memprod.egg-info/SOURCES.txt +2 -1
- memprod-0.2.2/tests/test_pdb_output.py +38 -0
- {memprod-0.2.1 → memprod-0.2.2}/LICENSE +0 -0
- {memprod-0.2.1 → memprod-0.2.2}/README.md +0 -0
- {memprod-0.2.1 → memprod-0.2.2}/setup.cfg +0 -0
- {memprod-0.2.1 → memprod-0.2.2}/src/memprod/__init__.py +0 -0
- {memprod-0.2.1 → memprod-0.2.2}/src/memprod.egg-info/dependency_links.txt +0 -0
- {memprod-0.2.1 → memprod-0.2.2}/src/memprod.egg-info/entry_points.txt +0 -0
- {memprod-0.2.1 → memprod-0.2.2}/src/memprod.egg-info/requires.txt +0 -0
- {memprod-0.2.1 → memprod-0.2.2}/src/memprod.egg-info/top_level.txt +0 -0
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "memprod"
|
|
8
|
-
version = "0.2.
|
|
8
|
+
version = "0.2.2"
|
|
9
9
|
authors = [{name = "Matyas Parrag",email="matyas.parrag@gmail.com"}]
|
|
10
10
|
description = "A program for the prediction of local membrane deformations around a protein"
|
|
11
11
|
readme = "README.md"
|
|
@@ -21,6 +21,12 @@ from scipy.optimize._optimize import _line_search_wolfe12, _LineSearchError
|
|
|
21
21
|
#A1 @ H @ A2 with two dense n x n matrix products (O(n^3), ~0.6 s per iteration for MemPrOD's ~3000 variables),
|
|
22
22
|
#whereas the identical update is applied here as a rank-2 correction (O(n^2)):
|
|
23
23
|
# H+ = H - rho*(H y) s^T - rho*s (y^T H) + (rho^2 y^T H y + rho) s s^T
|
|
24
|
+
#One PDB ATOM record in the fixed columns of the format: serial 7-11, name 13-16, residue 18-20, chain 22, residue
|
|
25
|
+
#number 23-26, x/y/z 31-54, occupancy 55-60, B-factor 61-66
|
|
26
|
+
def pdb_atom_line(serial,name,resname,chain,resnum,x,y,z,occ=1.0,bfac=0.0):
|
|
27
|
+
name = name if len(name) == 4 else " "+name
|
|
28
|
+
return "ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f\n"%(serial%100000,name[:4],resname[:3],chain[:1],resnum%10000,x,y,z,occ,bfac)
|
|
29
|
+
|
|
24
30
|
def bfgs_minimize(fun,x0,jac,gtol=1e-5,maxiter=None,c1=1e-4,c2=0.9,xrtol=0):
|
|
25
31
|
x0 = np.asarray(x0,dtype=float).flatten()
|
|
26
32
|
N = len(x0)
|
|
@@ -258,16 +264,7 @@ def main():
|
|
|
258
264
|
count = 0
|
|
259
265
|
for i in points:
|
|
260
266
|
count += 1
|
|
261
|
-
|
|
262
|
-
c = "ATOM "+count_str+" BB DUM 1 0.000 0.000 15.000 1.00 0.00"
|
|
263
|
-
xp = np.format_float_positional(i[0],precision=3)
|
|
264
|
-
yp = np.format_float_positional(i[1],precision=3)
|
|
265
|
-
zp = np.format_float_positional(i[2],precision=3)
|
|
266
|
-
xp += "0"*(3-len((xp.split(".")[1])))
|
|
267
|
-
yp += "0"*(3-len((yp.split(".")[1])))
|
|
268
|
-
zp += "0"*(3-len((zp.split(".")[1])))
|
|
269
|
-
new_c = c[:30]+(" "*(8-len(xp)))+xp+(" "*(8-len(yp)))+yp+(" "*(8-len(zp))) +zp+c[54:]+"\n"
|
|
270
|
-
new_file.write(new_c)
|
|
267
|
+
new_file.write(pdb_atom_line(count,"BB","DUM","Z",1,float(i[0]),float(i[1]),float(i[2])))
|
|
271
268
|
new_file.close()
|
|
272
269
|
|
|
273
270
|
def write_protein(bfacs,fn,ofn):
|
|
@@ -278,9 +275,9 @@ def main():
|
|
|
278
275
|
bc = 0
|
|
279
276
|
for c in n_lines:
|
|
280
277
|
if len(c) > 54 and "[" not in c and c.startswith("ATOM"):
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
new_c = c[:60]+
|
|
278
|
+
#The record as read up to the occupancy, then the B-factor in its six columns (61-66); what follows in
|
|
279
|
+
#the input is dropped, as files with a wider B-factor (MemPrO 0.3.3 and earlier) leave it misaligned
|
|
280
|
+
new_c = c.rstrip("\n")[:60].ljust(60)+"%6.2f"%float(bfacs[map_to_beads[bc]])+"\n"
|
|
284
281
|
bc+=1
|
|
285
282
|
out_file.write(new_c)
|
|
286
283
|
else:
|
|
@@ -500,25 +497,11 @@ def main():
|
|
|
500
497
|
if(covp > 0.6):
|
|
501
498
|
BanGrid[i,j,nn] = 1
|
|
502
499
|
Data[i,j,nn] = grid_in[i,j,0]+zp
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
else:
|
|
506
|
-
bbp = np.format_float_positional((grid_in[i,j,0]+zp-z_dev)*pm1,precision=3)
|
|
507
|
-
bbp += "0"*(3-len((bbp.split(".")[1])))
|
|
500
|
+
#B-factor: charge with -wb, otherwise the surface's deviation from flat
|
|
501
|
+
bbp = float(gc[i,j,nn]) if bfacs else float((grid_in[i,j,0]+zp-z_dev)*pm1)
|
|
508
502
|
count += 1
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
pos = np.array([xs[i],ys[j],0])
|
|
513
|
-
pos = np.dot(rot_mat_inv,pos)
|
|
514
|
-
xp = np.format_float_positional(pos[0],precision=3)
|
|
515
|
-
yp = np.format_float_positional(pos[1],precision=3)
|
|
516
|
-
zp = np.format_float_positional(grid_in[i,j,0]+zp,precision=3)
|
|
517
|
-
xp += "0"*(3-len((xp.split(".")[1])))
|
|
518
|
-
yp += "0"*(3-len((yp.split(".")[1])))
|
|
519
|
-
zp += "0"*(3-len((zp.split(".")[1])))
|
|
520
|
-
new_c = c[:30]+(" "*(8-len(xp)))+xp+(" "*(8-len(yp)))+yp+(" "*(8-len(zp))) +zp+c[54:60]+(" "*(8-len(bbp)))+bbp+c[66:]+"\n"
|
|
521
|
-
new_file.write(new_c)
|
|
503
|
+
pos = np.dot(rot_mat_inv,np.array([xs[i],ys[j],0]))
|
|
504
|
+
new_file.write(pdb_atom_line(count,"BB","DUM","Z",1,float(pos[0]),float(pos[1]),float(grid_in[i,j,0]+zp),1.0,bbp))
|
|
522
505
|
new_file.close()
|
|
523
506
|
np.savez(locdir+"BotBan.npz",BanGrid[:,:,0])
|
|
524
507
|
np.savez(locdir+"TopBan.npz",BanGrid[:,:,1])
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for MemPrOD's PDB output (Deformations.pdb, the contact and surface files).
|
|
3
|
+
|
|
4
|
+
Run from the repository root with: python -m unittest discover tests
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import unittest
|
|
10
|
+
|
|
11
|
+
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
12
|
+
sys.path.insert(0, os.path.join(ROOT, "src"))
|
|
13
|
+
from memprod.MemPrOD import pdb_atom_line # noqa: E402
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def fields(line):
|
|
17
|
+
"""The fixed PDB columns of an ATOM record."""
|
|
18
|
+
return (line[:6], int(line[6:11]), line[12:16].strip(), line[17:20], line[21], int(line[22:26]),
|
|
19
|
+
float(line[30:38]), float(line[38:46]), float(line[46:54]), float(line[54:60]), float(line[60:66]))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TestPdbOutput(unittest.TestCase):
|
|
23
|
+
|
|
24
|
+
def test_columns(self):
|
|
25
|
+
# A surface bead as Deformations.pdb writes it: coordinates and B-factor read back from their own columns
|
|
26
|
+
line = pdb_atom_line(12, "BB", "DUM", "Z", 1, 38.641, 61.8, -15.92, 1.0, -1.067)
|
|
27
|
+
self.assertNotIn("\t", line)
|
|
28
|
+
self.assertEqual(len(line.rstrip("\n")), 66)
|
|
29
|
+
self.assertEqual(fields(line), ("ATOM ", 12, "BB", "DUM", "Z", 1, 38.641, 61.8, -15.92, 1.0, -1.07))
|
|
30
|
+
|
|
31
|
+
def test_wide_values_stay_in_their_columns(self):
|
|
32
|
+
# Negative coordinates to -999.999 and B-factors to -99.99 fit; serial numbers wrap as in the PDB format
|
|
33
|
+
line = pdb_atom_line(123456, "SC1", "MET", "A", 12, -999.999, 999.999, -100.0, 1.0, -99.99)
|
|
34
|
+
self.assertEqual(fields(line)[1:], (23456, "SC1", "MET", "A", 12, -999.999, 999.999, -100.0, 1.0, -99.99))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if __name__ == "__main__":
|
|
38
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|