Skip to content

Commit

Permalink
redefinition of agani class, working on secondary structures, error o…
Browse files Browse the repository at this point in the history
…n preprocess
  • Loading branch information
SalvadorBrandolin committed Dec 16, 2024
1 parent 5fa9a99 commit 1334df5
Show file tree
Hide file tree
Showing 11 changed files with 584 additions and 561 deletions.
492 changes: 80 additions & 412 deletions tests/agani.ipynb

Large diffs are not rendered by default.

175 changes: 175 additions & 0 deletions tests/agani_s.ipynb

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions ugropy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"""

from .core import instantiate_mol_object
from .core.frag_classes.abdulelah_gani.abdulelah_gani_p import (
AbdulelahGaniPrimaryModel,
from .core.frag_classes.abdulelah_gani.abdulelah_gani_pst import (
AbdulelahGaniPSTModel,
)
from .core.frag_classes.abdulelah_gani.abdulelah_gani_p_result import (
AGaniPFragmentationResult,
from .core.frag_classes.abdulelah_gani.abdulelah_gani_pst_result import (
AGaniPSTFragmentationResult,
)
from .core.frag_classes.base.fragmentation_model import (
FragmentationModel,
Expand All @@ -29,6 +29,7 @@
from .core.ilp_solvers.ilp_solver import ILPSolver
from .groups import Groups
from .models.abdulelah_gani_pmod import abdulelah_gani_p
from .models.abdulelah_gani_smod import abdulelah_gani_s
from .models.jobackmod import joback
from .models.psrkmod import psrk
from .models.unifacmod import unifac
Expand All @@ -38,8 +39,8 @@
"constants",
"writers",
"instantiate_mol_object",
"AbdulelahGaniPrimaryModel",
"AGaniPFragmentationResult",
"AbdulelahGaniPSTModel",
"AGaniPSTFragmentationResult",
"FragmentationModel",
"FragmentationResult",
"GibbsModel",
Expand All @@ -48,6 +49,7 @@
"JobackFragmentationResult",
"Groups",
"abdulelah_gani_p",
"abdulelah_gani_s",
"joback",
"unifac",
"psrk",
Expand Down
4 changes: 2 additions & 2 deletions ugropy/core/frag_classes/abdulelah_gani/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Abdulelah-Gani frag classes module."""

from . import abdulelah_gani_p, abdulelah_gani_p_result
from . import abdulelah_gani_pst, abdulelah_gani_pst_result


__all__ = ["abdulelah_gani_p", "abdulelah_gani_p_result"]
__all__ = ["abdulelah_gani_pst", "abdulelah_gani_pst_result"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from rdkit import Chem

from ugropy.core.frag_classes.abdulelah_gani.abdulelah_gani_p_result import (
AGaniPFragmentationResult,
from ugropy.core.frag_classes.abdulelah_gani.abdulelah_gani_pst_result import (
AGaniPSTFragmentationResult,
)
from ugropy.core.frag_classes.base.fragmentation_model import (
FragmentationModel,
Expand All @@ -16,7 +16,7 @@
from ugropy.core.ilp_solvers.ilp_solver import ILPSolver


class AbdulelahGaniPrimaryModel(FragmentationModel):
class AbdulelahGaniPSTModel(FragmentationModel):
"""Abdulelah-Gani model dedicated to properties estimation models.
Class to construct the primary structures detector for the Abdulelah-Gani
Expand Down Expand Up @@ -48,13 +48,17 @@ def __init__(
self,
subgroups: pd.DataFrame,
subgroups_info: pd.DataFrame,
allow_overlapping: bool = False,
allow_free_atoms: bool = False,
) -> None:

super().__init__(
subgroups=subgroups,
allow_overlapping=False,
fragmentation_result=AGaniPFragmentationResult,
allow_overlapping=allow_overlapping,
allow_free_atoms=allow_free_atoms,
fragmentation_result=AGaniPSTFragmentationResult,
)

self.subgroups_info = subgroups_info

def get_groups(
Expand All @@ -63,7 +67,7 @@ def get_groups(
identifier_type: str = "name",
solver: ILPSolver = DefaultSolver,
search_multiple_solutions: bool = False,
) -> Union[AGaniPFragmentationResult, List[AGaniPFragmentationResult]]:
) -> Union[AGaniPSTFragmentationResult, List[AGaniPSTFragmentationResult]]:
"""Get the groups of a molecule.
Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


class AGaniPFragmentationResult(FragmentationResult):
class AGaniPSTFragmentationResult(FragmentationResult):
"""Abdulelah-Gani primary group contribution properties estimator.
Parameters
Expand Down
4 changes: 3 additions & 1 deletion ugropy/core/frag_classes/base/fragmentation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ def __init__(
self,
subgroups: pd.DataFrame,
allow_overlapping: bool = False,
allow_free_atoms: bool = False,
fragmentation_result: FragmentationResult = FragmentationResult,
) -> None:
self.subgroups = subgroups
self.allow_overlapping = allow_overlapping
self.allow_free_atoms = allow_free_atoms
self.fragmentation_result = fragmentation_result

# Instantiate all de mol object from their SMARTS representation
Expand Down Expand Up @@ -122,7 +124,7 @@ def get_groups(
)

# If there is free atoms in the molecule can't fragment with the model
if np.size(free_atoms) > 0:
if np.size(free_atoms) > 0 and not self.allow_free_atoms:
return self.set_fragmentation_result(
mol, [{}], search_multiple_solutions, **kwargs
)
Expand Down
131 changes: 131 additions & 0 deletions ugropy/groupscsv/abdulelah_gani/secondary/info.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
group|group_number
(CH3)2CH|221
(CH3)3C|222
CH(CH3)CH(CH3)|223
CH(CH3)C(CH3)2|224
C(CH3)2C(CH3)2|225
CHn=CHm-CHp=CHk (k,m,n,p in 0..2)|226
CH3-CHm=CHn (m,n in 0..2)|227
CH2-CHm=CHn (m,n in 0..2)|228
CHp-CHm=CHn (m,n in 0..2; p in 0..1)|229
CHCHO or CCHO|230
CH3COCH2|231
CH3COCH or CH3COC|232
CHCOOH or CCOOH|233
CH3COOCH or CH3COOC|234
CO-O-CO|235
CHOH|236
COH|237
CH3COCHnOH (n in 0..2)|238
NCCHOH or NCCOH|239
OH-CHn-COO (n in 0..2)|240
CHm(OH)CHn(OH) (m,n in 0..2)|241
CHm(OH)CHn(NHp) (m,n,p in 0..2)|242
CHm(NH2)CHn(NH2) (m,n in 0..2)|243
CHm(NH)CHn(NH2) (m,n in 1..2)|244
H2NCOCHnCHmCONH2 (m,n in 1..2)|245
CHm(NHn)-COOH (m,n in 0..2)|246
HOOC-CHn-COOH (n in 1..2)|247
HOOC-CHn-CHm-COOH (n, m in 1..2)|248
HO-CHn-COOH (n in 1..2)|249
NH2-CHn-CHm-COOH (n, m in 1..2)|250
CH3-O-CHn-COOH (n in 1..2)|251
HS-CH-COOH|252
HS-CHn-CHm-COOH (n, m in 1..2)|253
NC-CHn-CHm-CN (n, m in 1..2)|254
OH-CHn-CHm-CN (n, m in 1..2)|255
HS-CHn-CHm-SH (n, m in 1..2)|256
COO-CHn-CHm-OOC (n, m in 1..2)|257
OOC-CHm-CHm-COO (n, m in 1..2)|258
NC-CHn-COO (n in 1..2)|259
COCHnCOO (n in 1..2)|260
CHm-O-CHn=CHp (m,n,p in 0..3)|261
CHm=CHn-F (m,n in 0..2)|262
CHm=CHn-Br (m,n in 0..2)|263
CHm=CHn-I (m,n in 0..2)|264
CHm=CHn-Cl (m,n in 0..2)|265
CHm=CHn-CN (m,n in 0..2)|266
CHn=CHm-COO-CHp (m,n,p in 0..3)|267
CHm=CHn-CHO (m,n in 0..2)|268
CHm=CHn-COOH (m,n in 0..2)|269
aC-CHn-X (n in 1..2) X: Halogen|270
aC-CHn-NHm (n in 1..2; m in 0..2))|271
aC-CHn-O- (n in 1..2)|272
aC-CHn-OH (n in 1..2)|273
aC-CHn-CN (n in 1..2)|274
aC-CHn-CHO (n in 1..2)|275
aC-CHn-SH (n in 1..2)|276
aC-CHn-COOH (n in 1..2)|277
aC-CHn-CO- (n in 1..2)|278
aC-CHn-S- (n in 1..2)|279
aC-CHn-OOC-H (n in 1..2)|280
aC-CHm-NO2 (n in 1..2)|281
aC-CHn-CONH2 (n in 1..2)|282
aC-CHn-OOC (n in 1..2)|283
aC-CHn-COO (n in 1..2)|284
aC-SO2-OH|285
aC-CH(CH3)2|286
aC-C(CH3)3|287
aC-CF3|288
(CHn=C)(cyc)-CHO (n in 0..2)|289
(CHn=C)cyc-COO-CHm (n,m in 0..3)|290
(CHn=C)cyc-CO- (n in 0..2)|291
(CHn=C)cyc-CH3 (n in 0..2)|292
(CHn=C)cyc-CH2 (n in 0..2)|293
(CHn=C)cyc-CN (n in 0..2)|294
(CHn=C)cyc-Cl (n in 0..2)|295
CHcyc-CH3|296
CHcyc-CH2|297
CHcyc-CH|298
CHcyc-C|299
CHcyc-CH=CHn (n in 1..2)|300
CHcyc-C=CHn (n in 1..2)|301
CHcyc-Cl|302
CHcyc-F|303
CHcyc-OH|304
CHcyc-NH2|305
CHcyc-NH-CHn (n in 0..3)|306
CHcyc-N-CHn (n in 0..3)|307
CHcyc-SH|308
CHcyc-CN|309
CHcyc-COOH|310
CHcyc-CO|311
CHcyc-NO2|312
CHcyc-S-|313
CHcyc-CHO|314
CHcyc-O-|315
CHcyc-OOCH|316
CHcyc-COO|317
CHcyc-OOC|318
Ccyc-CH3|319
Ccyc-CH2|320
Ccyc-OH|321
>Ncyc-CH3|322
>Ncyc-CH2|323
AROMRINGs1s2|324
AROMRINGs1s3|325
AROMRINGs1s4|326
AROMRINGs1s2s3|327
AROMRINGs1s2s4|328
AROMRINGs1s3s5|329
AROMRINGs1s2s3s4|330
AROMRINGs1s2s3s5|331
AROMRINGs1s2s4s5|332
PYRIDINEs2|333
PYRIDINEs3|334
PYRIDINEs4|335
PYRIDINEs2s3|336
PYRIDINEs2s4|337
PYRIDINEs2s5|338
PYRIDINEs2s6|339
PYRIDINEs3s4|340
PYRIDINEs3s5|341
PYRIDINEs2s3s6|342
(CHn=CHm)cyc-COOH|343
AROMRINGs1s2s3s4s5|344
aC-NHCOCH2N|345
(N=C)cyc-CH3|346
aC-CONH(CH2)2N|347
aC-SO2NHn (n>=0;n<3)|348
aC-SO2NHn (n>=0;n<3)|349
aC-SO2NHn (n>=0;n<3)|350
Loading

0 comments on commit 1334df5

Please sign in to comment.