Putting the concept into action

16 July 2022

Standing on the shoulder of giants:

After analyzing the whole MDAnalysis library, it's time now to begin implementing our idea. Firstly, I started with creating the new ‘guessers’ package, which will be the hub for every context-aware guesser to be implemented in the future. In the process of creating the new guesser's package, I took the topology and core package as a reference in the first few steps, because I believe that those packages have the same spirit as the guesser package that I'm planning to build, and this will help me to better visualize what I want to do. Studying those packages helped me in different ways as copying the metaclass idea for guessers registration, distributing the code in modules with the same spirit (core, base), managing dependencies, etc.

The right way to start:

I first developed the base module of the package which mainly Contains the GuesserMeta metaclass for guessers registration and the BaseGuesser class which represents the parent class for all the upcoming guessers. My mistake in this step was that I was trying to implement the Guessermeta and BaseGuesser before realizing how the universe will interact with this new package. This put me in confusion for a while because I didn’t know what I should add to the base class. Then I shifted to work from the universe point, then adding/modifying methods and attributes in the BaseGuesser accordingly. Also, I removed the Guessermeta class temporarily to relax the problem and just test that the new API is working fine. For testing the new process, I removed mass and atomtype guessing from PDBParser to test passing them to the universe by the new guess_TopologyAttributes API. Then, I created the DefualtGuesser class, which is the first guesser class that will represent the current generic guessing methods. I only added the guess_mass method to just test one attribute guessing before moving to the next step.

I created a pull request (#3753) to add the new guesser package features, and whenever I have a new increment to the code I commit to it until it reaches the mature level to be ready for merging.

Lesson from this step:


1- How to create a package in python

2- A top-down approach for building new features is more efficient than a bottom one

3- Test the basics before moving to the more sophisticated steps

Next step:


After testing that the API basic idea works fine, I will begin to propagate the idea on a wider level as follow:

1- Remove all guessing that happens inside parsers

2- Implement the rest of the BaseGuesser