pychnosz 1.1.1__cp311-cp311-macosx_10_13_x86_64.whl
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.
- pychnosz/.dylibs/libgcc_s.1.1.dylib +0 -0
- pychnosz/.dylibs/libgfortran.5.dylib +0 -0
- pychnosz/.dylibs/libquadmath.0.dylib +0 -0
- pychnosz/__init__.py +129 -0
- pychnosz/biomolecules/__init__.py +29 -0
- pychnosz/biomolecules/ionize_aa.py +197 -0
- pychnosz/biomolecules/proteins.py +595 -0
- pychnosz/core/__init__.py +46 -0
- pychnosz/core/affinity.py +1256 -0
- pychnosz/core/animation.py +593 -0
- pychnosz/core/balance.py +334 -0
- pychnosz/core/basis.py +716 -0
- pychnosz/core/diagram.py +3336 -0
- pychnosz/core/equilibrate.py +813 -0
- pychnosz/core/equilibrium.py +554 -0
- pychnosz/core/info.py +821 -0
- pychnosz/core/retrieve.py +364 -0
- pychnosz/core/speciation.py +580 -0
- pychnosz/core/species.py +599 -0
- pychnosz/core/subcrt.py +1700 -0
- pychnosz/core/thermo.py +593 -0
- pychnosz/core/unicurve.py +1226 -0
- pychnosz/data/__init__.py +11 -0
- pychnosz/data/add_obigt.py +327 -0
- pychnosz/data/extdata/Berman/BDat17_2017.csv +2 -0
- pychnosz/data/extdata/Berman/Ber88_1988.csv +68 -0
- pychnosz/data/extdata/Berman/Ber90_1990.csv +5 -0
- pychnosz/data/extdata/Berman/DS10_2010.csv +6 -0
- pychnosz/data/extdata/Berman/FDM+14_2014.csv +2 -0
- pychnosz/data/extdata/Berman/Got04_2004.csv +5 -0
- pychnosz/data/extdata/Berman/JUN92_1992.csv +3 -0
- pychnosz/data/extdata/Berman/SHD91_1991.csv +12 -0
- pychnosz/data/extdata/Berman/VGT92_1992.csv +2 -0
- pychnosz/data/extdata/Berman/VPT01_2001.csv +3 -0
- pychnosz/data/extdata/Berman/VPV05_2005.csv +2 -0
- pychnosz/data/extdata/Berman/ZS92_1992.csv +11 -0
- pychnosz/data/extdata/Berman/sympy.R +99 -0
- pychnosz/data/extdata/Berman/testing/BA96.bib +12 -0
- pychnosz/data/extdata/Berman/testing/BA96_Berman.csv +21 -0
- pychnosz/data/extdata/Berman/testing/BA96_OBIGT.csv +21 -0
- pychnosz/data/extdata/Berman/testing/BA96_refs.csv +6 -0
- pychnosz/data/extdata/OBIGT/AD.csv +25 -0
- pychnosz/data/extdata/OBIGT/Berman_cr.csv +93 -0
- pychnosz/data/extdata/OBIGT/DEW.csv +211 -0
- pychnosz/data/extdata/OBIGT/H2O_aq.csv +4 -0
- pychnosz/data/extdata/OBIGT/SLOP98.csv +411 -0
- pychnosz/data/extdata/OBIGT/SUPCRT92.csv +178 -0
- pychnosz/data/extdata/OBIGT/inorganic_aq.csv +729 -0
- pychnosz/data/extdata/OBIGT/inorganic_cr.csv +273 -0
- pychnosz/data/extdata/OBIGT/inorganic_gas.csv +20 -0
- pychnosz/data/extdata/OBIGT/organic_aq.csv +1104 -0
- pychnosz/data/extdata/OBIGT/organic_cr.csv +481 -0
- pychnosz/data/extdata/OBIGT/organic_gas.csv +268 -0
- pychnosz/data/extdata/OBIGT/organic_liq.csv +533 -0
- pychnosz/data/extdata/OBIGT/testing/GEMSFIT.csv +43 -0
- pychnosz/data/extdata/OBIGT/testing/IGEM.csv +17 -0
- pychnosz/data/extdata/OBIGT/testing/Sandia.csv +8 -0
- pychnosz/data/extdata/OBIGT/testing/SiO2.csv +4 -0
- pychnosz/data/extdata/misc/AD03_Fig1a.csv +69 -0
- pychnosz/data/extdata/misc/AD03_Fig1b.csv +43 -0
- pychnosz/data/extdata/misc/AD03_Fig1c.csv +89 -0
- pychnosz/data/extdata/misc/AD03_Fig1d.csv +30 -0
- pychnosz/data/extdata/misc/BZA10.csv +5 -0
- pychnosz/data/extdata/misc/HW97_Cp.csv +90 -0
- pychnosz/data/extdata/misc/HWM96_V.csv +229 -0
- pychnosz/data/extdata/misc/LA19_test.csv +7 -0
- pychnosz/data/extdata/misc/Mer75_Table4.csv +42 -0
- pychnosz/data/extdata/misc/OBIGT_check.csv +423 -0
- pychnosz/data/extdata/misc/PM90.csv +7 -0
- pychnosz/data/extdata/misc/RH95.csv +23 -0
- pychnosz/data/extdata/misc/RH98_Table15.csv +17 -0
- pychnosz/data/extdata/misc/SC10_Rainbow.csv +19 -0
- pychnosz/data/extdata/misc/SK95.csv +55 -0
- pychnosz/data/extdata/misc/SOJSH.csv +61 -0
- pychnosz/data/extdata/misc/SS98_Fig5a.csv +81 -0
- pychnosz/data/extdata/misc/SS98_Fig5b.csv +84 -0
- pychnosz/data/extdata/misc/TKSS14_Fig2.csv +25 -0
- pychnosz/data/extdata/misc/bluered.txt +1000 -0
- pychnosz/data/extdata/protein/Cas/Cas_aa.csv +177 -0
- pychnosz/data/extdata/protein/Cas/Cas_uniprot.csv +186 -0
- pychnosz/data/extdata/protein/Cas/download.R +34 -0
- pychnosz/data/extdata/protein/Cas/mkaa.R +34 -0
- pychnosz/data/extdata/protein/POLG.csv +12 -0
- pychnosz/data/extdata/protein/TBD+05.csv +393 -0
- pychnosz/data/extdata/protein/TBD+05_aa.csv +393 -0
- pychnosz/data/extdata/protein/rubisco.csv +28 -0
- pychnosz/data/extdata/protein/rubisco.fasta +239 -0
- pychnosz/data/extdata/protein/rubisco_aa.csv +28 -0
- pychnosz/data/extdata/src/H2O92D.f.orig +3457 -0
- pychnosz/data/extdata/src/README.txt +5 -0
- pychnosz/data/extdata/taxonomy/names.dmp +215 -0
- pychnosz/data/extdata/taxonomy/nodes.dmp +63 -0
- pychnosz/data/extdata/thermo/Bdot_acirc.csv +60 -0
- pychnosz/data/extdata/thermo/buffer.csv +40 -0
- pychnosz/data/extdata/thermo/element.csv +135 -0
- pychnosz/data/extdata/thermo/groups.csv +6 -0
- pychnosz/data/extdata/thermo/opt.csv +2 -0
- pychnosz/data/extdata/thermo/protein.csv +506 -0
- pychnosz/data/extdata/thermo/refs.csv +343 -0
- pychnosz/data/extdata/thermo/stoich.csv.xz +0 -0
- pychnosz/data/loader.py +431 -0
- pychnosz/data/mod_obigt.py +322 -0
- pychnosz/data/obigt.py +471 -0
- pychnosz/data/worm.py +228 -0
- pychnosz/fortran/__init__.py +16 -0
- pychnosz/fortran/h2o92.dylib +0 -0
- pychnosz/fortran/h2o92_interface.py +527 -0
- pychnosz/geochemistry/__init__.py +21 -0
- pychnosz/geochemistry/minerals.py +514 -0
- pychnosz/geochemistry/redox.py +500 -0
- pychnosz/models/__init__.py +47 -0
- pychnosz/models/archer_wang.py +165 -0
- pychnosz/models/berman.py +309 -0
- pychnosz/models/cgl.py +381 -0
- pychnosz/models/dew.py +997 -0
- pychnosz/models/hkf.py +523 -0
- pychnosz/models/hkf_helpers.py +222 -0
- pychnosz/models/iapws95.py +1113 -0
- pychnosz/models/supcrt92_fortran.py +238 -0
- pychnosz/models/water.py +480 -0
- pychnosz/utils/__init__.py +27 -0
- pychnosz/utils/expression.py +1074 -0
- pychnosz/utils/formula.py +830 -0
- pychnosz/utils/formula_ox.py +227 -0
- pychnosz/utils/reset.py +33 -0
- pychnosz/utils/units.py +259 -0
- pychnosz-1.1.1.dist-info/METADATA +197 -0
- pychnosz-1.1.1.dist-info/RECORD +131 -0
- pychnosz-1.1.1.dist-info/WHEEL +5 -0
- pychnosz-1.1.1.dist-info/licenses/LICENSE.txt +19 -0
- pychnosz-1.1.1.dist-info/top_level.txt +1 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
pychnosz/__init__.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pyCHNOSZ: Thermodynamic Calculations and Diagrams for Geochemistry
|
|
3
|
+
|
|
4
|
+
An integrated set of tools for thermodynamic calculations in aqueous geochemistry
|
|
5
|
+
and geobiochemistry. Functions are provided for writing balanced reactions to form
|
|
6
|
+
species from user-selected basis species and for calculating the standard molal
|
|
7
|
+
properties of species and reactions, including the standard Gibbs energy and
|
|
8
|
+
equilibrium constant.
|
|
9
|
+
|
|
10
|
+
Python port of the CHNOSZ package for R. The original CHNOSZ package belongs to Dr. Jeffrey Dick.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
__version__ = "1.1.0"
|
|
14
|
+
__author__ = "Grayson Boyer"
|
|
15
|
+
__email__ = "gmboyer@asu.edu"
|
|
16
|
+
|
|
17
|
+
# Import main classes and functions
|
|
18
|
+
from .core.thermo import ThermoSystem, thermo
|
|
19
|
+
from .core.basis import basis
|
|
20
|
+
from .core.species import species
|
|
21
|
+
from .core.info import info
|
|
22
|
+
from .core.retrieve import retrieve
|
|
23
|
+
from .models.water import water
|
|
24
|
+
from .utils.reset import reset
|
|
25
|
+
|
|
26
|
+
# Import equation of state functions
|
|
27
|
+
from .models.hkf import hkf, gfun
|
|
28
|
+
from .models.cgl import cgl, quartz_coesite
|
|
29
|
+
from .models.hkf_helpers import calc_logK, calc_G_TP, G2logK, dissrxn2logK, OBIGT2eos
|
|
30
|
+
|
|
31
|
+
# Import implemented functions
|
|
32
|
+
from .core.subcrt import subcrt
|
|
33
|
+
from .core.balance import balance_reaction, format_reaction
|
|
34
|
+
from .data.add_obigt import add_OBIGT, list_OBIGT_files, reset_OBIGT
|
|
35
|
+
from .data.mod_obigt import mod_OBIGT
|
|
36
|
+
from .data.worm import load_WORM, reset_WORM
|
|
37
|
+
from .models.berman import Berman
|
|
38
|
+
from .utils.formula import makeup, mass, entropy, ZC
|
|
39
|
+
from .utils.formula_ox import get_formula_ox, get_n_element_ox
|
|
40
|
+
from .utils.expression import ratlab, ratlab_html, expr_species, syslab, syslab_html, describe_property, describe_property_html, describe_basis, describe_basis_html, add_legend, set_title
|
|
41
|
+
from .utils.units import convert, envert
|
|
42
|
+
|
|
43
|
+
# Implemented functions
|
|
44
|
+
from .core.affinity import affinity
|
|
45
|
+
from .core.diagram import diagram, diagram_interactive, water_lines, find_tp, copy_plot
|
|
46
|
+
from .core.equilibrate import equilibrate
|
|
47
|
+
from .core.unicurve import unicurve, univariant_TP
|
|
48
|
+
|
|
49
|
+
# Optional: animation requires plotly (install with: pip install pychnosz[interactive])
|
|
50
|
+
try:
|
|
51
|
+
from .core.animation import animation
|
|
52
|
+
except ImportError:
|
|
53
|
+
# plotly not installed, create stub function with helpful error message
|
|
54
|
+
def animation(*args, **kwargs):
|
|
55
|
+
raise ImportError(
|
|
56
|
+
"The 'animation' function requires plotly, which is not installed. "
|
|
57
|
+
"Install it with: pip install pychnosz[interactive]"
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# Protein functions
|
|
61
|
+
from .biomolecules.proteins import pinfo, add_protein, protein_length, protein_formula, protein_OBIGT, protein_basis, group_formulas
|
|
62
|
+
from .biomolecules.ionize_aa import ionize_aa
|
|
63
|
+
|
|
64
|
+
__all__ = [
|
|
65
|
+
'ThermoSystem',
|
|
66
|
+
'thermo',
|
|
67
|
+
'basis',
|
|
68
|
+
'species',
|
|
69
|
+
'info',
|
|
70
|
+
'retrieve',
|
|
71
|
+
'water',
|
|
72
|
+
'reset',
|
|
73
|
+
'subcrt',
|
|
74
|
+
'balance_reaction',
|
|
75
|
+
'format_reaction',
|
|
76
|
+
'affinity',
|
|
77
|
+
'diagram',
|
|
78
|
+
'diagram_interactive',
|
|
79
|
+
'water_lines',
|
|
80
|
+
'find_tp',
|
|
81
|
+
'copy_plot',
|
|
82
|
+
'equilibrate',
|
|
83
|
+
'animation',
|
|
84
|
+
'unicurve',
|
|
85
|
+
'univariant_TP',
|
|
86
|
+
'add_OBIGT',
|
|
87
|
+
'mod_OBIGT',
|
|
88
|
+
'list_OBIGT_files',
|
|
89
|
+
'reset_OBIGT',
|
|
90
|
+
'load_WORM',
|
|
91
|
+
'reset_WORM',
|
|
92
|
+
'Berman',
|
|
93
|
+
'makeup',
|
|
94
|
+
'mass',
|
|
95
|
+
'entropy',
|
|
96
|
+
'ZC',
|
|
97
|
+
'get_formula_ox',
|
|
98
|
+
'get_n_element_ox',
|
|
99
|
+
'ratlab',
|
|
100
|
+
'ratlab_html',
|
|
101
|
+
'expr_species',
|
|
102
|
+
'syslab',
|
|
103
|
+
'syslab_html',
|
|
104
|
+
'describe_property',
|
|
105
|
+
'describe_property_html',
|
|
106
|
+
'describe_basis',
|
|
107
|
+
'describe_basis_html',
|
|
108
|
+
'add_legend',
|
|
109
|
+
'set_title',
|
|
110
|
+
'hkf',
|
|
111
|
+
'gfun',
|
|
112
|
+
'cgl',
|
|
113
|
+
'quartz_coesite',
|
|
114
|
+
'calc_logK',
|
|
115
|
+
'calc_G_TP',
|
|
116
|
+
'G2logK',
|
|
117
|
+
'dissrxn2logK',
|
|
118
|
+
'OBIGT2eos',
|
|
119
|
+
'convert',
|
|
120
|
+
'envert',
|
|
121
|
+
'pinfo',
|
|
122
|
+
'add_protein',
|
|
123
|
+
'protein_length',
|
|
124
|
+
'protein_formula',
|
|
125
|
+
'protein_OBIGT',
|
|
126
|
+
'protein_basis',
|
|
127
|
+
'group_formulas',
|
|
128
|
+
'ionize_aa'
|
|
129
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Biomolecule thermodynamics package for CHNOSZ.
|
|
3
|
+
|
|
4
|
+
This package provides thermodynamic calculations for biological molecules
|
|
5
|
+
including proteins, amino acids, and other biomolecules.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .proteins import (
|
|
9
|
+
pinfo,
|
|
10
|
+
add_protein,
|
|
11
|
+
protein_length,
|
|
12
|
+
protein_formula,
|
|
13
|
+
protein_OBIGT,
|
|
14
|
+
protein_basis,
|
|
15
|
+
group_formulas
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
from .ionize_aa import ionize_aa
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
'pinfo',
|
|
22
|
+
'add_protein',
|
|
23
|
+
'protein_length',
|
|
24
|
+
'protein_formula',
|
|
25
|
+
'protein_OBIGT',
|
|
26
|
+
'protein_basis',
|
|
27
|
+
'group_formulas',
|
|
28
|
+
'ionize_aa'
|
|
29
|
+
]
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Amino acid ionization calculations for CHNOSZ.
|
|
3
|
+
|
|
4
|
+
This module calculates ionization properties of proteins based on
|
|
5
|
+
amino acid composition.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import pandas as pd
|
|
10
|
+
from typing import Union, Optional
|
|
11
|
+
|
|
12
|
+
from ..core.thermo import thermo
|
|
13
|
+
from ..core.subcrt import subcrt
|
|
14
|
+
from ..core.info import info
|
|
15
|
+
from ..utils.units import convert
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def ionize_aa(aa: pd.DataFrame,
|
|
19
|
+
property: str = "Z",
|
|
20
|
+
T: Union[float, np.ndarray] = 25.0,
|
|
21
|
+
P: Union[float, str, np.ndarray] = "Psat",
|
|
22
|
+
pH: Union[float, np.ndarray] = 7.0,
|
|
23
|
+
ret_val: Optional[str] = None,
|
|
24
|
+
suppress_Cys: bool = False) -> pd.DataFrame:
|
|
25
|
+
"""
|
|
26
|
+
Calculate additive ionization properties of proteins.
|
|
27
|
+
|
|
28
|
+
This function calculates the net charge or other ionization properties
|
|
29
|
+
of proteins based on amino acid composition at specified T, P, and pH.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
aa : DataFrame
|
|
34
|
+
Amino acid composition data
|
|
35
|
+
property : str, default "Z"
|
|
36
|
+
Property to calculate:
|
|
37
|
+
- "Z": net charge
|
|
38
|
+
- "A": chemical affinity
|
|
39
|
+
- Other subcrt properties (G, H, S, Cp, V)
|
|
40
|
+
T : float or array, default 25.0
|
|
41
|
+
Temperature in degrees Celsius
|
|
42
|
+
P : float, str, or array, default "Psat"
|
|
43
|
+
Pressure in bar, or "Psat" for saturation
|
|
44
|
+
pH : float or array, default 7.0
|
|
45
|
+
pH value(s)
|
|
46
|
+
ret_val : str, optional
|
|
47
|
+
Return value type:
|
|
48
|
+
- "pK": return pK values
|
|
49
|
+
- "alpha": return degree of formation
|
|
50
|
+
- "aavals": return amino acid values
|
|
51
|
+
- None: return ionization property (default)
|
|
52
|
+
suppress_Cys : bool, default False
|
|
53
|
+
Suppress cysteine ionization
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
DataFrame
|
|
58
|
+
Ionization properties
|
|
59
|
+
|
|
60
|
+
Examples
|
|
61
|
+
--------
|
|
62
|
+
>>> from pychnosz import *
|
|
63
|
+
>>> aa = pinfo(pinfo("LYSC_CHICK"))
|
|
64
|
+
>>> Z = ionize_aa(aa, pH=7.0)
|
|
65
|
+
"""
|
|
66
|
+
# Ensure inputs are arrays
|
|
67
|
+
T = np.atleast_1d(T)
|
|
68
|
+
if isinstance(P, str):
|
|
69
|
+
P = np.array([P] * len(T))
|
|
70
|
+
else:
|
|
71
|
+
P = np.atleast_1d(P)
|
|
72
|
+
pH_arr = np.atleast_1d(pH)
|
|
73
|
+
|
|
74
|
+
# Get maximum length and replicate arrays
|
|
75
|
+
lmax = max(len(T), len(P), len(pH_arr))
|
|
76
|
+
T = np.resize(T, lmax)
|
|
77
|
+
if isinstance(P[0], str):
|
|
78
|
+
P = np.array([P[0]] * lmax)
|
|
79
|
+
else:
|
|
80
|
+
P = np.resize(P, lmax)
|
|
81
|
+
pH_arr = np.resize(pH_arr, lmax)
|
|
82
|
+
|
|
83
|
+
# Turn pH into a matrix with as many columns as ionizable groups (9)
|
|
84
|
+
pH_matrix = np.tile(pH_arr[:, np.newaxis], (1, 9))
|
|
85
|
+
|
|
86
|
+
# Charges for ionizable groups
|
|
87
|
+
charges = np.array([-1, -1, -1, 1, 1, 1, -1, 1, -1])
|
|
88
|
+
charges_matrix = np.tile(charges, (lmax, 1))
|
|
89
|
+
|
|
90
|
+
# The ionizable groups
|
|
91
|
+
neutral = ["[Cys]", "[Asp]", "[Glu]", "[His]", "[Lys]", "[Arg]", "[Tyr]", "[AABB]", "[AABB]"]
|
|
92
|
+
charged = ["[Cys-]", "[Asp-]", "[Glu-]", "[His+]", "[Lys+]", "[Arg+]", "[Tyr-]", "[AABB+]", "[AABB-]"]
|
|
93
|
+
|
|
94
|
+
# Get row numbers in OBIGT
|
|
95
|
+
ineutral = [info(g, "aq") for g in neutral]
|
|
96
|
+
icharged = [info(g, "aq") for g in charged]
|
|
97
|
+
|
|
98
|
+
# Get unique T, P combinations
|
|
99
|
+
pTP = [f"{t}_{p}" for t, p in zip(T, P)]
|
|
100
|
+
unique_pTP = []
|
|
101
|
+
seen = set()
|
|
102
|
+
indices = []
|
|
103
|
+
for i, tp in enumerate(pTP):
|
|
104
|
+
if tp not in seen:
|
|
105
|
+
unique_pTP.append(i)
|
|
106
|
+
seen.add(tp)
|
|
107
|
+
indices.append(list(seen).index(tp))
|
|
108
|
+
|
|
109
|
+
# Determine which property to calculate
|
|
110
|
+
sprop = ["G", property] if property not in ["A", "Z"] else ["G"]
|
|
111
|
+
|
|
112
|
+
# Convert T to Kelvin for subcrt
|
|
113
|
+
TK = convert(T, "K")
|
|
114
|
+
|
|
115
|
+
# Call subcrt for unique T, P combinations
|
|
116
|
+
unique_T = TK[unique_pTP]
|
|
117
|
+
unique_P = P[unique_pTP]
|
|
118
|
+
|
|
119
|
+
all_species = ineutral + icharged
|
|
120
|
+
sout = subcrt(all_species, T=unique_T, P=unique_P, property=sprop, convert=False)
|
|
121
|
+
|
|
122
|
+
# Extract G values
|
|
123
|
+
Gs = np.zeros((len(unique_pTP), len(all_species)))
|
|
124
|
+
for i, spec_idx in enumerate(all_species):
|
|
125
|
+
if isinstance(sout['out'], dict):
|
|
126
|
+
# Single species result
|
|
127
|
+
Gs[:, i] = sout['out']['G']
|
|
128
|
+
else:
|
|
129
|
+
# Multiple species result
|
|
130
|
+
Gs[:, i] = sout['out'][i]['G'].values
|
|
131
|
+
|
|
132
|
+
# Gibbs energy difference for each group
|
|
133
|
+
DG = Gs[:, 9:18] - Gs[:, 0:9]
|
|
134
|
+
|
|
135
|
+
# Build matrix for all T, P values (including duplicates)
|
|
136
|
+
DG_full = DG[indices, :]
|
|
137
|
+
|
|
138
|
+
# Calculate pK values
|
|
139
|
+
DG_full = DG_full * charges
|
|
140
|
+
pK = np.zeros_like(DG_full)
|
|
141
|
+
for i in range(pK.shape[1]):
|
|
142
|
+
pK[:, i] = convert(DG_full[:, i], "logK", T=TK)
|
|
143
|
+
|
|
144
|
+
# Return pK if requested
|
|
145
|
+
if ret_val == "pK":
|
|
146
|
+
return pd.DataFrame(pK, columns=charged)
|
|
147
|
+
|
|
148
|
+
# Calculate alpha (degree of formation)
|
|
149
|
+
alpha = 1 / (1 + 10 ** (charges_matrix * (pH_matrix - pK)))
|
|
150
|
+
|
|
151
|
+
# Suppress cysteine ionization if requested
|
|
152
|
+
if suppress_Cys:
|
|
153
|
+
alpha[:, 0] = 0
|
|
154
|
+
|
|
155
|
+
# Return alpha if requested
|
|
156
|
+
if ret_val == "alpha":
|
|
157
|
+
return pd.DataFrame(alpha, columns=charged)
|
|
158
|
+
|
|
159
|
+
# Calculate amino acid values
|
|
160
|
+
if property == "Z":
|
|
161
|
+
aavals = charges_matrix.copy()
|
|
162
|
+
elif property == "A":
|
|
163
|
+
aavals = -charges_matrix * (pH_matrix - pK)
|
|
164
|
+
else:
|
|
165
|
+
# Extract property values from subcrt output
|
|
166
|
+
prop_vals = np.zeros((len(unique_pTP), len(all_species)))
|
|
167
|
+
for i, spec_idx in enumerate(all_species):
|
|
168
|
+
if isinstance(sout['out'], dict):
|
|
169
|
+
prop_vals[:, i] = sout['out'][property]
|
|
170
|
+
else:
|
|
171
|
+
prop_vals[:, i] = sout['out'][i][property].values
|
|
172
|
+
|
|
173
|
+
# Build matrix for all T, P values
|
|
174
|
+
prop_vals_full = prop_vals[indices, :]
|
|
175
|
+
|
|
176
|
+
# Property difference for each group
|
|
177
|
+
aavals = prop_vals_full[:, 9:18] - prop_vals_full[:, 0:9]
|
|
178
|
+
|
|
179
|
+
# Return aavals if requested
|
|
180
|
+
if ret_val == "aavals":
|
|
181
|
+
return pd.DataFrame(aavals, columns=charged)
|
|
182
|
+
|
|
183
|
+
# Contribution from each group
|
|
184
|
+
aavals = aavals * alpha
|
|
185
|
+
|
|
186
|
+
# Get counts of ionizable groups from aa
|
|
187
|
+
# Columns: Cys, Asp, Glu, His, Lys, Arg, Tyr, chains, chains
|
|
188
|
+
ionize_cols = ["Cys", "Asp", "Glu", "His", "Lys", "Arg", "Tyr", "chains", "chains"]
|
|
189
|
+
aa_counts = aa[ionize_cols].values.astype(float)
|
|
190
|
+
|
|
191
|
+
# Calculate total ionization property
|
|
192
|
+
out = np.dot(aavals, aa_counts.T)
|
|
193
|
+
|
|
194
|
+
# Create DataFrame
|
|
195
|
+
result = pd.DataFrame(out)
|
|
196
|
+
|
|
197
|
+
return result
|