ReactionMechanismGenerator / ARC

ARC - Automatic Rate Calculator
https://reactionmechanismgenerator.github.io/ARC/index.html
MIT License
42 stars 21 forks source link

ARCSpecies does not show atom labels for the mol object if it was generated from a `species_dict` #675

Open kfir4444 opened 1 year ago

kfir4444 commented 1 year ago

Describe the bug ARCSpecies does not show atom labels for the mol object if it was generated from a species_dict

How to reproduce

>>> from arc.species import ARCSpecies
>>> spc = ARCSpecies(label="fail", smiles="CC")
>>> for index, atom in enumerate(spc.mol.atoms):
...     atom.label = str(index)
... 
>>> new_spc = ARCSpecies(species_dict=spc.as_dict())
>>> print([atom.label for atom in new_spc.mol.atoms])
['', '', '', '', '', '', '', '']

even though the species_dict does have atom labels:

'mol': {'atoms': [{'element': {'number': 6, 'isotope': -1},
    'radical_electrons': 0,
    'charge': 0,
    'label': '0',
    'lone_pairs': 0,
    'id': -27544,
    'props': {'inRing': False},
    'atomtype': 'Cs',
    'edges': {-27543: 1.0, -27542: 1.0, -27541: 1.0, -27540: 1.0}},
   {'element': {'number': 6, 'isotope': -1},
    'radical_electrons': 0,
    'charge': 0,
    'label': '1',
    'lone_pairs': 0,
    'id': -27543,
    'props': {'inRing': False},
    'atomtype': 'Cs',
    'edges': {-27544: 1.0, -27539: 1.0, -27538: 1.0, -27537: 1.0}},
   {'element': {'number': 1, 'isotope': -1},
    'radical_electrons': 0,
    'charge': 0,
    'label': '2',
    'lone_pairs': 0,
    'id': -27542,
    'props': {'inRing': False},
    'atomtype': 'H',
    'edges': {-27544: 1.0}},
   {'element': {'number': 1, 'isotope': -1},
    'radical_electrons': 0,
    'charge': 0,
    'label': '3',
    'lone_pairs': 0,
    'id': -27541,
    'props': {'inRing': False},
    'atomtype': 'H',
    'edges': {-27544: 1.0}},
   {'element': {'number': 1, 'isotope': -1},
    'radical_electrons': 0,
    'charge': 0,
    'label': '4',
    'lone_pairs': 0,
    'id': -27540,
    'props': {'inRing': False},
    'atomtype': 'H',
    'edges': {-27544: 1.0}},
   {'element': {'number': 1, 'isotope': -1},
    'radical_electrons': 0,
    'charge': 0,
    'label': '5',
    'lone_pairs': 0,
    'id': -27539,
    'props': {'inRing': False},
    'atomtype': 'H',
    'edges': {-27543: 1.0}},
   {'element': {'number': 1, 'isotope': -1},
    'radical_electrons': 0,
    'charge': 0,
    'label': '6',
    'lone_pairs': 0,
    'id': -27538,
    'props': {'inRing': False},
    'atomtype': 'H',
    'edges': {-27543: 1.0}},
   {'element': {'number': 1, 'isotope': -1},
    'radical_electrons': 0,
    'charge': 0,
    'label': '7',
    'lone_pairs': 0,
    'id': -27537,
    'props': {'inRing': False},
    'atomtype': 'H',
    'edges': {-27543: 1.0}}],

(see the 'labels' on the atom list) Expected behavior return the same labels.

Additional context Accurate parsing of the species object is important for restarts and for testing, as they help to avoid obsolete callings of other functions while performing tests, which may cause unrelated failures. :smile: