Skip to content

Commit

Permalink
there and back again
Browse files Browse the repository at this point in the history
  • Loading branch information
SalvadorBrandolin committed Sep 5, 2024
1 parent 7c75a8f commit 203447c
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can try ugropy from its
[Binder](https://mybinder.org/v2/gh/ipqa-research/ugropy/main). Open the
binder.ipynb file to explore the basic features.

# Models supported v2.0.7
# Models implemented
- Classic liquid-vapor UNIFAC
- Predictive Soave-Redlich-Kwong (PSRK)
- Joback
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ classifiers = [
urls = {Homepage = "https://github.com/ipqa-research/ugropy"}

dependencies = [
'numpy >= 1.25.1, <2.0.0',
'numpy >= 1.25.1',
'pandas >= 2.0.3',
'pubchempy >= 1.0.4',
'rdkit >= 2023.9.5'
Expand Down
6 changes: 0 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,3 @@ ipdb
ipython
jupyter
matplotlib

# ugropy dependecies
numpy >= 1.25.1, <2.0.0
pandas >= 2.0.3
pubchempy >= 1.0.4
rdkit >= 2023.9.5
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

6 changes: 6 additions & 0 deletions ugropy/refactor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .fragment import Fragment
from .fragmentation_model import FragmentationModel
from .fragmentation_unifac import unifac


__all__ = ["Fragment", "FragmentationModel", "unifac"]
8 changes: 8 additions & 0 deletions ugropy/refactor/fragment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from rdkit import Chem


class Fragment:
def __init__(self, name: str, smarts: str):
self.name = name
self.smarts = smarts
self.mol_object = Chem.MolFromSmarts(smarts)
21 changes: 21 additions & 0 deletions ugropy/refactor/fragmentation_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import List

from ugropy.refactor.fragment import Fragment

from rdkit import Chem


class FragmentationModel:
def __init__(self, fragments: List[Fragment]):
self.fragments = fragments

def detect_fragments(self, molecule: Chem.rdchem.Mol):
detected = {}

for fragment in self.fragments:
match = molecule.GetSubstructMatches(fragment.mol_object)

if match:
detected[fragment.name] = match

return detected
22 changes: 22 additions & 0 deletions ugropy/refactor/fragmentation_unifac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from ugropy.refactor.fragment import Fragment
from ugropy.refactor.fragmentation_model import FragmentationModel


_unifac_fragments = [
Fragment("CH3", "[CH3]"),
Fragment("CH2", "[CH2]"),
Fragment("CH", "[CH]"),
Fragment("C", "[CH0]"),
Fragment("OH", "[OH]"),
Fragment("H2O", "O"),
Fragment("ACH", "[cH]"),
Fragment("AC", "[cH0]"),
Fragment("ACCH3", "[cH0][CH3]"),
Fragment("ACCH2", "[cH0][CH2]"),
Fragment("ACCH", "[cH0][CH]"),
]


unifac = FragmentationModel(_unifac_fragments)

# mol = Chem.MolFromSmiles("C(C1=CC=CC=C1)C1=CC=CC=C1")

0 comments on commit 203447c

Please sign in to comment.