Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split off a base parser from read_smiles #49

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

pckroon
Copy link
Owner

@pckroon pckroon commented Nov 18, 2024

No description provided.

Copy link
Collaborator

@fgrunewald fgrunewald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! I think we're getting more and more modular, which is really a big benefit.

pysmiles/read_smiles.py Show resolved Hide resolved
pysmiles/read_smiles.py Outdated Show resolved Hide resolved
Comment on lines +262 to +280
for node in mol:
mol.nodes[node].update(parse_atom(mol.nodes[node]['_atom_str']))
for idx, jdx, attrs in ring_bonds:
if mol.nodes[idx].get('rs_isomer'):
mol.nodes[idx]['rs_isomer'][1].append(jdx)
if mol.nodes[jdx].get('rs_isomer'):
mol.nodes[jdx]['rs_isomer'][1].append(idx)
for edge in mol.edges:
if mol.edges[edge]['_bond_str']:
order = bond_to_order[mol.edges[edge]['_bond_str']]
if not order and not zero_order_bonds:
mol.remove_edge(*edge)
continue
mol.edges[edge]['order'] = order
elif mol.nodes[edge[0]].get('aromatic') and mol.nodes[edge[1]].get('aromatic'):
mol.edges[edge]['order'] = default_aromatic_bond
else:
mol.edges[edge]['order'] = default_bond

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one were to make a bold suggestion: These could be put into functions as well such that one can mix and match a read_smiles interpreter function. Maybe even decorators? Something like an abstract interpret_graph method.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, but I need to think on it a little bit. How to organise the code and such. I suggest leaving that for a next PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants