# Andre's Insanity

## How to Put Tubes in a Centrifuge

I have been thinking a lot about how to put tubes into a centrifuge. This will be a wonderful journal of physics, biology, math, and computer science.

To begin, why centrifuge things? The most common procedure I do that needs a centrifuge is a miniprep. The number of samples I run varies. The centrifuge I use has 24 slots. The issue with a miniprep is that it involves multiple spins with different tube types and different volumes. That makes it much more difficult to use an extra tube as a blank for balance.

Balancing certain numbers of tubes are easy. Two tubes go opposite each other. Four go in a square. Any even number is actually pretty trivial. Three fit nicely 120° apart, too. Some configurations are not obvious. Balancing five or seven tubes is not intuitive. What would be nice is to have an algorithm to lay out the tubes in the rotor.

From a physical perspective, a rotor is balanced if the centre of mass is exactly the centre of rotation. If this is not the case, then the rotor will gyrate. If there is too much gyration, the rotor can tear itself off the spindle and go through nearby walls. In general, all the tubes are same weight, so their position in the rotor is all that matters.

Given we want to put s samples in a centrifuge rotor with n slots, it's trivial if s divides evenly into n, or, n mod s = 0, since we can just space the tubes evenly at intervals n/s.

In the non-trivial case is more interesting. If two rotor configurations are balanced, the “gluing” the rotors together would still be balanced. In sort, if we transfer the tubes from one balanced rotor into another, the rotor will still be balanced, obviously, we must obey the laws of physics and not put two tubes in to the same slot. That makes figuring this out fairly easy. If we can find two or more rotor configurations that sum to the correct number of samples, we can possibly overlay them. The partition of the number of samples is a set of numbers that sum to s. Therefore, we need a partition such ∀x ∈ P, n mod x = 0 ∧ x ≠ 1. Given this partition, which is relatively easy to find, we need to find a bunch of offsets so that the different configurations can be overlaid without any tubes occupying the same positions. Effectively, given the set of numbers P, ∃oxoy c n / x + oxd n / y + oy mod nx, y ∈ P ∧ c, d ∈ ℤ, xy.

I don't have a smart way of solving that, so I just a depth-first search of all possible offsets. It's crude, but it works. I think I could convert that into a matrix and solve a system of discrete linear equations. I'm not sure that can be done with all the ring math.

I wrote a little program that does all of this and spits out the possibilities. I implemented it using lots of iterators, which in C#, are quite nice, unlike Java's iterators. The source is available. I made a web GUI that is sort of...unique. I create a picture of the rotor configuration but ASP.NET didn't have a particularly good way to send it back to the client, so I did it a particularly fun way. I create a bitmap and draw the rotor configuration on the bitmap. I then write the bitmap to a memory stream as a PNG image. I then convert that memory stream to a Base64-encoded string and put it in the src attribute of an HTML img tag. It works perversely well and doesn't require multiple round trips to the server.

## Cry for the Stupid Children

In winter of last year, I TAed a course and had to mark summaries written by the students about the use of physical laws to understand the evolution of land plants. The course was effectively a writing course, so most of the emphasis was on communicating clearly and correct writing. It's also worth remembering that Laurier is nearly entirely Ontarian English-speaking students. I wrote down some of the choicer stupid quotes.

Large plants with much more complex and intellectual anatomies evolved.
Second, plants need carbon monoxide and oxygen for their metabolic requirements.
Some forget that trees are the largest organisms and there[sic] wood is their means of vascular tissue.

Note that the largest organisms on earth are fungus and most of the wood and bark are actually dead support material. Only a thin outer layer, called the sap wood, is alive and actively being vascular tissue.

Hopefully, it will provide clues as to how we can better our way of life.
The second evolution plants experience where vascular tissues.
The history of plants in an extensive on and who knows where they may become colonised next.
The brief exposure to air can be a source of the evolution.

The worst quote, which I did not write down because it hurt me too much, was a student who told me that the sun orbited the earth. While I realise we are dealing with biologists, that is a piece of astrophysics we should all know.

## Restriction Enzyme Names in LaTeX

I had a moment of genius/stupidity. Restriction enzyme names are all of the form: EcoRI, where Eco is a short form of the organism from which it was isolated, in this case E. coli and RI is a strain and unique identifier, in this case strain R and the first discovered one. Doing this in LaTeX is cumbersome as it involves \textit{Eco}RI every time or defining a slew of macros.

I thought of writing a macro to italicise only the first three letters. This is how it is:

\documentclass{article}
% xstring package needed for \rease
\usepackage{xstring}

% Typeset a restriction enzyme name
\newcommand{\rease}[1]{\textit{\StrLeft{#1}{3}}\StrGobbleLeft{#1}{3}{}}

\begin{document}
\rease{BamHI} and \rease{SmaI} were used to digest despite the tons of \rease{EcoRI} in the freezer.
\end{document}


Hooray. It is much simpler.