Skip to content

Commit 8a5d2e1

Browse files
authored
Merge pull request #188 from moleculemaker/group-cart
Group cart
2 parents 6071c2a + 55f987d commit 8a5d2e1

File tree

255 files changed

+20114
-21525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+20114
-21525
lines changed

.browserslistrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
defaults
2+
iOS >= 12

angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
{
4242
"type": "initial",
4343
"maximumWarning": "500kb",
44-
"maximumError": "1.5mb"
44+
"maximumError": "2mb"
4545
},
4646
{
4747
"type": "anyComponentStyle",
4848
"maximumWarning": "2kb",
49-
"maximumError": "14kb"
49+
"maximumError": "15kb"
5050
}
5151
],
5252
"fileReplacements": [

poetry.lock

Lines changed: 125 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ python = "^3.12"
99
pandas = "^2.2.1"
1010
openpyxl = "^3.1.2"
1111
numpy = "^1.26.4"
12+
rdkit = "^2023.9.6"
1213

1314

1415
[build-system]

scripts/process_color_wheel.py

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import itertools
22
import json
33
import os
4+
from rdkit.Chem.Descriptors import MolWt
5+
from rdkit.Chem import CanonSmiles, MolFromSmiles
6+
from rdkit.Chem.rdMolDescriptors import CalcMolFormula
47

5-
from utils import get_svg_dimensions, combine_chemical_formulas, combine
8+
from utils import get_svg_dimensions, naive_combine
69

710
workdir = './src/assets/blocks/10x10x10palette'
811

9-
with open(os.path.join(workdir, 'blocks.json')) as file:
12+
with open(os.path.join(workdir, 'block_set.json')) as file:
1013
block_set = json.load(file)
1114

1215
blocks_by_index = [[None], [None], [None]]
@@ -31,6 +34,29 @@ def process_blocks():
3134
block_set['blocks'] = processed_blocks
3235

3336

37+
def get_smiles(donor, bridge, acceptor):
38+
"""
39+
Returns SMILES of either a single block or a full 3-block combo
40+
"""
41+
blocks = [donor, bridge, acceptor]
42+
blocks = [block for block in blocks if block]
43+
44+
if len(blocks) == 1:
45+
return CanonSmiles(blocks[0]['properties']['smiles'])
46+
47+
if not donor or not bridge or not acceptor:
48+
return ''
49+
50+
start = chr(ord('A') + (donor['id'] - 1))
51+
mid = bridge['id']
52+
end = chr(ord('K') + (acceptor['id'] - 1))
53+
54+
filename = workdir + f'/smi/{start}_{mid}_{end}.smi'
55+
with open(filename) as f:
56+
smiles = f.read().strip()
57+
return smiles
58+
59+
3460
def generate_lookup_table():
3561
block_set['table'] = {}
3662

@@ -40,12 +66,21 @@ def generate_lookup_table():
4066
a_id = acceptor['id'] if acceptor else 0
4167
key = f'{d_id}:{b_id}:{a_id}'
4268

69+
smiles = get_smiles(donor, bridge, acceptor)
70+
chemical_formula = CalcMolFormula(MolFromSmiles(smiles))
71+
72+
all_smiles = [block['properties']['smiles'] if block else '' for block in (donor, bridge, acceptor)]
73+
4374
block_set['table'][key] = {
4475
'key': key,
45-
'chemicalFormula': combine_chemical_formulas(donor, bridge, acceptor),
46-
'smiles': combine('smiles', '')(donor, bridge, acceptor),
47-
'lambdaMaxShift': combine('lambdaMaxShift', 0)(donor, bridge, acceptor),
48-
'molecularWeight': combine('molecularWeight', 0)(donor, bridge, acceptor),
76+
'chemicalFormula': chemical_formula.replace('+', '').replace('-', ''),
77+
'smiles': smiles,
78+
'lambdaMaxShift': (
79+
(donor['properties']['lambdaMaxShift'] if donor else 0)
80+
+ (bridge['properties']['lambdaMaxShift'] if bridge else 0)
81+
+ (acceptor['properties']['lambdaMaxShift'] if acceptor else 0)
82+
),
83+
'molecularWeight': MolWt(naive_combine(all_smiles))
4984
}
5085

5186

0 commit comments

Comments
 (0)