Skip to content

Ryan/dev work#30

Open
Ryan-Rhys wants to merge 49 commits intomasterfrom
Ryan/dev_work
Open

Ryan/dev work#30
Ryan-Rhys wants to merge 49 commits intomasterfrom
Ryan/dev_work

Conversation

@Ryan-Rhys
Copy link
Collaborator

Photoswitch example. Summary of changes that touch other parts of the codebase:

  1. Extra flags added to kpca.py and umap_reducer.py in order to allow the usage of the Morgan fingerprint representation. Default is not to use it.

  2. 'metric' flag added to gen_soap_kmat.py that allows users to specify what form of kernel they want from kpca. Default set to linear.

@Ryan-Rhys Ryan-Rhys requested a review from BingqingCheng May 7, 2020 17:05
Copy link
Owner

@BingqingCheng BingqingCheng left a comment

Choose a reason for hiding this comment

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

Make the default of --keepraw to False. And then we are ready to merge.

Good work!

@@ -100,13 +100,14 @@ def main(fxyz, dictxyz, prefix, output, peratom, fsoap_param, soap_rcut, soap_g,
parser = argparse.ArgumentParser()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cosmetics

@@ -74,7 +74,8 @@ def plot_density_map(X, z, fig=None, ax=None,
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cosmetics


def normalizekernel(kernel):
# first normalize the kernel matrix
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the module I wrote the tests for. Just expanding the docstrings slightly.

@@ -1,6 +1,6 @@
#!/usr/bin/python3
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the original kpca.py script is now deprecated shall we make this deprecated switch compatible with the photoswitch example or would you prefer a modification to the new kpca? (Wherever that might be, I haven't looked for it yet!)

Copy link
Owner

Choose a reason for hiding this comment

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

You can implement the Morgan fingerprints as a Global_Descriptor class in descriptors/global_descriptors.py

@@ -50,7 +50,8 @@ def main(fmat, fxyz, ftags, fcolor, colorscol, prefix, output, peratom, keepraw,
if fxyz != 'none':
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cosmetics

@@ -0,0 +1,72 @@
"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Very basic tests for the functions in the ml_kernel_operations.py module but useful as a template for further tests.


from asaplib.kernel.ml_kernel_operations import kerneltodis, kerneltodis_linear, kerneltorho, normalizekernel


Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The @pytest.mark.parametrize decorator allows you to specify multiple test inputs to be run with pytest. In the case of the kernel function tests, we pass in different types of kernel as the test input and check that the output satisfies some basic properties that we'd expect to be present.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The passing of the tests, while not a formal correctness proof, ensures that the functions we write produce the correct output on the examples we specify. It's possible that a pathological input exists which will cause the functions to fail, but we try to think of all of these pathological inputs in advance, test them here and if there's a failure, modify the function.

Copy link
Owner

@BingqingCheng BingqingCheng left a comment

Choose a reason for hiding this comment

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

Let's not keep the png files in the examples. As we have changed the design a lot, so the commands and the outputs are very different now.

@@ -1,6 +1,6 @@
#!/usr/bin/python3
Copy link
Owner

Choose a reason for hiding this comment

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

You can implement the Morgan fingerprints as a Global_Descriptor class in descriptors/global_descriptors.py


import numpy as np
from rdkit.Chem import MolFromSmiles
from rdkit.Chem.AllChem import GetMorganFingerprintAsBitVect
Copy link
Owner

Choose a reason for hiding this comment

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

Can we import the package inside the class?

return {'acronym': self.acronym, 'descriptors': self.cm.create(frame, n_jobs=8)}, {}


class FingerprintDescriptor:
Copy link
Owner

Choose a reason for hiding this comment

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

The logic of ASAPXYZ class is that the create() function for the descriptors takes a frame as argument.

So in this case,
create(self, frame):
compute_morgan(frame.info['smiles'])

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