cosmopharm 0.0.23__py3-none-any.whl → 0.0.23.1__py3-none-any.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.
@@ -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)
cosmopharm/components.py CHANGED
@@ -2,12 +2,13 @@ from typing import Optional
2
2
  from numbers import Number
3
3
 
4
4
  class Component:
5
- def __init__(self, name: Optional[str] = None,
6
- Mw: Optional[Number] = None,
7
- T_fus: Optional[Number] = None,
8
- H_fus: Optional[Number] = None,
9
- Cp_fus_a_fit: Optional[Number] = None,
10
- Cp_fus_bT_fit: Optional[Number] = None,
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
  ):
@@ -123,4 +123,4 @@ class LLE:
123
123
  else:
124
124
  # If actmodel is neither an instance nor a subclass of ActModel
125
125
  err = "'actmodel' must be an instance or a subclass of 'ActModel'"
126
- raise ValueError(err)
126
+ raise ValueError(err)
@@ -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
- res = [k for k in gen]
47
- res = pd.DataFrame(res, columns=['T', 'x', 'vary', 'w'])
48
- res = res[['T', 'w', 'x', 'vary']]
49
- return res
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
 
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.1
2
+ Name: cosmopharm
3
+ Version: 0.0.23.1
4
+ Summary: Predictive modeling for drug-polymer compatibility in pharmaceutical formulations using COSMO-SAC.
5
+ Home-page: https://github.com/ivanantolo/cosmopharm,
6
+ Author: Ivan Antolovic
7
+ Author-email: Ivan.Antolovic@tu-berlin.de
8
+ Maintainer: Martin Klajmon
9
+ Maintainer-email: Martin.Klajmon@vscht.cz
10
+ License: MIT
11
+ Keywords: Drug-Polymer Compatibility,Amorphous Solid Dispersions,Pharmaceutical Formulation,COSMO-SAC Model,Solubility Prediction,Miscibility Analysis,Phase Behavior Prediction,Pharmaceutical Sciences,Drug Formulation Research,Polymer Science,Predictive Modeling in Pharma,Drug Development Tools,Biopharmaceuticals
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Healthcare Industry
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Education
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
20
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3 :: Only
23
+ Classifier: Programming Language :: Python :: 3.8
24
+ Classifier: Programming Language :: Python :: 3.9
25
+ Classifier: Programming Language :: Python :: 3.10
26
+ Classifier: Programming Language :: Python :: 3.11
27
+ Classifier: Programming Language :: Python :: 3.12
28
+ Classifier: Programming Language :: Python :: 3.13
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: numpy >=1.15
33
+ Requires-Dist: pandas >=1.0
34
+ Requires-Dist: scipy >=1.4
35
+ Requires-Dist: openpyxl >=3.0
36
+ Provides-Extra: examples
37
+ Requires-Dist: matplotlib >=3.0 ; extra == 'examples'
38
+
39
+ # COSMOPharm
40
+
41
+ Welcome to the COSMOPharm package, accompanying [our paper in *J. Chem. Theory Comput.*](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.
42
+
43
+ <p align="center">
44
+ <!-- <img src="https://github.com/usnistgov/COSMOSAC/raw/master/JCTC2020.PNG" alt="TOC Figure" width="500"> -->
45
+ <img src="https://github.com/usnistgov/COSMOSAC/raw/master/JCTC2020.PNG" alt="TOC Figure">
46
+ </p>
47
+
48
+ ## About
49
+
50
+ COSMOPharm is a Python package designed for predictive modeling of drug-polymer compatibility and drug-solubility in common solvents. It leverages the COSMO-SAC (Conductor-like Screening Model Segment Activity Coefficient) model, offering a robust platform for solubility, miscibility, and phase behavior prediction in drug formulation processes.
51
+
52
+ ## Features
53
+
54
+ - **Compatibility Prediction**: Predict drug-polymer compatibility using the open-source COSMO-SAC model.
55
+ - **Solubility Calculation**: Guide polymer selection for drug formulations by calculating drug-polymer solubilities.
56
+ - **Miscibility and Phase Behavior Analysis**: Understand drug-polymer miscibility and phase behavior under various conditions.
57
+ - **User-friendly Interface**: Facilitate research with easy-to-use functions and comprehensive documentation.
58
+
59
+ ## Installation
60
+
61
+ Install COSMOPharm with pip:
62
+
63
+ `pip install cosmopharm`
64
+
65
+ Ensure you have installed the `cCOSMO` library as per instructions on the [COSMOSAC GitHub page](https://github.com/usnistgov/COSMOSAC).
66
+
67
+ ## Quick Start
68
+
69
+ This minimal example demonstrates how to use COSMOPharm to calculate solubility and miscibility of a drug with a polymer:
70
+
71
+ ```python
72
+ import cCOSMO
73
+ from cosmopharm import SLE, COSMOSAC
74
+ from cosmopharm.utils import create_components, read_params
75
+
76
+ # Define components - replace 'DrugName' and 'PolymerName' with your actual component names
77
+ names = ['DrugName', 'PolymerName']
78
+ params_file = "path/to/your/params.xlsx"
79
+
80
+ # Load parameters and create components
81
+ parameters = read_params(params_file)
82
+ components = create_components(names, parameters)
83
+
84
+ # Initialize COSMO-SAC model - replace paths with your local paths to COSMO profiles
85
+ db = cCOSMO.DelawareProfileDatabase(
86
+ "path/to/your/complist/complist.txt",
87
+ "path/to/your/profiles/")
88
+
89
+ for name in names:
90
+ iden = db.normalize_identifier(name)
91
+ db.add_profile(iden)
92
+ COSMO = cCOSMO.COSMO3(names, db)
93
+
94
+ # Setup the COSMO-SAC model with components
95
+ model = COSMOSAC(COSMO, components=components)
96
+
97
+ # Calculate solubility (SLE)
98
+ sle = SLE(solute=components[0], solvent=components[1], actmodel=model)
99
+ solubility = sle.solubility(mix='real')
100
+
101
+ # Output the solubility
102
+ print(solubility[['T', 'w', 'x']].to_string(index=False))
103
+ ```
104
+
105
+ Replace 'DrugName', 'PolymerName', and file paths with your actual data and files. This example provides a straightforward demonstration of calculating the real solubility of a drug in a polymer using COSMOPharm.
106
+
107
+ ## Contributing
108
+
109
+ Contributions are welcome! Please refer to our [GitHub repository](https://github.com/ivanantolo/cosmopharm) for more information.
110
+
111
+ ## Citation
112
+
113
+ If you use COSMOPharm in your research, kindly cite our work. Citation details are available in [CITATION.md](https://github.com/ivanantolo/cosmopharm/CITATION.md).
114
+
115
+ ## License
116
+
117
+ COSMOPharm is released under the MIT License. For more details, see the [LICENSE](https://github.com/ivanantolo/cosmopharm/LICENSE) file.
@@ -0,0 +1,18 @@
1
+ cosmopharm/__init__.py,sha256=sdgLzbqylG8DDAJ5J96YiO4egn9xVJTx2uzaIZ8qj4g,68
2
+ cosmopharm/components.py,sha256=wEQQ0ZNOrFvG9SdhKAzBgqTbT6DtuoTreNBEdLw8Lm0,981
3
+ cosmopharm/actmodels/__init__.py,sha256=9iH67yrdSaf10Fj8LwRikUDUMeMxsvUHRPEaWc3384k,59
4
+ cosmopharm/actmodels/actmodel.py,sha256=69jluNR7Tb4BHwtkCQLI3NQ_0AEZcTDM69IdRPz9--w,5072
5
+ cosmopharm/actmodels/cosmo.py,sha256=tpYboI369rEOIkYgGqLyqgQSfKEgxwONULC4ZKDKIHI,5962
6
+ cosmopharm/equilibrium/__init__.py,sha256=5NsIbQEwELjeeoFEiWelnzHnhTzt5zsBh3r5icn_AIQ,44
7
+ cosmopharm/equilibrium/lle.py,sha256=Ru0_mso43vZNjy8ybdVQeweAsaZoa_yJiUBljn8qoNU,5472
8
+ cosmopharm/equilibrium/sle.py,sha256=E89JHAq-0XpJvSf2ybeVoNuV8OH55DHiJL6-8r33ggc,11187
9
+ cosmopharm/utils/__init__.py,sha256=qfUPovmZ9ukj6ZbTfndUOH6EX0ZrzRNjLZEDIVS8UvM,113
10
+ cosmopharm/utils/convert.py,sha256=V-7jY-Sb7C38N5bQcp1c27EOiVJfriP6zRbLAIKgrdE,2470
11
+ cosmopharm/utils/helpers.py,sha256=CXUTh3jVStHno_W_Z7o8RvQ6SveSjw_Ss31CkvfROfs,1460
12
+ cosmopharm/utils/lle_scanner.py,sha256=So9FCxLLcHmBkuF6zggMo3W3gFBocEmuRzyxVGy69JM,6587
13
+ cosmopharm/utils/spacing.py,sha256=vtM9b4wodpFGkZFGGLhiSXT51Zl6fNK2Og4oRcbLFH4,9222
14
+ cosmopharm-0.0.23.1.dist-info/LICENSE,sha256=25ZCycfBgonIECGYnZTy72eJVfzcHCEOz3DM9sTx7do,1162
15
+ cosmopharm-0.0.23.1.dist-info/METADATA,sha256=Th4N_9ntQqWDPlYnXewaQ9tH71Ru0BXLMJ2RInEodrI,5524
16
+ cosmopharm-0.0.23.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
17
+ cosmopharm-0.0.23.1.dist-info/top_level.txt,sha256=MGniVgvs1yq4sn6HQ7ErDVYV_g3st3Fs8TTFHOJVQ9I,11
18
+ cosmopharm-0.0.23.1.dist-info/RECORD,,
@@ -1,38 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: cosmopharm
3
- Version: 0.0.23
4
- Summary: Predictive modeling for drug-polymer compatibility in pharmaceutical formulations using COSMO-SAC.
5
- Home-page: https://github.com/ivanantolo/cosmopharm,
6
- Author: Ivan Antolovic
7
- Author-email: Ivan.Antolovic@tu-berlin.de
8
- Maintainer: Martin Klajmon
9
- Maintainer-email: Martin.Klajmon@vscht.cz
10
- License: MIT
11
- Keywords: Drug-Polymer Compatibility,Amorphous Solid Dispersions,Pharmaceutical Formulation,COSMO-SAC Model,Solubility Prediction,Miscibility Analysis,Phase Behavior Prediction,Pharmaceutical Sciences,Drug Formulation Research,Polymer Science,Predictive Modeling in Pharma,Drug Development Tools,Biopharmaceuticals
12
- Classifier: Development Status :: 3 - Alpha
13
- Classifier: Intended Audience :: Science/Research
14
- Classifier: Intended Audience :: Healthcare Industry
15
- Classifier: Intended Audience :: Developers
16
- Classifier: Intended Audience :: Education
17
- Classifier: License :: OSI Approved :: MIT License
18
- Classifier: Topic :: Scientific/Engineering
19
- Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
20
- Classifier: Topic :: Scientific/Engineering :: Chemistry
21
- Classifier: Programming Language :: Python :: 3
22
- Classifier: Programming Language :: Python :: 3 :: Only
23
- Classifier: Programming Language :: Python :: 3.8
24
- Classifier: Programming Language :: Python :: 3.9
25
- Classifier: Programming Language :: Python :: 3.10
26
- Classifier: Programming Language :: Python :: 3.11
27
- Classifier: Programming Language :: Python :: 3.12
28
- Classifier: Programming Language :: Python :: 3.13
29
- Requires-Python: >=3.8
30
- Description-Content-Type: text/markdown
31
- License-File: LICENSE
32
- Requires-Dist: numpy >=1.15
33
- Requires-Dist: pandas >=1.0
34
- Requires-Dist: scipy >=1.4
35
- Requires-Dist: openpyxl >=3.0
36
- Provides-Extra: examples
37
- Requires-Dist: matplotlib >=3.0 ; extra == 'examples'
38
-
@@ -1,18 +0,0 @@
1
- cosmopharm/__init__.py,sha256=sdgLzbqylG8DDAJ5J96YiO4egn9xVJTx2uzaIZ8qj4g,68
2
- cosmopharm/components.py,sha256=yHbhgFvLt9VN0jcAsLLRb0vS9FXM06yM7Pc7UgBli4M,946
3
- cosmopharm/actmodels/__init__.py,sha256=9iH67yrdSaf10Fj8LwRikUDUMeMxsvUHRPEaWc3384k,59
4
- cosmopharm/actmodels/actmodel.py,sha256=69jluNR7Tb4BHwtkCQLI3NQ_0AEZcTDM69IdRPz9--w,5072
5
- cosmopharm/actmodels/cosmo.py,sha256=BoO_Yny_UUr8CxUuu8uuwR5kg3eR3NXKomKH1zsbm78,4372
6
- cosmopharm/equilibrium/__init__.py,sha256=5NsIbQEwELjeeoFEiWelnzHnhTzt5zsBh3r5icn_AIQ,44
7
- cosmopharm/equilibrium/lle.py,sha256=k3ub2BXSpocY6TPsxLNkwSp8sAhU6LVsHEx84ptsKio,5470
8
- cosmopharm/equilibrium/sle.py,sha256=rIbNcvLQ9O5rvAssjxp4anahlUtxE3HMBB8s-rRVV-o,10963
9
- cosmopharm/utils/__init__.py,sha256=qfUPovmZ9ukj6ZbTfndUOH6EX0ZrzRNjLZEDIVS8UvM,113
10
- cosmopharm/utils/convert.py,sha256=V-7jY-Sb7C38N5bQcp1c27EOiVJfriP6zRbLAIKgrdE,2470
11
- cosmopharm/utils/helpers.py,sha256=D2Zx9P0ywWWl2XQtzC6e5ek2CrudBIncfAIp_7vQnC0,1430
12
- cosmopharm/utils/lle_scanner.py,sha256=So9FCxLLcHmBkuF6zggMo3W3gFBocEmuRzyxVGy69JM,6587
13
- cosmopharm/utils/spacing.py,sha256=vtM9b4wodpFGkZFGGLhiSXT51Zl6fNK2Og4oRcbLFH4,9222
14
- cosmopharm-0.0.23.dist-info/LICENSE,sha256=25ZCycfBgonIECGYnZTy72eJVfzcHCEOz3DM9sTx7do,1162
15
- cosmopharm-0.0.23.dist-info/METADATA,sha256=RIEg2FeVCKo7RTwxx7PIgOIkjWC1hH5LRHklyaP-Ywc,1851
16
- cosmopharm-0.0.23.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
17
- cosmopharm-0.0.23.dist-info/top_level.txt,sha256=MGniVgvs1yq4sn6HQ7ErDVYV_g3st3Fs8TTFHOJVQ9I,11
18
- cosmopharm-0.0.23.dist-info/RECORD,,