From f93091278b4f1d48721df5e6d3a4fb77abca5644 Mon Sep 17 00:00:00 2001 From: Peter Kroon Date: Fri, 9 Jun 2023 12:35:32 +0200 Subject: [PATCH 1/2] Fix atom formatting for Se and As. format_atom wrongly assumed Se and As could be formatted as non-bracket atoms --- pysmiles/smiles_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pysmiles/smiles_helper.py b/pysmiles/smiles_helper.py index 86b05e3..e855107 100644 --- a/pysmiles/smiles_helper.py +++ b/pysmiles/smiles_helper.py @@ -142,7 +142,7 @@ def format_atom(molecule, node_key, default_element='*'): name = name.lower() if (stereo is None and isotope == '' and charge == 0 and default_h and - class_ == '' and name.lower() in 'b c n o p s se as *'.split()): + class_ == '' and name.lower() in 'b c n o p s *'.split()): return name if hcount: From 9136c7a3e0e3d94c6b0dd699518720d390f6c00d Mon Sep 17 00:00:00 2001 From: Peter Kroon Date: Fri, 9 Jun 2023 13:05:19 +0200 Subject: [PATCH 2/2] Add tests for writing [As] and [Se] --- tests/test_write_smiles.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_write_smiles.py b/tests/test_write_smiles.py index 1b5fa97..d4b2790 100644 --- a/tests/test_write_smiles.py +++ b/tests/test_write_smiles.py @@ -130,6 +130,16 @@ (2, 3, {'order': 1})], False ), + ( + [(0, {'element': 'Se', 'charge': 0, 'aromatic': False, 'hcount': 0})], + [], + False + ), + ( + [(0, {'element': 'As', 'charge': 0, 'aromatic': False, 'hcount': 0})], + [], + False + ), )) def test_write_smiles(node_data, edge_data, expl_h): mol = make_mol(node_data, edge_data)