cosmopharm 0.0.23__tar.gz → 0.0.23.1__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.
- {cosmopharm-0.0.23/src/cosmopharm.egg-info → cosmopharm-0.0.23.1}/PKG-INFO +1 -1
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/README.md +46 -14
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/setup.cfg +1 -1
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/actmodels/cosmo.py +31 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/components.py +7 -6
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/equilibrium/lle.py +1 -1
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/equilibrium/sle.py +8 -4
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/utils/helpers.py +2 -2
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1/src/cosmopharm.egg-info}/PKG-INFO +1 -1
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/LICENSE +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/setup.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/__init__.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/actmodels/__init__.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/actmodels/actmodel.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/equilibrium/__init__.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/utils/__init__.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/utils/convert.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/utils/lle_scanner.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm/utils/spacing.py +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm.egg-info/SOURCES.txt +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm.egg-info/dependency_links.txt +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm.egg-info/requires.txt +0 -0
- {cosmopharm-0.0.23 → cosmopharm-0.0.23.1}/src/cosmopharm.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: cosmopharm
|
3
|
-
Version: 0.0.23
|
3
|
+
Version: 0.0.23.1
|
4
4
|
Summary: Predictive modeling for drug-polymer compatibility in pharmaceutical formulations using COSMO-SAC.
|
5
5
|
Home-page: https://github.com/ivanantolo/cosmopharm,
|
6
6
|
Author: Ivan Antolovic
|
@@ -5,7 +5,7 @@
|
|
5
5
|
</p>
|
6
6
|
|
7
7
|
|
8
|
-
Welcome to the COSMOPharm repository, accompanying [our paper in *
|
8
|
+
Welcome to the COSMOPharm repository, accompanying [our paper in *Molecular Pharmaceutics*](https://dx.doi.org/10.1021/acs.jctc.9b01016). This project and its associated publication offer insights and a practical toolkit for researching drug-polymer and drug-solvent systems, aiming to provide the scientific community with the means to reproduce our findings and further the development of COSMO-SAC-based models.
|
9
9
|
|
10
10
|
## About
|
11
11
|
|
@@ -35,9 +35,9 @@ For users who need more control over the installation process (e.g., for develop
|
|
35
35
|
|
36
36
|
#### Step 1: Clone the Repository
|
37
37
|
|
38
|
-
First, clone the COSMOPharm repository
|
38
|
+
First, clone the COSMOPharm repository. The project includes a submodule named "pharmaceuticals" that stores essential data files (.sigma, .cosmo, and .xyz files) for the pharmaceutical components. Use the --recurse-submodules option to ensure that the "pharmaceuticals" submodule is correctly initialized and updated along with the main project.
|
39
39
|
```
|
40
|
-
git clone https://github.com/ivanantolo/cosmopharm
|
40
|
+
git clone --recurse-submodules https://github.com/ivanantolo/cosmopharm
|
41
41
|
```
|
42
42
|
|
43
43
|
#### Step 2: Navigate to the Repository Directory
|
@@ -73,22 +73,23 @@ Get started with COSMOPharm using the minimal example below, which demonstrates
|
|
73
73
|
|
74
74
|
|
75
75
|
```python
|
76
|
+
import matplotlib.pyplot as plt
|
76
77
|
import cCOSMO
|
77
78
|
from cosmopharm import SLE, COSMOSAC
|
78
79
|
from cosmopharm.utils import create_components, read_params
|
79
80
|
|
80
|
-
# Define components
|
81
|
-
names = ['
|
82
|
-
params_file = "
|
81
|
+
# Define components
|
82
|
+
names = ['SIM','PLGA50']
|
83
|
+
params_file = "data/sle/table_params.xlsx"
|
83
84
|
|
84
85
|
# Load parameters and create components
|
85
86
|
parameters = read_params(params_file)
|
86
|
-
|
87
|
+
mixture = create_components(names, parameters)
|
87
88
|
|
88
89
|
# Initialize COSMO-SAC model - replace paths with your local paths to COSMO profiles
|
89
90
|
db = cCOSMO.DelawareProfileDatabase(
|
90
|
-
"
|
91
|
-
"
|
91
|
+
"./profiles/_import_methods/UD/complist.txt",
|
92
|
+
"./profiles/_import_methods/UD/sigma3/")
|
92
93
|
|
93
94
|
for name in names:
|
94
95
|
iden = db.normalize_identifier(name)
|
@@ -96,16 +97,32 @@ for name in names:
|
|
96
97
|
COSMO = cCOSMO.COSMO3(names, db)
|
97
98
|
|
98
99
|
# Setup the COSMO-SAC model with components
|
99
|
-
|
100
|
+
actmodel = COSMOSAC(COSMO, mixture=mixture)
|
100
101
|
|
101
102
|
# Calculate solubility (SLE)
|
102
|
-
sle = SLE(
|
103
|
+
sle = SLE(actmodel=actmodel)
|
103
104
|
solubility = sle.solubility(mix='real')
|
104
105
|
|
105
106
|
# Output the solubility
|
106
107
|
print(solubility[['T', 'w', 'x']].to_string(index=False))
|
108
|
+
|
109
|
+
# Plot results
|
110
|
+
plt.plot(*solubility[['w','T']].values.T,'.-', label='Solubility (w)')
|
111
|
+
|
112
|
+
# Settings
|
113
|
+
plt.xlim(0,1)
|
114
|
+
plt.ylim(300,500)
|
115
|
+
# Adding title and labels
|
116
|
+
plt.title('Solubility vs. Temperature')
|
117
|
+
plt.ylabel("T / K")
|
118
|
+
xlabel = {'w':'Weight', 'x':'Mole'}
|
119
|
+
plt.xlabel(f"Weight fraction {mixture[0].name}")
|
120
|
+
plt.legend()
|
121
|
+
# Save the figure to a PNG or PDF file
|
122
|
+
plt.savefig('solubility_plot.png') # Saves the plot as a PNG file
|
123
|
+
# plt.savefig('solubility_plot.pdf') # Saves the plot as a PDF file
|
124
|
+
plt.show()
|
107
125
|
```
|
108
|
-
Replace 'DrugName', 'PolymerName', and file paths with your actual data and files.
|
109
126
|
|
110
127
|
For a more comprehensive demonstration, including advanced functionalities and plotting results, please see the [example_usage.py](https://github.com/ivanantolo/cosmopharm/blob/main/example_usage.py) script in this repository. This detailed example walks through the process of setting up COSMOPharm, initializing models, and visualizing the results of solubility and miscibility calculations.
|
111
128
|
|
@@ -118,8 +135,23 @@ For bugs, feature requests, or other queries, please [open an issue](https://git
|
|
118
135
|
|
119
136
|
## Citation
|
120
137
|
|
121
|
-
If you use COSMOPharm in your research, please
|
122
|
-
|
138
|
+
We appreciate citations to our work as they help acknowledge and spread our research contributions. If you use COSMOPharm in your research, please cite the associated paper. Citation details are provided in the [`CITATION.cff`](https://github.com/ivanantolo/cosmopharm/CITATION.cff) file, and GitHub generates APA or BibTeX formats accessible under the "Cite this repository" dropdown on our repository page.
|
139
|
+
|
140
|
+
For convenience, here's the citation in BibTeX format:
|
141
|
+
|
142
|
+
```bibtex
|
143
|
+
@article{Antolovic2024COSMOPharm,
|
144
|
+
title={COSMOPharm: Drug--Polymer Compatibility of Pharmaceutical Amorphous Solid Dispersions from COSMO-SAC},
|
145
|
+
author={Antolovic, Ivan and Vrabec, Jadran and Klajmon, Martin},
|
146
|
+
journal={Molecular Pharmaceutics},
|
147
|
+
year={2024},
|
148
|
+
volume={1}, # Will be adjusted accordingly
|
149
|
+
issue={1}, # Will be adjusted accordingly
|
150
|
+
month={3}, # Will be adjusted accordingly
|
151
|
+
pages={1--10}, # Will be adjusted accordingly
|
152
|
+
doi={10.1021/acs.molpharmaceut.3c12345} # Will be adjusted accordingly
|
153
|
+
}
|
154
|
+
```
|
123
155
|
|
124
156
|
## License
|
125
157
|
|
@@ -6,7 +6,12 @@ from typing import List, Union, Literal
|
|
6
6
|
from .actmodel import ActModel
|
7
7
|
from ..components import Component
|
8
8
|
|
9
|
+
|
9
10
|
class COSMOSAC(ActModel):
|
11
|
+
# Handling invalid values for free volume calculation
|
12
|
+
class InvalidFreeVolumeParametersException(Exception):
|
13
|
+
pass
|
14
|
+
|
10
15
|
def __init__(self,
|
11
16
|
COSMO: Union[cCOSMO.COSMO1, cCOSMO.COSMO3],
|
12
17
|
mixture: List[Component],
|
@@ -62,6 +67,8 @@ class COSMOSAC(ActModel):
|
|
62
67
|
(can replace ln_gamma_comb of normal COSMO-SAC) - Kuo2013
|
63
68
|
x, v_298, v_hc are 1D arrays (number of elements = number of components)
|
64
69
|
"""
|
70
|
+
# TODO: Make sure, that v_298 and v_hc are provided, else "FV" not possible
|
71
|
+
self.validate_free_volume_parameters() # Ensure components are valid before proceeding
|
65
72
|
v_298 = np.array([comp.v_298 for comp in self.mixture])
|
66
73
|
v_hc = np.array([comp.v_hc for comp in self.mixture])
|
67
74
|
vf = v_298-v_hc
|
@@ -121,3 +128,27 @@ class COSMOSAC(ActModel):
|
|
121
128
|
""" Convenience function to quickly configure COSMO parameters """
|
122
129
|
self._combinatorial = comb
|
123
130
|
self._dispersion = dsp
|
131
|
+
|
132
|
+
|
133
|
+
def validate_free_volume_parameters(self):
|
134
|
+
# List of parameters to validate
|
135
|
+
parameters_to_check = ["v_298", "v_hc"]
|
136
|
+
|
137
|
+
for comp in self.mixture:
|
138
|
+
invalid_params = [] # List to accumulate names of invalid parameters for this component
|
139
|
+
for param in parameters_to_check:
|
140
|
+
value = getattr(comp, param, None)
|
141
|
+
# Check if value is None, not a number (np.nan), less than or equal to 0
|
142
|
+
if value is None or np.isnan(value) or value <= 0:
|
143
|
+
invalid_params.append((param, value)) # Append parameter name and value tuple
|
144
|
+
|
145
|
+
# Check if any errors were found for this component
|
146
|
+
if invalid_params:
|
147
|
+
# If errors were found, construct the warning message
|
148
|
+
error_message = f"Invalid FV parameters for component {comp}: {invalid_params}"
|
149
|
+
raise self.InvalidFreeVolumeParametersException(error_message)
|
150
|
+
|
151
|
+
# Additionally check if v_298 and v_hc are equal
|
152
|
+
if comp.v_298 == comp.v_hc:
|
153
|
+
msg = f"v_298 and v_hc are equal for component {comp}: v_298={comp.v_298}, v_hc={comp.v_hc}"
|
154
|
+
raise self.InvalidFreeVolumeParametersException(msg)
|
@@ -2,12 +2,13 @@ from typing import Optional
|
|
2
2
|
from numbers import Number
|
3
3
|
|
4
4
|
class Component:
|
5
|
-
def __init__(self,
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
def __init__(self,
|
6
|
+
name: Optional[str] = None,
|
7
|
+
Mw: Optional[Number] = None, # Positive number expected
|
8
|
+
T_fus: Optional[Number] = None, # Positive number expected
|
9
|
+
H_fus: Number = 0,
|
10
|
+
Cp_fus_a_fit: Number = 0,
|
11
|
+
Cp_fus_bT_fit: Number = 0,
|
11
12
|
v_298: Optional[Number] = None,
|
12
13
|
v_hc: Optional[Number] = None,
|
13
14
|
):
|
@@ -43,10 +43,14 @@ class SLE:
|
|
43
43
|
args = self.set_args(args)
|
44
44
|
init = self.set_x0(init)
|
45
45
|
gen = self.solve_sle(args, init, solver)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
try:
|
47
|
+
res = [k for k in gen]
|
48
|
+
res = pd.DataFrame(res, columns=['T', 'x', 'vary', 'w'])
|
49
|
+
res = res[['T', 'w', 'x', 'vary']]
|
50
|
+
return res
|
51
|
+
except self.actmodel.InvalidFreeVolumeParametersException as e:
|
52
|
+
print(f"Warning: {e}") # Inform the user
|
53
|
+
return pd.DataFrame(columns=['T', 'w', 'x', 'vary'])
|
50
54
|
|
51
55
|
|
52
56
|
# =============================================================================
|
@@ -21,8 +21,8 @@ def add_parameters(c, params):
|
|
21
21
|
c.Mw = params['Mw'] # g/mol
|
22
22
|
c.T_fus = params['T_fus'] if params['T_fus'] > 0 else np.nan # K
|
23
23
|
c.H_fus = params['H_fus'] * KILOJOULE_TO_JOULE # J/mol
|
24
|
-
c.Cp_fus_A = params['Cp_fus_a_fit'] # J/(mol K)
|
25
|
-
c.Cp_fus_BT = params['Cp_fus_bT_fit'] # J/(mol K²)
|
24
|
+
c.Cp_fus_A = np.nan_to_num(params['Cp_fus_a_fit']) # J/(mol K)
|
25
|
+
c.Cp_fus_BT = np.nan_to_num(params['Cp_fus_bT_fit']) # J/(mol K²)
|
26
26
|
c.v_298 = params['v298'] # cm³/mol
|
27
27
|
c.v_hc = params['v_hc'] # cm³/mol
|
28
28
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: cosmopharm
|
3
|
-
Version: 0.0.23
|
3
|
+
Version: 0.0.23.1
|
4
4
|
Summary: Predictive modeling for drug-polymer compatibility in pharmaceutical formulations using COSMO-SAC.
|
5
5
|
Home-page: https://github.com/ivanantolo/cosmopharm,
|
6
6
|
Author: Ivan Antolovic
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|