-
Notifications
You must be signed in to change notification settings - Fork 23
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
BugFix: Don't overwrite self.mol if self.mol_from_xyz is None #106
Conversation
Codecov Report
@@ Coverage Diff @@
## master #106 +/- ##
==========================================
- Coverage 40.6% 31.49% -9.11%
==========================================
Files 22 22
Lines 5221 5226 +5
Branches 1353 1357 +4
==========================================
- Hits 2120 1646 -474
- Misses 2759 3271 +512
+ Partials 342 309 -33
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #106 +/- ##
==========================================
+ Coverage 40.6% 40.62% +0.01%
==========================================
Files 22 22
Lines 5221 5226 +5
Branches 1353 1357 +4
==========================================
+ Hits 2120 2123 +3
+ Misses 2759 2758 -1
- Partials 342 345 +3
Continue to review full report at Codecov.
|
4c4dce8
to
280b4eb
Compare
@@ -827,6 +830,8 @@ def mol_from_xyz(self, xyz=None): | |||
'Got xyz:\n{0}\n\nwhich corresponds to {1}\n{2}\n\nand: {3}\n{4}'.format( | |||
xyz, self.mol.toSMILES(), self.mol.toAdjacencyList(), | |||
original_mol.toSMILES(), original_mol.toAdjacencyList())) | |||
if self.mol is None: | |||
self.mol = original_mol # todo: Atom order will not be correct, need fix | |||
else: | |||
self.mol = molecules_from_xyz(xyz, multiplicity=self.multiplicity, charge=self.charge)[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alongd What if after the else statement, molecules_from_xyz gives None. In this case, it seems that we will still have a problem of self.mol = None. How should we resolve that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this condition is true, then this means that self.mol is None to begin with, and molecules_from_xyz
is our last resort. If it doesn't work, the user is expected to give some 2D representation. When we do it in an automated fashion, we have an RMG Species object, so it shouldn't be a problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! please see comments
arc/species/species.py
Outdated
else: | ||
# parameters were entered directly, not via an RMG:Species object | ||
|
||
# parameters were entered directly, not via an RMG:Species object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should be removed, since the code here refers to all cases now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
self.charge = charge | ||
if self.mol is None: | ||
if adjlist: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add mol
before adjList, inchi and SMILES (it can also be directly given)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we already have self.mol = mol in the init? See line 118, species.py @alongd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
@@ -827,6 +830,8 @@ def mol_from_xyz(self, xyz=None): | |||
'Got xyz:\n{0}\n\nwhich corresponds to {1}\n{2}\n\nand: {3}\n{4}'.format( | |||
xyz, self.mol.toSMILES(), self.mol.toAdjacencyList(), | |||
original_mol.toSMILES(), original_mol.toAdjacencyList())) | |||
if self.mol is None: | |||
self.mol = original_mol # todo: Atom order will not be correct, need fix | |||
else: | |||
self.mol = molecules_from_xyz(xyz, multiplicity=self.multiplicity, charge=self.charge)[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this condition is true, then this means that self.mol is None to begin with, and molecules_from_xyz
is our last resort. If it doesn't work, the user is expected to give some 2D representation. When we do it in an automated fashion, we have an RMG Species object, so it shouldn't be a problem
Thanks for your contribution! |
280b4eb
to
345324a
Compare
@alongd Many thanks for your review. I have changed the commit message. Please let me what do you think of the self.mol = mol in the init. |
Could you change the commit message (not the PR title)? |
Temporary fix. Need to troubleshoot why self.mol_from_xyz is None i.e. why it does not parse xyz as expected
345324a
to
277e7ef
Compare
@alongd I updated the commit message and also rebased. |
arc/species/species.py
Outdated
elif smiles: | ||
self.mol = Molecule(SMILES=smiles) | ||
if not self.is_ts and self.mol is None and self.generate_thermo: | ||
logging.warn('No structure (SMILES, adjList, RMG:Species, or RMG:Molecule) was given for species' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change logging.warn
(which will be deprecated soon) to logging.warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just made another commit to replace all logging.warn
to logging.warning
in species.py. I also changed the code to conform to PEP 8.
I added another small comment. |
Also modified code to conform PEP 8 style guide
Many thanks for the comment. I opened an issue addressing our problem here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
Temporary fix. Need to troubleshoot why self.mol_from_xyz is None
i.e. why it does not parse xyz as expected