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

test core_def_all_beads added. [Issue #27] #31

Merged
merged 11 commits into from
Jun 25, 2021
5 changes: 1 addition & 4 deletions membrane_curvature/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
Handles the primary functions
"""

from .lib.mods import dict2pickle, core_fast, curvature
import sys
import os
from .lib.mods import dict2pickle, core_fast, curvature, def_all_beads
import time
import mdtraj as md
import MDAnalysis as mda
Expand All @@ -16,7 +14,6 @@
__author__ = "Estefania Barreto-Ojeda"
version = 0.1

sys.path.append('lib/')

def main():

Expand Down
53 changes: 53 additions & 0 deletions membrane_curvature/data/test_po4_big.gro
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Test file 50 lipids in grid
50
1902POPC PO4 1 3.646 2.658 16.174
1923POPC PO4 2 1.361 0.630 16.101
1926POPC PO4 3 2.354 0.867 16.251
1970POPC PO4 4 0.527 3.817 15.992
1974POPC PO4 5 2.897 3.940 15.792
1978POPC PO4 6 4.292 4.115 15.764
2012POPC PO4 7 1.840 2.717 16.095
2054POPC PO4 8 0.704 2.229 15.981
2061POPC PO4 9 2.914 1.416 16.518
2064POPC PO4 10 0.705 3.189 16.049
2067POPC PO4 11 2.323 3.353 15.948
2081POPC PO4 12 3.467 0.096 16.186
2095POPC PO4 13 -0.168 0.737 15.950
2100POPC PO4 14 2.591 1.788 16.268
2105POPC PO4 15 3.672 3.187 15.870
2157POPE PO4 16 4.385 2.551 15.934
2240POPE PO4 17 3.408 2.115 16.221
2243POPE PO4 18 2.630 2.623 16.040
2274POPE PO4 19 3.909 0.407 16.339
2298POPE PO4 20 0.956 1.559 16.059
2326POPE PO4 21 2.266 4.080 16.184
2328POPE PO4 22 1.796 4.100 15.802
2337POPE PO4 23 0.707 0.736 15.711
2587POPC PO4 24 4.275 2.659 11.733
2597POPC PO4 25 4.143 3.386 12.021
2598POPC PO4 26 3.842 0.874 11.831
2607POPC PO4 27 1.082 4.111 11.526
2622POPC PO4 28 1.451 0.382 11.752
2653POPC PO4 29 2.586 3.912 11.880
2682POPC PO4 30 2.657 2.082 12.172
2702POPC PO4 31 0.081 0.610 11.835
2708POPC PO4 32 0.678 2.233 11.825
2712POPC PO4 33 2.776 0.572 12.004
2713POPC PO4 34 0.988 0.554 11.838
2758POPC PO4 35 3.489 4.016 12.037
2818POPE PO4 36 1.077 3.604 11.516
2825POPE PO4 37 1.824 3.035 11.688
2841POPE PO4 38 3.495 2.382 11.981
2856POPE PO4 39 4.290 1.565 11.671
2879POPE PO4 40 1.854 2.137 12.034
2884POPE PO4 41 1.433 2.763 11.929
2888POPE PO4 42 2.151 1.328 11.814
2912POPE PO4 43 3.156 2.070 11.949
2929POPE PO4 44 2.660 2.821 12.144
2931POPE PO4 45 1.730 1.061 11.953
2965POPE PO4 46 3.301 2.792 11.834
2999POPE PO4 47 1.371 1.989 12.027
3000POPE PO4 48 0.639 1.402 12.078
3006POPE PO4 49 3.113 1.117 11.996
3019POPE PO4 50 0.302 3.800 12.042
4.40167 4.40167 32.07157
13 changes: 13 additions & 0 deletions membrane_curvature/data/test_po4_inverted_indexes.gro
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Test file 10 lipids in grid with indexes inverted. Correct form is: Index 1 belongs to lower leaflet and index 10 belong to upper leaflet.
10
3000POPE PO4 1 0.639 1.402 12.078
2054POPC PO4 2 0.704 2.229 15.981
2298POPE PO4 3 0.956 1.559 16.059
2337POPE PO4 4 0.707 0.736 15.711
2622POPC PO4 5 1.451 0.382 11.752
2702POPC PO4 6 0.081 0.610 11.835
2708POPC PO4 7 0.678 2.233 11.825
2713POPC PO4 8 0.988 0.554 11.838
2999POPE PO4 9 1.371 1.989 12.027
1923POPC PO4 10 1.361 0.630 16.101
2.60167 2.60167 32.07157
28 changes: 28 additions & 0 deletions membrane_curvature/data/test_po4_med.gro
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Test file 25 lipid in grid
25
1923POPC PO4 1 1.361 0.630 16.101
1926POPC PO4 2 2.354 0.867 16.251
2012POPC PO4 3 1.840 2.717 16.095
2054POPC PO4 4 0.704 2.229 15.981
2061POPC PO4 5 2.914 1.416 16.518
2064POPC PO4 6 0.705 3.189 16.049
2095POPC PO4 7 -0.168 0.737 15.950
2100POPC PO4 8 2.591 1.788 16.268
2243POPE PO4 9 2.630 2.623 16.040
2298POPE PO4 10 0.956 1.559 16.059
2337POPE PO4 11 0.707 0.736 15.711
2622POPC PO4 12 1.451 0.382 11.752
2682POPC PO4 13 2.657 2.082 12.172
2702POPC PO4 14 0.081 0.610 11.835
2708POPC PO4 15 0.678 2.233 11.825
2712POPC PO4 16 2.776 0.572 12.004
2713POPC PO4 17 0.988 0.554 11.838
2825POPE PO4 18 1.824 3.035 11.688
2879POPE PO4 19 1.854 2.137 12.034
2884POPE PO4 20 1.433 2.763 11.929
2888POPE PO4 21 2.151 1.328 11.814
2929POPE PO4 22 2.660 2.821 12.144
2931POPE PO4 23 1.730 1.061 11.953
2999POPE PO4 24 1.371 1.989 12.027
3000POPE PO4 25 0.639 1.402 12.078
3.5167 3.5167 32.07157
13 changes: 13 additions & 0 deletions membrane_curvature/data/test_po4_small.gro
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Test file 10 lipids in grid
10
1923POPC PO4 1 1.361 0.630 16.101
2054POPC PO4 2 0.704 2.229 15.981
2298POPE PO4 3 0.956 1.559 16.059
2337POPE PO4 4 0.707 0.736 15.711
2622POPC PO4 5 1.451 0.382 11.752
2702POPC PO4 6 0.081 0.610 11.835
2708POPC PO4 7 0.678 2.233 11.825
2713POPC PO4 8 0.988 0.554 11.838
2999POPE PO4 9 1.371 1.989 12.027
3000POPE PO4 10 0.639 1.402 12.078
2.60167 2.60167 32.07157
24 changes: 6 additions & 18 deletions membrane_curvature/lib/mods.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,12 @@ def def_all_beads(lipid_types, leaflets, head_list, topology):
print('==== Lipid types in membrane ==== ')
for lt in lipid_types:
print('====>', lt)
dic_all_beads['upper'][lt] = np.concatenate((topology.select('resname ' +
lt +
' and index ' +
str(head_list[0]) +
' to ' +
str(head_list[1]) +
' and name PO4'), topology.select('resname ' +
lt +
' and index ' +
str(head_list[0]) +
' to ' +
str(head_list[1]) +
' and name GM1'))).astype(int).tolist()
dic_all_beads['lower'][lt] = np.concatenate((topology.select(
'resname ' + lt + ' and index ' + str(head_list[1] + 1) + ' to ' + str(head_list[2]) + ' and name PO4'),
topology.select(
'resname ' + lt + ' and index ' + str(head_list[1] + 1) + ' to ' + str(head_list[2]) + ' and name GM1'))).astype(int).tolist()

dic_all_beads['upper'][lt] = topology.select(
'resname ' + lt + ' and index ' + str(head_list[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know about f-strings, @ojeda-e? It might be more readable to do this?

f"resname {lt} and index {head_list[0]} to {head_list[1]} and name PO4"

As a side note, maybe you shouldn't hard-code the name of the bead / atom in in the refactor :)

+ ' to ' + str(head_list[1]) + ' and name PO4').astype(int).tolist()
dic_all_beads['lower'][lt] = topology.select(
'resname ' + lt + ' and index ' + str(head_list[1] + 1)
+ ' to ' + str(head_list[2]) + ' and name PO4').astype(int).tolist()
print("upper", len(dic_all_beads['upper'][lt]))
print("lower", len(dic_all_beads['lower'][lt]))

Expand Down
20 changes: 18 additions & 2 deletions membrane_curvature/tests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,30 @@
"""

__all__ = [
# From lower to higher complexity
"GRO_PO4_SMALL", # Gromacs file of PO4 beads in POPC POPE membrane with 10 lipids
# Gromacs test file of PO4 beacs in POPC POPE membrane with 10 lipids with indexes inverted.
"GRO_PO4_INVERTED_ID",
"GRO_PO4_MED", # Gromacs file of PO4 beads in POPC POPE membrane with 25 lipids
"GRO_PO4_BIG", # Gromacs file of PO4 beads in POPC POPE membrane with 50 lipids
"GRO_PO4", # Gromacs file of PO4 beads in POPC POPE membrane with 914 lipids
"XTC_PO4", # Gromacs trajectory of GRO_PO4
"GRO_MEMBRANE_PROTEIN", # Gromacs file of POPC POPE CHOL membrane
"XTC_MEMBRANE_PROTEIN" # Gromacs trajectory of 10 frames.
"XTC_MEMBRANE_PROTEIN", # Gromacs trajectory of 10 frames.
]

from pkg_resources import resource_filename

# Membrane protein systems
GRO_MEMBRANE_PROTEIN = resource_filename(__name__, '../data/test_curvature_abca1.gro')
GRO_PO4 = resource_filename(__name__, '../data/test_curvature_po4_only.gro')
XTC_MEMBRANE_PROTEIN = resource_filename(__name__, '../data/test_curvature_abca1.xtc')
# PO4 beads only
GRO_PO4 = resource_filename(__name__, '../data/test_curvature_po4_only.gro')
XTC_PO4 = resource_filename(__name__, '../data/test_curvature_po4_only.xtc')
# Smaler systems derived from
GRO_PO4_SMALL = resource_filename(__name__, '../data/test_po4_small.gro')
GRO_PO4_MED = resource_filename(__name__, '../data/test_po4_med.gro')
GRO_PO4_BIG = resource_filename(__name__, '../data/test_po4_big.gro')
# Inverted indexes
GRO_PO4_INVERTED_ID = resource_filename(__name__, '../data/test_po4_inverted_indexes.gro')
del resource_filename
Loading