Skip to content

Refactor CIF Import#1607

Merged
trisyoungs merged 44 commits into
developfrom
1576-refactor-cif-import
Sep 11, 2023
Merged

Refactor CIF Import#1607
trisyoungs merged 44 commits into
developfrom
1576-refactor-cif-import

Conversation

@jws-1
Copy link
Copy Markdown
Member

@jws-1 jws-1 commented Aug 3, 2023

This PR refactors the CIF importing, moving the bulk of the code from the dialog into cifClasses. A single class has been added CIFSpecies that now does the work.

I think this is moving in the right direction, but further work likely needs to be done - so a second pair of eyes would be useful!

Works towards #1576.

@jws-1 jws-1 requested a review from trisyoungs August 3, 2023 09:16
Copy link
Copy Markdown
Member

@trisyoungs trisyoungs left a comment

Choose a reason for hiding this comment

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

First off, I really like the way this cleans up the wizard code and collects all of the CIF stuff together - clear separation, like it a lot.

I don't think CIFSpecies is an appropriate class name any longer since it does an awful lot more than that. As a related broad comment I wonder about whether the functionality of CIFSpecies should be absorbed into CIFImporter, and that class renamed to something like CIFHandler? Having the import functionality as a separate thing doesn't offer a lot.

My final comment relates to unit testing, which is now one thing we'll be able to do once this refactor is complete. I think it would be most wise to include the testing in this PR - I'm happy to work on that once the present changes have settled.

Comment thread src/gui/importCIFDialogFuncs.cpp Outdated
Comment thread src/gui/importCIFDialogFuncs.cpp Outdated
@trisyoungs trisyoungs added this to the Release 1.4 milestone Aug 3, 2023
@jws-1 jws-1 requested a review from trisyoungs August 4, 2023 13:02
@trisyoungs trisyoungs force-pushed the 1576-refactor-cif-import branch 2 times, most recently from dabe64c to 2c4053e Compare August 31, 2023 20:34
Copy link
Copy Markdown
Member Author

@jws-1 jws-1 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 where things are going - I'm quite pleased with our new interface!

@trisyoungs trisyoungs force-pushed the 1576-refactor-cif-import branch 2 times, most recently from e76725d to 08b004a Compare September 8, 2023 14:54
@trisyoungs trisyoungs force-pushed the 1576-refactor-cif-import branch from 08b004a to 6948ea7 Compare September 9, 2023 19:21
@trisyoungs trisyoungs force-pushed the 1576-refactor-cif-import branch from 6948ea7 to edbbcbb Compare September 9, 2023 20:26
Copy link
Copy Markdown
Contributor

@rprospero rprospero left a comment

Choose a reason for hiding this comment

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

This came together beautifully. The only comments I have are praise.

Comment thread src/io/import/cif.h
Comment on lines +99 to +109
// CIF Species Update Flags
enum UpdateFlags
{
CleanMoietyRemoveAtomics, /* Remove atoms of single moiety */
CleanMoietyRemoveWater, /* Remove water molecules of single moiety */
CleanMoietyRemoveNETA, /* Remove single atoms by NETA definition */
CleanRemoveBoundFragments, /* Remove entire fragments when using NETA definition */
CalculateBonding, /* Calculate bonding */
PreventMetallicBonding, /* Prevent metallic bonding */
CreateSupermolecule
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This flag enum makes me unreasonably happy

Comment thread src/io/import/cif.cpp
std::vector<int> allIndices(sp->nAtoms());
std::iota(allIndices.begin(), allIndices.end(), 0);
std::vector<int> indicesToRemove;
std::set_difference(allIndices.begin(), allIndices.end(), fragment.begin(), fragment.end(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd never seen set_difference before, but it's the perfect tool for the job.

@jws-1
Copy link
Copy Markdown
Member Author

jws-1 commented Sep 11, 2023

Also happy with this!

@trisyoungs trisyoungs merged commit cc5973a into develop Sep 11, 2023
@trisyoungs trisyoungs deleted the 1576-refactor-cif-import branch September 11, 2023 15:20
rprospero pushed a commit that referenced this pull request Mar 11, 2024
Co-authored-by: Tristan Youngs <tristan.youngs@stfc.ac.uk>
rprospero pushed a commit that referenced this pull request Apr 8, 2024
Co-authored-by: Tristan Youngs <tristan.youngs@stfc.ac.uk>
rprospero pushed a commit that referenced this pull request Apr 9, 2024
Co-authored-by: Tristan Youngs <tristan.youngs@stfc.ac.uk>
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.

3 participants