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

Big smiles #358

Closed
wants to merge 25 commits into from
Closed

Big smiles #358

wants to merge 25 commits into from

Conversation

fgrunewald
Copy link
Member

@fgrunewald fgrunewald commented Jan 19, 2024

Implements parsing capabilities for an adopted BigSmiles format. This format allows to specify both the residue graph well as any all-atom molecule utilising a string-based description similar to a smile.

Copy link
Member

@pckroon pckroon left a comment

Choose a reason for hiding this comment

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

I like the functionality, but I'm not super happy with the parser code tbh. As it is I wouldn't like to have to take over its maintenance

polyply/src/big_smile_parsing.py Outdated Show resolved Hide resolved
polyply/src/big_smile_parsing.py Show resolved Hide resolved
polyply/src/big_smile_parsing.py Outdated Show resolved Hide resolved
polyply/src/big_smile_parsing.py Outdated Show resolved Hide resolved
polyply/src/big_smile_parsing.py Outdated Show resolved Hide resolved
polyply/src/big_smile_mol_processor.py Outdated Show resolved Hide resolved
polyply/src/big_smile_mol_processor.py Show resolved Hide resolved
polyply/tests/test_big_smile_mol_proc.py Show resolved Hide resolved
polyply/tests/test_big_smile_parsing.py Show resolved Hide resolved
polyply/tests/test_big_smile_parsing.py Show resolved Hide resolved
@fgrunewald
Copy link
Member Author

@pckroon thanks for the comments! I don't understand your worry about the parser maintenance. This is a wrapper around pysmiles that lives in the polyply repro. So maintenance only goes as far as your polyply commitments go.

@pckroon
Copy link
Member

pckroon commented Jan 25, 2024

That's the standard I aim for when reviewing ;)

@fgrunewald fgrunewald requested a review from pckroon March 7, 2024 15:09
Copy link
Member

@pckroon pckroon left a comment

Choose a reason for hiding this comment

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

Getting there, still some comments ;)

polyply/src/big_smile_mol_processor.py Show resolved Hide resolved
polyply/src/big_smile_mol_processor.py Show resolved Hide resolved
Comment on lines +121 to +122
hcount = VALENCES[element][0] -\
self.meta_molecule.molecule.degree(node) + 1
Copy link
Member

Choose a reason for hiding this comment

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

The VALENCES[element][0] doesn't always work. You need to select the smallest valence that is larger than the current number of bonds present.

Also, why +1?

polyply/src/big_smile_mol_processor.py Show resolved Hide resolved
polyply/src/big_smile_mol_processor.py Show resolved Hide resolved
if stop < len(pattern) and pattern[stop] == '|':
# eon => end of next
Copy link
Member

Choose a reason for hiding this comment

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

Refactor eon -> end_of_next?


# add the new residue
# new we add new residue as often as required
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# new we add new residue as often as required
# now we add new residue as often as required

prev_node = anchor
# the outermost loop goes over how often a the branch has to be
# added to the existing sequence
for idx in range(0,int(pattern[eon_a+2:eon_b])-1):
Copy link
Member

Choose a reason for hiding this comment

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

Create a variable repetition_number or something to aid readability

Suggested change
for idx in range(0,int(pattern[eon_a+2:eon_b])-1):
repetition_number = int(pattern[eon_a+2:eon_b])-1
for idx in range(0, repetition_number):

Also, why -1?

mol_graph.nodes[node]['hcount'] = hcount - len(mol_graph.nodes[node]['bonding'])
# get the degree
ele = mol_graph.nodes[0]['element']
# hcoung is the valance minus the degree minus
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# hcoung is the valance minus the degree minus
# hcount is the valence minus the degree minus

Comment on lines +99 to +100
# nx.draw_networkx(meta_mol.molecule, with_labels=True, labels=nx.get_node_attributes(meta_mol.molecule, 'element'))
# plt.show()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# nx.draw_networkx(meta_mol.molecule, with_labels=True, labels=nx.get_node_attributes(meta_mol.molecule, 'element'))
# plt.show()

@pckroon pckroon mentioned this pull request Mar 20, 2024
9 tasks
for node in mol_graph.nodes:
if mol_graph.nodes[node].get('bonding', False):
# get the degree
ele = mol_graph.nodes[0]['element']
Copy link
Member Author

Choose a reason for hiding this comment

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

line 290 needs to be updated to node instead of just taking 0

@fgrunewald
Copy link
Member Author

retired in favor of cgsmiles

@fgrunewald fgrunewald closed this Jul 3, 2024
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