mempro 0.3.3__tar.gz → 0.4.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mempro
3
- Version: 0.3.3
3
+ Version: 0.4.0
4
4
  Summary: Membrane Protein Orientation in Lipid Bilayers
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -149,7 +149,22 @@ MemPrO is intended to be run on PDB files, and will output the following files:
149
149
 
150
150
  **-c, --curvature** — Toggles global curvature minimisation. Not currently compatible with `-dm` or `-mt_opt`.
151
151
 
152
- **-flip, --flip** — Flips the protein in the Z-axis on output.
152
+ **-flip, --flip** — Turns the protein over on output (180° about x, so it is not mirrored), after `-side`.
153
+
154
+ **-la, --long_axis** — (Default: `on`; only with `-dm`) Turns the protein so its long axis (the first principal axis of its surface beads) lies along z before the search, and adds a starting configuration with the membrane normals along it to the `-ng` grid. `-dm` estimates the membranes' starting separation and depth along z before minimising, so without this the result depends on how the protein happens to lie in the input file: an AcrAB–TolC-type pump lying 46° from z came out with membranes touching nothing (rank 1 potential −1, 6% of starts), and turned onto z first it was oriented with TolC in the outer membrane and the RND transporter in the inner one (potential −102, 71% of starts). Complexes already lying along z (MacAB–TolC, 0.1°) are unchanged.
155
+
156
+ **-side, --sidedness** — (Default: `auto`) Which way up the protein goes. The membrane alone does not show which side is which, so with `auto` the protein is turned over where needed to follow Insane4MemPrO's convention: `-u` is the extracellular (non-cytoplasmic) side, up, and `-l` the cytoplasmic side, at −z, in every membrane. In an organelle `-l` is the side positive-inside points to (the matrix, the stroma); in the outer membrane it is the periplasm.
157
+
158
+ Outer-membrane proteins and lipoproteins (β-barrels, or lipid anchors with no helices across the membrane), strongest rule first:
159
+ - Lipid anchors (CYST, CYSD, CYSP, CYSM, CYSK, CYSL, CYSF, CYSG, GLYM, or any four-letter CYS*/GLY* residue with beads beyond its side chain) are in the periplasmic leaflet.
160
+ - A β-barrel chain's last strand runs into the periplasm (the C-terminal β-signal), so where a barrel chain finally leaves the membrane is periplasmic. Chain ends are found from breaks in the backbone, as `martinize2 -merge all` numbers merged chains straight through.
161
+ - Only if neither applies: a β-barrel's extracellular loops are longer than its periplasmic turns (at least 1.5 times, by median).
162
+
163
+ Helical membrane proteins: positive-inside. The side with at least twice as many Lys and Arg within 1 nm of the membrane, and at least 3 more, is cytoplasmic. Lipid anchors are not used for helical proteins: a lipoprotein's anchor is periplasmic in either membrane, which is `-l` in the outer membrane but `-u` in the inner one.
164
+
165
+ A protein left as found is as likely to be wrong as right, so where these thresholds are not met the weaker evidence still decides, and the log prints a `WARNING` that the decision is low-confidence: any difference in loop length, then in Lys/Arg (β-barrels), or in Lys/Arg (helical proteins). Only a protein with no evidence at all, or whose anchors and C-terminal strands disagree, keeps MemPrO's orientation, also with a warning. Check every protein with a warning, and use `-flip` if it is wrong. The log prints rank 1's decision and its evidence, and each `info_rank_N.txt` gives that rank's.
166
+
167
+ Tested on 22 proteins used to develop the rules (OmpA, OmpF, OmpLA, FhuA, FadL, PagP, TolC, LptD/E, BamA–BCDE, Wza; LacY, GlpT, XylE, AcrB, BtuCD, MsbA, HmuUV, KcsA, MscL, AqpZ, SecYEβ, bacteriorhodopsin), each as MemPrO placed it and turned over: 20 come out the right way up. Wza (an α-helical outer-membrane protein, where positive-inside does not apply) and KcsA without its cytoplasmic domains come out upside down, with the warning. On 19 further proteins not used to develop the rules (OmpX, OmpW, OmpT, NspA, FepA, Tsx, OmpG, LamB; LeuT, EmrD, NorM, FocA, YiiP, ClC-ec1, MscS, GlpG, Mhp1, BetP, GltPh) 18 came out right; FepA was wrong until segments ending at missing loop residues were no longer taken for chain ends, and is right now. `off` keeps MemPrO's orientation. Not used with `-dm`, where the two membranes already say which side is which: the cytoplasm is at −z there too (tested on MacAB–TolC, `tests/test_dual_membrane.py`).
153
168
 
154
169
  **-itp, --itp_file** — Path to a Martini 3 `.itp` file. Defaults to `martini_v3.itp` in the same directory as `MemPrO.py` (or the installed package directory).
155
170
 
@@ -261,7 +276,7 @@ Lipid names follow the [Martini 3 lipidome](https://github.com/Martini-Force-Fie
261
276
 
262
277
  **-apl** — (Optional, repeatable) Area per lipid (nm²) for one lipid type (`NAME:AREA`), overriding the built-in value. Built-in values are in `lipid_apl` in `Insane4MemPrO.py`: experimental areas from the Martini 3 lipidome benchmark where measured, otherwise the lipidome's Martini 3 single-lipid bilayer areas scaled by 1.04 (the mean ratio of experiment to those simulations, sd 0.03). Ether and plasmalogen lipids take the area of their diacyl analogue +1.5% and +5%. Lipids not listed use a value for their headgroup class (PC, PE, PG, PS, PA, SM, ceramide) or 0.6 nm².
263
278
 
264
- **-grid** — (Default: circular) Lipid grid for flat membranes filling the box. `circular` places lipids on concentric rings; `square` uses a square lattice that is continuous across the periodic boundaries, avoiding close contacts where clipped rings meet at the box edges. Either way a flat leaflet gets (box area)/(area per lipid) lipids before any are removed around the protein. Curved membranes and `-radius` disks always use rings.
279
+ **-grid** — (Default: square) Lipid grid for flat membranes filling the box. `square` uses a square lattice that is continuous across the periodic boundaries; `circular` places lipids on concentric rings, the original Insane grid. Either way a flat leaflet gets (box area)/(area per lipid) lipids before any are removed around the protein, so the counts are the same. Rings do not pack evenly where neighbouring rings meet or are clipped at the box edges: in a 15 × 15 nm outer membrane (KLA over POPE:POPG:CARD 7:2:1) they gave 204 pairs of beads from different lipids closer than 0.40 nm in the KLA leaflet and 49 in the phospholipid leaflet, against 2 and 0 for `square` (with OmpA, 165 and 14 against 9 and 0; pure POPE, 86 against 0). Energy minimisation removes such contacts, so the gain is a cleaner start. Both grids follow MemPrOD deformations (`-def`) equally, as each lipid is moved to the deformed membrane at its own x, y: on LacY with MemPrOD 0.2.1, phosphates sat within 0.03–0.04 nm (rms) of the predicted head planes with either grid, with 0/5 close contacts (upper/lower) for `square` against 48/53 for `circular`. Curved membranes, pores, micelles and `-radius` disks always use rings.
265
280
 
266
281
  **-temp** — (Optional) Temperature (K) for the built-in phospholipid, cardiolipin and phosphoinositide areas, which otherwise refer to ~303 K (or the lowest temperature at which the lipid is fluid, e.g. DPPC 323 K, sphingomyelin 318 K; see `apl_ref_temp`). Areas are scaled by 0.25% per K, the typical fluid-phase expansion. LPS, sterol and hopanoid values are not scaled. Below a lipid's melting temperature (e.g. DPPC, sphingomyelin) the scaled value is not meaningful.
267
282
 
@@ -274,7 +289,7 @@ Lipid names follow the [Martini 3 lipidome](https://github.com/Martini-Force-Fie
274
289
  **-mt** — (Optional) Membrane thickness (nm) between the phosphate planes for `-footprint map`, as fitted by MemPrO; one value, or two comma-separated for the `-l`/`-u` and `-lo`/`-uo` membranes. MemPrO passes it when building with `-bd`. By default each leaflet extends to the phosphate beads of its lipids as built (about 1.65 nm from the midplane for POPE).
275
290
 
276
291
  **-enclosed** — (Default: `auto`, or `lipids` with `-ring`) Whether lipids go into regions the protein encloses in the membrane, which lipids cannot reach from the bulk (the inside of a ring or barrel). The modes are:
277
- - `auto` judges each region in each leaflet. A region gets lipids if its narrowest core slice still has at least 1 nm² free for lipid beads (room for a lipid at every depth) and at least 60% of the residues lining it are hydrophobic, as inside an ATP synthase c-ring. A water-filled porin or channel lumen is left empty. The log prints each region's narrowest free area, number of lining residues and hydrophobic fraction, and the decision.
292
+ - `auto` judges each region in each leaflet it is enclosed in. A region gets lipids if its narrowest core slice still has at least 1 nm² free for lipid beads (room for a lipid at every depth) and at least 60% of the residues lining it are hydrophobic, as inside an ATP synthase c-ring. Lipid-anchored residues count as hydrophobic: CYST, CYSD, CYSP, CYSM, CYSK, CYSL, CYSF, CYSG and GLYM, and any other four-letter CYS*/GLY* residue with beads beyond its own side chain, so a ring of lipoprotein anchors in one leaflet (such as the PqiC octamer) is filled with lipids. A water-filled porin or channel lumen is left empty. The log prints each region's narrowest free area (`open` in a leaflet where the region joins the bulk membrane), number of lining residues and hydrophobic fraction, and the decision.
278
293
  - `lipids` puts lipids in every enclosed region (the same as `-ring`).
279
294
  - `empty` leaves every enclosed region empty (the behaviour before `-enclosed`).
280
295
 
@@ -136,7 +136,22 @@ MemPrO is intended to be run on PDB files, and will output the following files:
136
136
 
137
137
  **-c, --curvature** — Toggles global curvature minimisation. Not currently compatible with `-dm` or `-mt_opt`.
138
138
 
139
- **-flip, --flip** — Flips the protein in the Z-axis on output.
139
+ **-flip, --flip** — Turns the protein over on output (180° about x, so it is not mirrored), after `-side`.
140
+
141
+ **-la, --long_axis** — (Default: `on`; only with `-dm`) Turns the protein so its long axis (the first principal axis of its surface beads) lies along z before the search, and adds a starting configuration with the membrane normals along it to the `-ng` grid. `-dm` estimates the membranes' starting separation and depth along z before minimising, so without this the result depends on how the protein happens to lie in the input file: an AcrAB–TolC-type pump lying 46° from z came out with membranes touching nothing (rank 1 potential −1, 6% of starts), and turned onto z first it was oriented with TolC in the outer membrane and the RND transporter in the inner one (potential −102, 71% of starts). Complexes already lying along z (MacAB–TolC, 0.1°) are unchanged.
142
+
143
+ **-side, --sidedness** — (Default: `auto`) Which way up the protein goes. The membrane alone does not show which side is which, so with `auto` the protein is turned over where needed to follow Insane4MemPrO's convention: `-u` is the extracellular (non-cytoplasmic) side, up, and `-l` the cytoplasmic side, at −z, in every membrane. In an organelle `-l` is the side positive-inside points to (the matrix, the stroma); in the outer membrane it is the periplasm.
144
+
145
+ Outer-membrane proteins and lipoproteins (β-barrels, or lipid anchors with no helices across the membrane), strongest rule first:
146
+ - Lipid anchors (CYST, CYSD, CYSP, CYSM, CYSK, CYSL, CYSF, CYSG, GLYM, or any four-letter CYS*/GLY* residue with beads beyond its side chain) are in the periplasmic leaflet.
147
+ - A β-barrel chain's last strand runs into the periplasm (the C-terminal β-signal), so where a barrel chain finally leaves the membrane is periplasmic. Chain ends are found from breaks in the backbone, as `martinize2 -merge all` numbers merged chains straight through.
148
+ - Only if neither applies: a β-barrel's extracellular loops are longer than its periplasmic turns (at least 1.5 times, by median).
149
+
150
+ Helical membrane proteins: positive-inside. The side with at least twice as many Lys and Arg within 1 nm of the membrane, and at least 3 more, is cytoplasmic. Lipid anchors are not used for helical proteins: a lipoprotein's anchor is periplasmic in either membrane, which is `-l` in the outer membrane but `-u` in the inner one.
151
+
152
+ A protein left as found is as likely to be wrong as right, so where these thresholds are not met the weaker evidence still decides, and the log prints a `WARNING` that the decision is low-confidence: any difference in loop length, then in Lys/Arg (β-barrels), or in Lys/Arg (helical proteins). Only a protein with no evidence at all, or whose anchors and C-terminal strands disagree, keeps MemPrO's orientation, also with a warning. Check every protein with a warning, and use `-flip` if it is wrong. The log prints rank 1's decision and its evidence, and each `info_rank_N.txt` gives that rank's.
153
+
154
+ Tested on 22 proteins used to develop the rules (OmpA, OmpF, OmpLA, FhuA, FadL, PagP, TolC, LptD/E, BamA–BCDE, Wza; LacY, GlpT, XylE, AcrB, BtuCD, MsbA, HmuUV, KcsA, MscL, AqpZ, SecYEβ, bacteriorhodopsin), each as MemPrO placed it and turned over: 20 come out the right way up. Wza (an α-helical outer-membrane protein, where positive-inside does not apply) and KcsA without its cytoplasmic domains come out upside down, with the warning. On 19 further proteins not used to develop the rules (OmpX, OmpW, OmpT, NspA, FepA, Tsx, OmpG, LamB; LeuT, EmrD, NorM, FocA, YiiP, ClC-ec1, MscS, GlpG, Mhp1, BetP, GltPh) 18 came out right; FepA was wrong until segments ending at missing loop residues were no longer taken for chain ends, and is right now. `off` keeps MemPrO's orientation. Not used with `-dm`, where the two membranes already say which side is which: the cytoplasm is at −z there too (tested on MacAB–TolC, `tests/test_dual_membrane.py`).
140
155
 
141
156
  **-itp, --itp_file** — Path to a Martini 3 `.itp` file. Defaults to `martini_v3.itp` in the same directory as `MemPrO.py` (or the installed package directory).
142
157
 
@@ -248,7 +263,7 @@ Lipid names follow the [Martini 3 lipidome](https://github.com/Martini-Force-Fie
248
263
 
249
264
  **-apl** — (Optional, repeatable) Area per lipid (nm²) for one lipid type (`NAME:AREA`), overriding the built-in value. Built-in values are in `lipid_apl` in `Insane4MemPrO.py`: experimental areas from the Martini 3 lipidome benchmark where measured, otherwise the lipidome's Martini 3 single-lipid bilayer areas scaled by 1.04 (the mean ratio of experiment to those simulations, sd 0.03). Ether and plasmalogen lipids take the area of their diacyl analogue +1.5% and +5%. Lipids not listed use a value for their headgroup class (PC, PE, PG, PS, PA, SM, ceramide) or 0.6 nm².
250
265
 
251
- **-grid** — (Default: circular) Lipid grid for flat membranes filling the box. `circular` places lipids on concentric rings; `square` uses a square lattice that is continuous across the periodic boundaries, avoiding close contacts where clipped rings meet at the box edges. Either way a flat leaflet gets (box area)/(area per lipid) lipids before any are removed around the protein. Curved membranes and `-radius` disks always use rings.
266
+ **-grid** — (Default: square) Lipid grid for flat membranes filling the box. `square` uses a square lattice that is continuous across the periodic boundaries; `circular` places lipids on concentric rings, the original Insane grid. Either way a flat leaflet gets (box area)/(area per lipid) lipids before any are removed around the protein, so the counts are the same. Rings do not pack evenly where neighbouring rings meet or are clipped at the box edges: in a 15 × 15 nm outer membrane (KLA over POPE:POPG:CARD 7:2:1) they gave 204 pairs of beads from different lipids closer than 0.40 nm in the KLA leaflet and 49 in the phospholipid leaflet, against 2 and 0 for `square` (with OmpA, 165 and 14 against 9 and 0; pure POPE, 86 against 0). Energy minimisation removes such contacts, so the gain is a cleaner start. Both grids follow MemPrOD deformations (`-def`) equally, as each lipid is moved to the deformed membrane at its own x, y: on LacY with MemPrOD 0.2.1, phosphates sat within 0.03–0.04 nm (rms) of the predicted head planes with either grid, with 0/5 close contacts (upper/lower) for `square` against 48/53 for `circular`. Curved membranes, pores, micelles and `-radius` disks always use rings.
252
267
 
253
268
  **-temp** — (Optional) Temperature (K) for the built-in phospholipid, cardiolipin and phosphoinositide areas, which otherwise refer to ~303 K (or the lowest temperature at which the lipid is fluid, e.g. DPPC 323 K, sphingomyelin 318 K; see `apl_ref_temp`). Areas are scaled by 0.25% per K, the typical fluid-phase expansion. LPS, sterol and hopanoid values are not scaled. Below a lipid's melting temperature (e.g. DPPC, sphingomyelin) the scaled value is not meaningful.
254
269
 
@@ -261,7 +276,7 @@ Lipid names follow the [Martini 3 lipidome](https://github.com/Martini-Force-Fie
261
276
  **-mt** — (Optional) Membrane thickness (nm) between the phosphate planes for `-footprint map`, as fitted by MemPrO; one value, or two comma-separated for the `-l`/`-u` and `-lo`/`-uo` membranes. MemPrO passes it when building with `-bd`. By default each leaflet extends to the phosphate beads of its lipids as built (about 1.65 nm from the midplane for POPE).
262
277
 
263
278
  **-enclosed** — (Default: `auto`, or `lipids` with `-ring`) Whether lipids go into regions the protein encloses in the membrane, which lipids cannot reach from the bulk (the inside of a ring or barrel). The modes are:
264
- - `auto` judges each region in each leaflet. A region gets lipids if its narrowest core slice still has at least 1 nm² free for lipid beads (room for a lipid at every depth) and at least 60% of the residues lining it are hydrophobic, as inside an ATP synthase c-ring. A water-filled porin or channel lumen is left empty. The log prints each region's narrowest free area, number of lining residues and hydrophobic fraction, and the decision.
279
+ - `auto` judges each region in each leaflet it is enclosed in. A region gets lipids if its narrowest core slice still has at least 1 nm² free for lipid beads (room for a lipid at every depth) and at least 60% of the residues lining it are hydrophobic, as inside an ATP synthase c-ring. Lipid-anchored residues count as hydrophobic: CYST, CYSD, CYSP, CYSM, CYSK, CYSL, CYSF, CYSG and GLYM, and any other four-letter CYS*/GLY* residue with beads beyond its own side chain, so a ring of lipoprotein anchors in one leaflet (such as the PqiC octamer) is filled with lipids. A water-filled porin or channel lumen is left empty. The log prints each region's narrowest free area (`open` in a leaflet where the region joins the bulk membrane), number of lining residues and hydrophobic fraction, and the decision.
265
280
  - `lipids` puts lipids in every enclosed region (the same as `-ring`).
266
281
  - `empty` leaves every enclosed region empty (the behaviour before `-enclosed`).
267
282
 
@@ -269,10 +269,12 @@ lipidsa.update({ # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1
269
269
 
270
270
 
271
271
 
272
+ # KLA template: bead centres of the CHARMM36 Kdo2-lipid A in cg2at (fragments/.../KLA.pdb), x/y in units of 0.25 nm
273
+ # scaled by 0.7 (so lipids fit at 1.67 nm^2 with random rotations), z in units of 0.3 nm (-bd)
272
274
  moltype = "LPS"
273
- lipidsx[moltype] = (-7.97, -8.52, -7.94, -8.14, -8.52, -7.87, -8.75, -8.77, -8.61, -8.58, -8.58, -7.69, -7.53, -7.47, -7.58, -7.45, -7.46, -7.37, -7.42, -6.88, -7.56, -7.11, -7.53, -7.26, -7.32, -7.42, -7.54, -8.07, -8.19, -8.44, -7.19, -6.72, -6.82, -6.81, -7.53, -7.74, -7.88, -7.67, -7.41, -7.86, -7.65, -7.51, -7.25, -7.68, -7.39, -7.84, -7.63, -7.18, -7.29)
274
- lipidsy[moltype] = (0.73, 0.52, 0.60, 0.62, 0.07, 0.51, 0.27, 0.54, 0.70, 0.96, 1.25, 0.51, 0.52, 0.58, 0.76, 0.49, 0.22, 0.10, 0.27, -0.31, -0.04, 0.72, -0.20, -0.29, -0.41, -0.51, -0.60, -0.35, -0.32, -0.13, 1.00, 1.26, 1.42, 1.75, 1.32, 1.56, 1.78, 0.33, 0.52, 0.52, 0.45, 0.85, 0.02, 0.31, -0.05, 0.19, 0.15, 0.58, -0.14)
275
- lipidsz[moltype] = (5.76, 5.32, 5.25, 5.44, 5.95, 4.51, 4.75, 4.25, 3.59, 2.78, 1.97, 4.00, 3.31, 2.47, 1.63, 6.12, 6.82, 6.30, 6.41, 6.10, 5.61, 5.60, 5.04, 4.41, 3.69, 2.97, 2.11, 4.54, 3.72, 2.80, 5.03, 4.58, 3.76, 2.85, 4.46, 3.68, 2.75, 7.59, 8.18, 8.03, 7.93, 7.36, 8.26, 8.81, 9.30, 9.27, 9.13, 8.95, 9.81)
275
+ lipidsx[moltype] = (0.22, 0.15, -0.41, -0.43, -0.98, -0.64, 0.60, 1.40, 1.53, 1.00, 0.65, -0.54, -0.08, 0.52, 1.04, -0.01, -0.52, -0.10, -0.51, -0.83, 0.12, -0.49, 0.00, 0.64, 1.29, 1.22, 1.12, -0.06, -0.10, -0.08, -1.19, -1.41, -1.27, -1.11, -0.77, -0.85, -0.65, -0.42, -0.78, -0.02, -0.47, -1.20, -0.60, 1.15, 0.66, 1.14, 0.81, 0.80, 0.47)
276
+ lipidsy[moltype] = (-0.36, -0.99, -1.11, -0.79, -1.40, -1.28, -1.09, -0.73, 0.19, 0.90, 1.13, -1.54, -0.99, -1.01, -0.94, 1.14, 0.85, 0.51, 0.55, 1.35, 0.11, 1.50, 0.17, -0.40, -0.36, 0.17, 0.67, 0.27, 0.08, -0.04, 0.36, -0.12, -0.08, -0.84, 1.18, 1.18, 1.09, -0.33, 0.27, 0.20, 0.53, -0.37, 1.00, 0.16, -0.20, -0.00, -0.43, 0.65, -0.82)
277
+ lipidsz[moltype] = (7.43, 6.90, 5.68, 6.39, 6.80, 4.71, 5.67, 5.40, 4.79, 4.34, 3.04, 3.45, 2.75, 2.03, 1.49, 5.85, 7.87, 7.00, 8.01, 6.83, 6.03, 4.86, 4.90, 4.10, 3.35, 2.33, 1.25, 3.49, 2.22, 1.00, 5.16, 3.82, 2.51, 1.87, 3.88, 2.66, 1.52, 8.70, 8.59, 8.94, 8.62, 8.10, 8.91, 8.99, 8.84, 9.72, 9.52, 8.14, 8.89)
276
278
  lipidsa.update({ "KLA":(moltype, "ZM1 ZM2 ZM3 VS1 PO1 ZM4 ZM5 CF C1F C2F C3F CE C1E C2E C3E GM1 GM2 GM3 VS2 PO2 GM4 GM5 CAB C1A C2A C3A C4A C1B C2B C3B CCD C1C C2C C3C C1D C2D C3D KR1 KR2 KR3 VS3 KS1 KS2 KR4 KR5 KR6 VS4 KS3 KS4")})
277
279
 
278
280
 
@@ -534,9 +536,10 @@ def get_apl(name):
534
536
  # core slices where it is free; a barrel open to the bulk at a single depth (e.g. a gap at the end of a porin barrel)
535
537
  # stays enclosed. Regions that are not reachable (the inside of a closed barrel) are blocked unless
536
538
  # enclosed_free (-enclosed lipids, or -ring). With enclosed_free="auto" (-enclosed auto) each such region is judged in
537
- # each leaflet: it gets lipids if its narrowest core slice still has FP_ENCLOSED_MIN_AREA free (room for a lipid at every
538
- # depth) and at least FP_ENCLOSED_MIN_HYDROPHOBIC of the residues lining it are hydrophobic (as inside a c-ring, unlike
539
- # the water-filled lumen of a porin or channel).
539
+ # each leaflet it is enclosed in (a ring of lipid anchors encloses a region in one leaflet only): it gets lipids if its
540
+ # narrowest core slice still has FP_ENCLOSED_MIN_AREA free (room for a lipid at every depth) and at least
541
+ # FP_ENCLOSED_MIN_HYDROPHOBIC of the residues lining it are hydrophobic (as inside a c-ring, unlike the water-filled
542
+ # lumen of a porin or channel). Lipid-anchored residues count as hydrophobic.
540
543
  import numpy as np
541
544
  from scipy import ndimage
542
545
  from scipy.spatial import cKDTree
@@ -560,6 +563,11 @@ FP_REACH_FRACTION = 0.5
560
563
  FP_ENCLOSED_MIN_AREA = 1.0
561
564
  FP_ENCLOSED_MIN_HYDROPHOBIC = 0.6
562
565
  FP_HYDROPHOBIC = {"ALA","VAL","LEU","ILE","MET","PHE","TRP","CYS","PRO"}
566
+ # Lipid-anchored residues, which also count as hydrophobic lining: these names (CCD2MD and martinize2: acylated,
567
+ # prenylated and myristoylated Cys and Gly), and any other four-letter CYS*/GLY* residue with beads or atoms beyond
568
+ # its own side chain (its lipid), so an anchor without a name here is still recognised
569
+ FP_LIPID_ANCHORS = {"CYST","CYSD","CYSP","CYSM","CYSK","CYSL","CYSF","CYSG","GLYM"}
570
+ FP_ANCHOR_SIDE = {"CYS":{"SC1","CB","SG"},"GLY":set()}
563
571
  # Backbone atoms and beads, which do not count towards the lining of an enclosed region
564
572
  FP_BACKBONE = {"N","CA","C","O","OXT","BB"}
565
573
  # Non-protein residues that may be in a protein file (MemPrO membrane dummies, water, ions)
@@ -628,8 +636,9 @@ def footprint_maps(prot_xyz,prot_r,box_xy,mid,half_up,half_lo,enclosed_free=Fals
628
636
  blocked), "free" and "footprint" (nm^2).
629
637
  enclosed_free: False (regions the protein encloses are blocked), True (they are free) or "auto", which needs
630
638
  lining = (atomnames, resnames, residue serial numbers) of the protein beads; "enclosed" then lists each enclosed
631
- region with its "mask", "narrowest" and "mean" free area per leaflet (nm^2), lining "residues", "hydrophobic"
632
- fraction, "centre" and "lipids" (whether each leaflet gets lipids there).
639
+ region with its "mask", and per leaflet its "masks" (the part enclosed in that leaflet), "narrowest" and "mean"
640
+ free area (nm^2) and "lipids" (whether it gets lipids there; all None in a leaflet the region is open in), and its
641
+ lining "residues", "hydrophobic" fraction and "centre".
633
642
  """
634
643
  box_xy = np.asarray(box_xy,dtype=float)[:2]
635
644
  nx,ny,px,py = fp_grid(box_xy,pixel)
@@ -682,31 +691,36 @@ def footprint_maps(prot_xyz,prot_r,box_xy,mid,half_up,half_lo,enclosed_free=Fals
682
691
  free = {name:([free_at(z) for z in core],[free_at(z) for z in heads]) for name,(core,heads) in slices.items()}
683
692
  enclosed = []
684
693
  if enclosed_free is not True:
685
- anywhere = np.zeros(shape,dtype=bool)
686
- allowed = {}
694
+ allowed,enclosed_in = {},{}
687
695
  for name,(core,_) in free.items():
688
696
  nfree = np.sum(core,axis=0)
689
697
  nmain = np.sum([fp_main_component(f) for f in core],axis=0)
690
698
  allowed[name] = (nmain > 0)&(nmain >= FP_REACH_FRACTION*nfree)
691
- anywhere |= nfree > 0
692
- reachable = allowed["upper"]|allowed["lower"]
699
+ enclosed_in[name] = (nfree > 0)&~allowed[name]
693
700
  if enclosed_free == "auto":
694
701
  if lining is None:
695
702
  raise ValueError("enclosed_free='auto' needs lining")
696
703
  side = ~np.isin(names,list(FP_BACKBONE))&~np.char.startswith(names.astype(str),"H")
697
704
  resname_of = dict(zip(resi.tolist(),resn.tolist()))
698
- lab,n = ndimage.label(anywhere&~reachable,structure=np.ones((3,3),dtype=int))
705
+ anchored = {r for r,rn,a,s_ in zip(resi.tolist(),resn.tolist(),names.tolist(),side.tolist()) if rn in FP_LIPID_ANCHORS
706
+ or (s_ and len(rn) == 4 and rn[:3] in FP_ANCHOR_SIDE and a not in FP_ANCHOR_SIDE[rn[:3]])}
707
+ lab,n = ndimage.label(enclosed_in["upper"]|enclosed_in["lower"],structure=np.ones((3,3),dtype=int))
699
708
  for c in range(1,n+1):
700
709
  comp = lab == c
701
- region = {"mask":comp,"narrowest":{},"mean":{},"lipids":{}}
710
+ region = {"mask":comp,"masks":{},"narrowest":{},"mean":{},"lipids":{}}
702
711
  lined = set()
703
712
  for name,(core,_) in free.items():
704
- counts = [(f&comp).sum() for f in core]
713
+ leaf = comp&enclosed_in[name]
714
+ region["masks"][name] = leaf
715
+ if not leaf.any():
716
+ region["narrowest"][name] = region["mean"][name] = region["lipids"][name] = None
717
+ continue
718
+ counts = [(f&leaf).sum() for f in core]
705
719
  region["narrowest"][name] = min(counts)*px*py
706
720
  region["mean"][name] = np.mean(counts)*px*py
707
721
  #Residues with a side chain within reach of a lipid bead in the region, slice by slice
708
722
  for z,f in zip(slices[name][0],core):
709
- fc = (f&comp).ravel()
723
+ fc = (f&leaf).ravel()
710
724
  if not fc.any() or not len(pts):
711
725
  continue
712
726
  zf = np.ravel(z)[fc].mean()
@@ -716,15 +730,17 @@ def footprint_maps(prot_xyz,prot_r,box_xy,mid,half_up,half_lo,enclosed_free=Fals
716
730
  reach_xy = np.sqrt(np.maximum((rads[near_z]+lipid_r+0.3)**2-(pts[near_z,2]-zf)**2,0))
717
731
  d,_ = cKDTree(pix[fc],boxsize=box_xy).query(fp_wrap(pts[near_z,:2],box_xy))
718
732
  lined.update(resi[near_z][d < reach_xy].tolist())
719
- if max(region["mean"].values()) < 0.05:
733
+ if max(v for v in region["mean"].values() if v is not None) < 0.05:
720
734
  continue
721
735
  region["residues"] = len(lined)
722
- region["hydrophobic"] = sum(resname_of[r] in FP_HYDROPHOBIC for r in lined)/len(lined) if lined else 0.0
736
+ region["hydrophobic"] = sum(resname_of[r] in FP_HYDROPHOBIC or r in anchored for r in lined)/len(lined) if lined else 0.0
723
737
  region["centre"] = (float(gx[comp].mean()),float(gy[comp].mean()))
724
738
  for name in free:
739
+ if region["narrowest"][name] is None:
740
+ continue
725
741
  region["lipids"][name] = bool(region["narrowest"][name] >= FP_ENCLOSED_MIN_AREA and region["hydrophobic"] >= FP_ENCLOSED_MIN_HYDROPHOBIC)
726
742
  if region["lipids"][name]:
727
- allowed[name] |= comp
743
+ allowed[name] |= region["masks"][name]
728
744
  enclosed.append(region)
729
745
  free = {name:([f&allowed[name] for f in core],[f&allowed[name] for f in heads]) for name,(core,heads) in free.items()}
730
746
 
@@ -3421,7 +3437,7 @@ are not specified. Curvature can be specified using -curv.
3421
3437
  ("-u_loc", Option(lipU_loc.append, 1, None, "Currently WIP do not use. Lipid type for localisation")),
3422
3438
  ("-micelle", Option(bool, 0, None, "Builds a micelle around a protein instead of a bilayer")),
3423
3439
  ("-radius", Option(float, 1, -1, "Radius of membrane outer disk. This is by default the whole cell")),
3424
- ("-grid", Option(str, 1, "circular", "Lipid grid for flat membranes filling the box: circular (concentric rings) or square (continuous across the periodic boundaries). Curved membranes and -radius disks always use rings")),
3440
+ ("-grid", Option(str, 1, "square", "Lipid grid for flat membranes filling the box: square (continuous across the periodic boundaries) or circular (concentric rings, which pack unevenly where they meet). Curved membranes and -radius disks always use rings")),
3425
3441
  ("-no_lipids", Option(int, 1, -1, "Number of lipids that make up a micelle, this will override area per lipid. Only for use with -micelle")),
3426
3442
  ("-def", Option(str, 1, None, "Input folder containing deformation data from MemPrOD, This cannot be used with -ps or -curv.")),
3427
3443
  """
@@ -3518,6 +3534,11 @@ SpGrid = jnp.array(SphereGridAng(20,np.pi/2))
3518
3534
  #print(SpGrid)
3519
3535
 
3520
3536
  memdata = options["-def"].value
3537
+ #MemPrOD deformations are for one flat membrane: with two membranes they would be applied to both, and MemPrOD's z
3538
+ #shift would move the protein off the positions MemPrO found
3539
+ if memdata and (float(options["-ps"].value) > 1e-5 or abs(float(options["-curv"].value.split(",")[0])) > 1e-9):
3540
+ print("ERROR: -def (MemPrOD deformations) cannot be used with -ps (two membranes) or -curv (a curved membrane)")
3541
+ exit(1)
3521
3542
  if memdata:
3522
3543
  mdata = np.load(memdata+"Membrane_pos.npz")
3523
3544
  membrane_pos = mdata["arr_0"]
@@ -4692,10 +4713,12 @@ if lipL:
4692
4713
  maps = footprint_maps(prot_coords_plain,prot_radii,box_xy,mid,half_up,half_lo,enclosed_free={"auto":"auto","lipids":True,"empty":False}[enclosed_mode],lining=prot_lining)
4693
4714
  for r in maps["enclosed"]:
4694
4715
  gets = [name for name in ("upper","lower") if r["lipids"][name]]
4695
- where = " and ".join(gets)+(" leaflets" if len(gets) == 2 else " leaflet")
4696
- print("Enclosed region at (%.1f, %.1f) nm: narrowest free area %.1f/%.1f nm^2 (upper/lower), %d lining residues, %.0f%% hydrophobic: %s"
4697
- %(r["centre"][0],r["centre"][1],r["narrowest"]["upper"],r["narrowest"]["lower"],r["residues"],100*r["hydrophobic"],
4698
- "lipids in the %s"%where if gets else "left empty"))
4716
+ empty = [name for name in ("upper","lower") if r["lipids"][name] is False]
4717
+ where = lambda names: " and ".join(names)+(" leaflets" if len(names) == 2 else " leaflet")
4718
+ outcome = "left empty" if not gets else "lipids in the %s"%where(gets)+("; %s left empty"%where(empty) if empty else "")
4719
+ area = "/".join("open" if r["narrowest"][name] is None else "%.1f"%r["narrowest"][name] for name in ("upper","lower"))
4720
+ print("Enclosed region at (%.1f, %.1f) nm: narrowest free area %s nm^2 (upper/lower), %d lining residues, %.0f%% hydrophobic: %s"
4721
+ %(r["centre"][0],r["centre"][1],area,r["residues"],100*r["hydrophobic"],outcome))
4699
4722
  if enclosed_mode == "auto" and maps["enclosed"]:
4700
4723
  print(" (-enclosed auto: lipids where the narrowest core slice has at least %.1f nm^2 free and at least %.0f%% of the lining residues are hydrophobic; use -enclosed lipids or empty to override)"
4701
4724
  %(FP_ENCLOSED_MIN_AREA,100*FP_ENCLOSED_MIN_HYDROPHOBIC))
@@ -4747,9 +4770,9 @@ if lipL:
4747
4770
  beads = [prot_coords_plain]
4748
4771
  for r in maps["enclosed"]:
4749
4772
  for name,sgn,half in (("upper",1,half_up),("lower",-1,half_lo)):
4750
- if r["lipids"][name]:
4773
+ if r["lipids"][name] is not False:
4751
4774
  continue
4752
- m = r["mask"][::2,::2]
4775
+ m = r["masks"][name][::2,::2]
4753
4776
  half = np.broadcast_to(np.asarray(half,dtype=float),(nx,ny))[::2,::2][m]
4754
4777
  for k in np.linspace(0,1,int(np.ceil((half.mean()+FP_HEAD)/0.25))+1):
4755
4778
  beads.append(np.column_stack([gx[::2,::2][m],gy[::2,::2][m],mid[::2,::2][m]+sgn*k*(half+FP_HEAD)]))