RSpin - Software for NMR People

Created a program to analyze dipolar couplings, complete with QT UI!

A time I shot my shot

In 2011 I was getting my start in science. I worked at a few disparate labs in parallel to make ends meet; lower level jobs like washing glassware and maintaining Drosophila stocks. One day I checked the undergraduate research opportunity board, and I found a job description that was about 12 pages long, rambling and ranting and raving and brilliant; containing such fantastic quotations as:

“If you’re looking for a paid vacation with banker’s hours - this post is simply not the right fit, perhaps inquire with any financiers with whom you study.”

Being young and exploitable, and equally wowed by written language pulled straight from 1857, I applied immediately! Truly I was looking for my chance to learn chemistry from the giants whose shoulders I would beg to stand upon. This is because the writer of that job description was John D. Roberts:

This man got his PhD in WWII. This man cowrote the first modern textbook on organic chemistry. Hell yeah - why wouldn’t I want to listen to every word he had to say?

I received an email from an office assistant telling me to report to Crellin Laboratory, third floor, at 4 PM. I walked into the office, in which he was awaiting, and he turned his head and immediately started the conversation with “and what do you know about… NMR?”

I told him “not much!”

After 3 hours of an impromptu lecture covering 60 years in the field of NMR, I still didn’t know much, but I somehow convinced him I was worth his time - I got the job.

The Project


I worked for the legend himself for 2 years. My first year was spent learning everything there was to know about the field of Nuclear Magnetic Resonance. Everything from the physics of pulse sequences; to the usage and maintenance of the tools themselves; to fundamental computer and math algorithms behind plotting and interpreting the divinations made by the mega magnetic machines.

Part of this first year was spent on the problem of dipolar couplings. These are a form of nuclear magnetic interactions that are very useful for determining the structural conformations that molecules can take on in 3D space. One of the issues that make these couplings difficult to utilize is that they only can really be measured when the target molecule has its movement restricted in a liquid crystal medium.

When molecules are in a solvent, they tend to be everything everywhere all at once. Scienfically we call this “isotropism” - it all averages out to a big blob. When you imprison the little bastards in liquid crystal walls they slow down enough in their wall to wall motions to see - those dipolar couplings are able to be extracted from the NMR spectra and we can use them to determine the backbone angles of the target.

Maybe you can see where this is going - for proteins and large macromolecules, as it turns out, a large open problem is the solution of “what does this molecule actually look like in 3D? … and how does that change in a liquid medium where everything is moving around?”

It would seem that if we could solve this problem for small systems we could at the very least extract major insights to solve the problem for much bigger molecules.

So we did! I wrote a program called “RSpin” (named because the main commercial competitor called their application “MSpin” and my name begins with the letter R).

Mine was a Python based QT GUI program that, given a csv file of the dipolar couplings for the test system, and an initial guess as to how the molecule might look - would optimize the structure to fit the data not based on molecular force fields or traditional free energy optimizations, but on data from the hidden magnetic interactions of the targets themselves. And I did it free and open source!

The math behind the algorithms was real fun - so was building this UI tool for other scientists!

And then what?


I learned a lot from that project. Writing user-friendly code is hard - not even solely because of UI concerns, but because at the time packaging and building python desktop applications was actually rather difficult. I had collaborated with about 10 other lab groups around the world to launch my free and open source tool, and honestly the biggest challenge was getting everyone to be able to get it running (Pipfiles would have helped a lot).

I also learned a tremendous amount about IP law. After I had open sourced my code my postdoc in the lab left to accept a position - and took my research along with them.

After that RSpin was no more! But it lives on in my heart (and screenshots - I got the application running after more than 10 years and that was a fun and nostalgic game).