Skip to content

Commit 1c533ce

Browse files
committed
bugs fixed.
tutorial updated.
1 parent 22158f2 commit 1c533ce

File tree

6 files changed

+148218
-281
lines changed

6 files changed

+148218
-281
lines changed

CGRdb/database/molecule.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2017-2019 Ramil Nugmanov <[email protected]>
3+
# Copyright 2017-2020 Ramil Nugmanov <[email protected]>
44
# Copyright 2019 Adelia Fatykhova <[email protected]>
55
# This file is part of CGRdb.
66
#
@@ -272,9 +272,11 @@ def unite_molecule(self, molecule, mapping: Dict[int, int]):
272272
Unite molecules into single.
273273
Don't use this in parallel mode!
274274
275-
:param molecule: molecule id with will be moved into self.
275+
:param molecule: Molecule object or id which will be moved into self.
276276
:param mapping: atom-to-atom mapping of molecule into self
277277
"""
278+
if not isinstance(molecule, int):
279+
molecule = molecule.id
278280
mapping = [list(x) for x in mapping.items()]
279281
self._database_.execute(f"SELECT test.cgrdb_merge_molecules({molecule}, {self.id}, '{mapping}')")
280282

CGRdb/sql/after_insert_molecule.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ WHERE x.reaction IN (
4343
FROM "{schema}"."MoleculeReaction" y
4444
WHERE y.molecule = {molecule}
4545
)
46-
GROUP BY x.reaction'''
46+
GROUP BY x.reaction ORDER BY x.reaction'''
4747

4848
get_ms = f'''SELECT array_agg(x.molecule) m, array_agg(x.id) s, array_agg(x.structure) d
4949
FROM "{schema}"."MoleculeStructure" x JOIN (
@@ -55,7 +55,7 @@ FROM "{schema}"."MoleculeStructure" x JOIN (
5555
WHERE z.molecule = {molecule}
5656
)
5757
) mr ON x.molecule = mr.molecule
58-
GROUP BY mr.reaction'''
58+
GROUP BY mr.reaction ORDER BY mr.reaction'''
5959

6060
cache = lru_cache(cache_size)(lambda x: loads(s, compression='gzip'))
6161
for ms_row, mp_row in zip(plpy.cursor(get_ms), plpy.cursor(get_mp)):

CGRdb/sql/merge_molecules.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ for molecule, update_s, update_si in ((source, t_structures, t_ids), (target, s_
9090
FROM "{schema}"."MoleculeReaction" y
9191
WHERE y.molecule = {molecule}
9292
)
93-
GROUP BY x.reaction'''
93+
GROUP BY x.reaction ORDER BY x.reaction'''
9494

9595
get_ms = f'''SELECT array_agg(x.molecule) m, array_agg(x.id) s, array_agg(x.structure) d
9696
FROM "{schema}"."MoleculeStructure" x JOIN (
@@ -102,7 +102,7 @@ for molecule, update_s, update_si in ((source, t_structures, t_ids), (target, s_
102102
WHERE z.molecule = {molecule}
103103
)
104104
) mr ON x.molecule = mr.molecule
105-
GROUP BY mr.reaction'''
105+
GROUP BY mr.reaction ORDER BY mr.reaction'''
106106

107107
update = list(zip(update_si, update_s))
108108
for ms_row, mp_row in zip(plpy.cursor(get_ms), plpy.cursor(get_mp)):

0 commit comments

Comments
 (0)