Commit f66e1a66 authored by Lukas Pravda's avatar Lukas Pravda
Browse files

account for multiline labels

parent a4a32015
......@@ -151,7 +151,7 @@ def convert_svg(svg_string, ccd_id, mol: rdkit.Chem.Mol):
temp = {
'name': mol.GetAtomWithIdx(atom_id).GetProp('name'),
'label': {},
'labels': [],
'x': float(atom_svg.attrib.get('cx')),
'y': float(atom_svg.attrib.get('cy'))
}
......@@ -196,7 +196,7 @@ def convert_svg(svg_string, ccd_id, mol: rdkit.Chem.Mol):
for tspan in filter(lambda x: x.text is not None, label_svg.findall('{http://www.w3.org/2000/svg}tspan'))]
}
nearest_index = kd_tree.query([temp['x'], temp['y']])[1]
result_bag['atoms'][nearest_index]['label'] = temp
result_bag['atoms'][nearest_index]['labels'].append(temp)
result_bag['resolution'] = {
'x': float(dimensions_svg.attrib.get('width')),
......
......@@ -124,7 +124,7 @@ class TestWriteImg:
atom_names = [atom['name'] for atom in json_obj['atoms']]
assert len(json_obj['atoms']) == component.mol_no_h.GetNumAtoms()
assert len(json_obj['bonds']) >= component.mol_no_h.GetNumBonds()
assert any(atom['label'] for atom in json_obj['atoms']) # do we have any labels (not all atoms has one)
assert any(atom['labels'] for atom in json_obj['atoms']) # do we have any labels (not all atoms has one)
assert all(atom['name'] for atom in json_obj['atoms']) # do we have atom names?
assert all(bond['bgn'] in atom_names and bond['end'] in atom_names for bond in json_obj['bonds']) # are all the atoms defined?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment