ASNTParser¶
- class manim_chemistry.utils.parsers.asnt_parser.ASNTParser(filename: str | bytes | PathLike)[source]¶
The ASNT format is weird. It’s like a JSON wannabe but ugly. Parsing it has been a pain for the last 5 hours and I wish to never encounter it again. It will only support a single molecule files and fuck it. Yes, fuck it goes to the commit.
Examples¶
parsed_asnt = ASNTParser(filename="acetone_2d.asnt") print(parsed_asnt.atoms_data) print(parsed_asnt.bonds_data) >>> { 1: {"element": "O", "coords": array([3.732, 0.75, 0.0])}, 2: {"element": "C", "coords": array([2.866, 0.25, 0.0])}, 3: {"element": "C", "coords": array([2.0, 0.75, 0.0])}, 4: {"element": "C", "coords": array([2.866, -0.75, 0.0])}, 5: {"element": "H", "coords": array([2.31, 1.2869, 0.0])}, 6: {"element": "H", "coords": array([1.4631, 1.06, 0.0])}, 7: {"element": "H", "coords": array([1.69, 0.2131, 0.0])}, 8: {"element": "H", "coords": array([2.246, -0.75, 0.0])}, 9: {"element": "H", "coords": array([2.866, -1.37, 0.0])}, 10: {"element": "H", "coords": array([3.486, -0.75, 0.0])}, } >>> { 0: {"from_atom_index": 1, "to_atom_index": 2, "bond_type": 2}, 1: {"from_atom_index": 2, "to_atom_index": 3, "bond_type": 1}, 2: {"from_atom_index": 2, "to_atom_index": 4, "bond_type": 1}, 3: {"from_atom_index": 3, "to_atom_index": 5, "bond_type": 1}, 4: {"from_atom_index": 3, "to_atom_index": 6, "bond_type": 1}, 5: {"from_atom_index": 3, "to_atom_index": 7, "bond_type": 1}, 6: {"from_atom_index": 4, "to_atom_index": 8, "bond_type": 1}, 7: {"from_atom_index": 4, "to_atom_index": 9, "bond_type": 1}, 8: {"from_atom_index": 4, "to_atom_index": 10, "bond_type": 1}, }
- inherited-members:
- static data_parser(data: Any) Tuple[Dict, Dict] | List[Tuple[Dict, Dict]] [source]¶
Parses the atoms and bonds data and returns a tuple of dictionaries with each data. The atom data follows the structure:
{<atom_index>: {“element”: <atom_element>, “position”: [<x_pos>, <y_pos>, <z_pos>]}}
- The bond data follows the structure:
{<bond_index>: {“from_atom_index”: <from_atom_index>, “to_atom_index”: <to_atom_index>, “bond_type”: <bond_type>}}