Skip to content

Commit

Permalink
CG primary structures finished
Browse files Browse the repository at this point in the history
  • Loading branch information
SalvadorBrandolin committed Apr 22, 2024
1 parent 6c96c18 commit 0e90e02
Show file tree
Hide file tree
Showing 31 changed files with 277 additions and 64 deletions.
5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_17_acnh2.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ def test_ch3nh2_psrk(identifier, result, identifier_type):
def test_ch3nh2_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
9 changes: 7 additions & 2 deletions tests/classic_unifac_groups/test_18_pyridine.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@ def test_ch3nh2_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)

if identifier != "C1=CC=NC=C1":

assert mol.subgroups == result

if mol.subgroups != {}:
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(
mol.mol_object, mol.subgroups, constantinou_gani_primary
)
!= {}
)
else:
assert mol.subgroups == {}
8 changes: 5 additions & 3 deletions tests/classic_unifac_groups/test_19_ccn.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ def test_ccn_psrk(identifier, result, identifier_type):
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_ccn_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)

if identifier != "CC#N":
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
else:
assert mol.subgroups == {}

7 changes: 5 additions & 2 deletions tests/classic_unifac_groups/test_20_cooh.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ def test_cooh_psrk(identifier, result, identifier_type):
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_cooh_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)

if identifier != "C(=O)O":
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
else:
assert mol.subgroups == {}
5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_21_ccl.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ def test_ccl_psrk(identifier, result, identifier_type):
def test_ccl_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
7 changes: 5 additions & 2 deletions tests/classic_unifac_groups/test_22_ccl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ def test_ccl2_psrk(identifier, result, identifier_type):
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_ccl2_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)

if identifier != "C(Cl)Cl":
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
else:
assert mol.subgroups == {}
9 changes: 6 additions & 3 deletions tests/classic_unifac_groups/test_23_ccl3.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def test_ccl3_psrk(identifier, result, identifier_type):
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_ccl3_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)

if identifier != "C(Cl)(Cl)Cl":
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
else:
assert mol.subgroups == {}
assert mol.subgroups == {}
5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_25_accl.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ def test_accl_psrk(identifier, result, identifier_type):
def test_accl_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
9 changes: 6 additions & 3 deletions tests/classic_unifac_groups/test_26_cno2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ def test_cno2_psrk(identifier, result, identifier_type):
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_cno2_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)

if identifier != "C[N+](=O)[O-]":
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
else:
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
else:
assert mol.subgroups == {}
5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_27_acno2.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ def test_acno2_cg(identifier, result, identifier_type):
assert mol.subgroups == result

if mol.subgroups != {}:
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
8 changes: 6 additions & 2 deletions tests/classic_unifac_groups/test_29_ch3sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ def test_ch3sh_cg(identifier, result, identifier_type):
assert mol.subgroups == result

if mol.subgroups != {}:
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(
mol.mol_object, mol.subgroups, constantinou_gani_primary
)
!= {}
)
else:
assert mol.subgroups == {}

5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_32_i.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ def test_i_psrk(identifier, result, identifier_type):
def test_i_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
6 changes: 4 additions & 2 deletions tests/classic_unifac_groups/test_33_br.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ def test_br_psrk(identifier, result, identifier_type):
def test_br_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}

assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_34_alquine.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ def test_alquine_psrk(identifier, result, identifier_type):
def test_alquine_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
7 changes: 5 additions & 2 deletions tests/classic_unifac_groups/test_37_clceqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ def test_cleqc_psrk(identifier, result, identifier_type):
assert fit_atoms(mol.mol_object, mol.subgroups, psrk) != {}


@pytest.mark.ConstantinougGani
@pytest.mark.ConstantinouGani
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_cleqc_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
14 changes: 11 additions & 3 deletions tests/classic_unifac_groups/test_38_acf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,20 @@ def test_acf_psrk(identifier, result, identifier_type):
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_acf_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)

if identifier != "FC1=CC=NC=C1":
assert mol.subgroups == result

if mol.subgroups != {}:
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(
mol.mol_object, mol.subgroups, constantinou_gani_primary
)
!= {}
)
else:
mol.subgroups == {"C5H4N": 1, "F": 1}
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_40_cf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ def test_cf2_cg(identifier, result, identifier_type):
assert mol.subgroups == result

if mol.subgroups != {}:
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_41_coo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ def test_coo_psrk(identifier, result, identifier_type):
def test_coo_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
15 changes: 12 additions & 3 deletions tests/classic_unifac_groups/test_45_cclf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,19 @@ def test_cclf_cg(identifier, result, identifier_type):
assert mol.subgroups == {}
elif identifier == "C(F)(Cl)Cl":
assert mol.subgroups == {"CHCL2": 1, "F": 1}
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
elif identifier == "C(F)(F)Cl":
assert mol.subgroups == {"CHCL": 1, "F": 2}
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
else:
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
69 changes: 68 additions & 1 deletion tests/classic_unifac_groups/test_46_con.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from ugropy import get_groups, psrk, unifac
from ugropy import constantinou_gani_primary, get_groups, psrk, unifac
from ugropy.core import fit_atoms


Expand Down Expand Up @@ -81,3 +81,70 @@ def test_con_psrk(identifier, result, identifier_type):

if mol.subgroups != {}:
assert fit_atoms(mol.mol_object, mol.subgroups, psrk) != {}


trials_cg = [
# acetamide
("CC(=O)N", {"CH3": 1, "CONH2": 1}, "smiles"),
# N-Methylacetamide
("CC(=O)NC", {"CH3": 1, "CONHCH3": 1}, "smiles"),
# N-Ethylacetamide
("CCNC(=O)C", {"CH3": 2, "CONHCH2": 1}, "smiles"),
# N,N-Dimethylacetamide
("CC(=O)N(C)C", {"CH3": 1, "CON(CH3)2": 1}, "smiles"),
# N-ethyl-N-methylacetamide
("CCN(C)C(=O)C", {"CH3": 2, "CONCH3CH2": 1}, "smiles"),
# N,N-Diethylacetamide
("CCN(CC)C(=O)C", {"CH3": 3, "CON(CH2)2": 1}, "smiles"),
# di amide + amine
("CCN(C(C)C)C(=O)NC(C)C", {}, "smiles"),
("CC(C)NC(=O)N(C)C(C)C", {}, "smiles"),
("CCN(CC)C(=O)NC(C)C", {"CON(CH2)2": 1, "CHNH": 1, "CH3": 4}, "smiles"),
("CCN(C)C(=O)NC(C)C", {"CONCH3CH2": 1, "CHNH": 1, "CH3": 3}, "smiles"),
("CC(C)NC(=O)N(C)C", {"CON(CH3)2": 1, "CHNH": 1, "CH3": 2}, "smiles"),
(
"CCNC(=O)N(CC)C(C)C",
{"CONHCH2": 1, "CH2N": 1, "CH3": 4, "CH": 1},
"smiles",
),
(
"CCNC(=O)N(C)C(C)C",
{"CONHCH2": 1, "CH3N": 1, "CH3": 3, "CH": 1},
"smiles",
),
("CCNC(=O)N(CC)CC", {"CON(CH2)2": 1, "CH2NH": 1, "CH3": 3}, "smiles"),
("CCNC(=O)N(C)CC", {"CONCH3CH2": 1, "CH2NH": 1, "CH3": 2}, "smiles"),
("CCNC(=O)N(C)C", {"CON(CH3)2": 1, "CH2NH": 1, "CH3": 1}, "smiles"),
(
"CCN(C(C)C)C(=O)NC",
{"CONHCH3": 1, "CH2N": 1, "CH": 1, "CH3": 3},
"smiles",
),
(
"CNC(=O)N(C)C(C)C",
{"CONHCH3": 1, "CH3N": 1, "CH": 1, "CH3": 2},
"smiles",
),
("CCN(CC)C(=O)NC", {"CON(CH2)2": 1, "CH3NH": 1, "CH3": 2}, "smiles"),
("CCN(C)C(=O)NC", {"CONCH3CH2": 1, "CH3NH": 1, "CH3": 1}, "smiles"),
("CNC(=O)N(C)C", {"CON(CH3)2": 1, "CH3NH": 1}, "smiles"),
("CC(C)NC(=O)NC(C)C", {}, "smiles"),
("CCNC(=O)NC(C)C", {"CONHCH2": 1, "CHNH": 1, "CH3": 3}, "smiles"),
("CCNC(=O)NCC", {"CONHCH2": 1, "CH2NH": 1, "CH3": 2}, "smiles"),
("CNC(=O)NC(C)C", {"CONHCH3": 1, "CHNH": 1, "CH3": 2}, "smiles"),
("CCNC(=O)NC", {"CONHCH3": 1, "CH2NH": 1, "CH3": 1}, "smiles"),
("CNC(=O)NC", {"CONHCH3": 1, "CH3NH": 1}, "smiles"),
]


@pytest.mark.ConstantinouGani
@pytest.mark.parametrize("identifier, result, identifier_type", trials_cg)
def test_con_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result

if mol.subgroups != {}:
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
6 changes: 4 additions & 2 deletions tests/classic_unifac_groups/test_47_occoh.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ def test_occoh_psrk(identifier, result, identifier_type):
def test_occoh_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}

assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
5 changes: 4 additions & 1 deletion tests/classic_unifac_groups/test_48_ch2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ def test_ch2s_psrk(identifier, result, identifier_type):
def test_ch2s_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
7 changes: 5 additions & 2 deletions tests/classic_unifac_groups/test_50_thiophene.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ def test_thiophene_psrk(identifier, result, identifier_type):
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_thiophene_cg(identifier, result, identifier_type):
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)

if identifier != "C1=CSC=C1":
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
else:
assert mol.subgroups == {}
18 changes: 14 additions & 4 deletions tests/classic_unifac_groups/test_composed.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,22 @@ def test_composed_psrk(identifier, result, identifier_type):
@pytest.mark.ConstantinouGani
@pytest.mark.parametrize("identifier, result, identifier_type", trials_unifac)
def test_composed_cg(identifier, result, identifier_type):
cg_result = get_groups(constantinou_gani_primary, identifier, identifier_type)
cg_result = get_groups(
constantinou_gani_primary, identifier, identifier_type
)
try:
mol = get_groups(constantinou_gani_primary, identifier, identifier_type)
mol = get_groups(
constantinou_gani_primary, identifier, identifier_type
)
assert mol.subgroups == result
assert fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, mol.subgroups, constantinou_gani_primary)
!= {}
)
except ValueError:
for psrk_r, sol in zip(cg_result.subgroups, result):
assert psrk_r == sol
assert fit_atoms(mol.mol_object, psrk_r, constantinou_gani_primary) != {}
assert (
fit_atoms(mol.mol_object, psrk_r, constantinou_gani_primary)
!= {}
)
Loading

0 comments on commit 0e90e02

Please sign in to comment.