Saturday, December 31, 2011

DNA seen through the eyes of a coder, my take

Several years ago in 2008, a programmer researched DNA and  how the cell works. He gave a software related analogy on how it operates.  It was a great overview of the process with the biology language translated for engineers.  I constantly thought about the article and wanted to add my own spin on it.  The author didn't really do anything wrong, and it really is a great article, but I personally wish he would have given a one paragraph software analogy.  (With the core content, I am not a scientist so I can't really refute his research).

I enjoyed the last view paragraphs at the end, "Now, DNA is not like a computer programming language. It really isn't. But there are some whopping analogies. We can view each cell as a CPU, running its own kernel. Each cell has a copy of the entire kernel, but choses to activate only the relevant parts. Which modules or drivers it loads, so to speak. If a cell needs to do something, it whips up the right piece of the genome and transcribes it into RNA. The RNA is then translated into a sequence of amino acids, which together make up a protein the DNA coded for."

I would analogize the DNA processing of the cell like so, DNA is a special type of hardware device and storage software.  Imagine it is like a VMWare like virtual machine.   Not only does it store important information about the cell, key blueprint information about how the cell should function.  But DNA also has special software for dynamically running other applications.  VMWare virtual machine has persistent information contained within its image file.  But, the VMWare player can also execute the machine.

The DNA virtual machine has the cron task launcher and only one cron job configured.  The cron job program launches special software that makes a "web-service call to some remote server". The web-service message might be similar to mRNA and the content is based on core DNA data stored on the virtual machine.   I used the analogy of a remote web-service call because DNA can't leave the nucleus so information and functions are sent remotely.  During transcription, RNA is copied from DNA.  Eventually, proteins are created.  RNA has message information for which protein to create.

So, during the lifecycle of the cell, cron jobs are running every 5 minutes.  The cron job task launches an application reading information from DNA, then launches a web-service call.  At the back-end server, the data from the web-service call (mRNA) is used with data from the server-side (tRNA).  Some additional routines get kicked off on the back-end and eventually proteins are created.  Proteins are also molecular chains that can be used as a structural component for the cell or used to for other cell tasks.  There are sixty thousand different proteins in the human body [1].

(Note: 5 mins is an arbitrary time period for my analogy, a cell can live several months or decades).

[1] The Machinery of Life – Goodsell - 1993

Monday, December 26, 2011

Lorenz Attractor 3D View





[4] - Github projects


Human life faces the same alternatives that confront all other forms of life—of adapting itself to the conditions under which it must live or becoming extinct. You have an advantage over the sagebrush in that you can move from your city or state or country to another, but after all that is not much of an advantage. For though you may improve your situation slightly you will still find that in any civilized country the main elements of your problem are the same.

Friday, December 23, 2011

Ron Paul is the most racist candidate in 2012 by far 

Summary of his remarks. 

Repeal drug laws and it will be a tremendous improvement for blacks snared in an injust system. 

Systems that are impartial will have no special punishments or rewards for people. Right no no one can deny blacks are punished by our justice system. That has to stop. Blacks are 14% of drug users, yet are 36% of those arrested for drugs. 

We must get black men out of prison. The war on drugs is responsible for this. It cost $400 billion since the 1970s fighting drugs. Prohibition is a failure. Drug addiction is a disease and should be treated medically. 

Death penalty is wrong, unjust, and racist. The rich never get it, the poor and minorities are far more likely to get the death penalty. 

Rosa Parks is one of his heros for engaging in peaceful civil disobedience against injust laws. 

Ron Paul has gotten the most black votes of any Republican candidate because he is against injustice. 

He will issue a presidential pardon to EVERYONE, black, white and otherwise convicted of non-violent drug "crimes". 

Libertarianism is about the individual, not the color of their skin. Paul is the anti-racist because he is the ONLY candidate that will protect people against vicious drug laws.

Edit: In recent news Kelly Clarkson supports Ron Paul for 2012.  And not a bad song: Stronger.

Wednesday, December 21, 2011

A Physics Example in Java: A Projectile Fired from a Cannon, 2D Particle Kinematics

Here is an example program that shows how to implement kinematic equations for projectile motion using Java and the Swing 2D graphics libraries.

Equation used to plot projectile path along the X and Y axis

The Java code for these equations are simple, here is the current implementation of the doSimulation routine. The routine calculates the X and Y positions of the projectile over time.  The project only consists of two classes, the class for rendering the simulation and initializing the application.  The other class contains logic for calculating the X and Y positions.

Java code, DoSimulation routine, see s.i and s.k for the X/Y positions

Java 2D Cannon Physics Simulation

Java Source

Based on code from: physics for game developers, David Bourg


So today we see man a highly evolved creature who not only acts but thinks and feels. All these thoughts, feelings and emotions are interrelated.
The body and the mind of man are so closely bound together that whatever affects one affects the other. An instantaneous change of mind instantly changes the muscles of the face. A violent thought instantly brings violent bodily movements.

Sunday, December 18, 2011

Random Code Post of the Day (procedural haskell, parse file)

This is a random code post of the day, with haskell, read a log file, search for a term and then write when the term is found to another file.

Haskell Source, open a file and search for a term



It was a cloudy, sultry afternoon; the seamen were lazily lounging about the decks, or vacantly gazing over into the lead-coloured waters. Queequeg and I were mildly employed weaving what is called a sword-mat, for an additional lashing to our boat. So still and subdued and yet somehow preluding was all the scene, and such an incantation of reverie lurked in the air, that each silent sailor seemed resolved into his own invisible self.

Friday, December 16, 2011

Implementing Example One from the Machine Learning Class in Java

At the end of 2011, Stanford offered a free online machine learning course.  The course covered many aspects of machine learning including linear regression, neural networks, super vector machines, and anomaly detection.

Octave is an open software platform for numerical applications that is compatible with Matlab.  Octave was the   tool of choice for the machine learning class, all of the programming exercises required that you submit Octave source.

Overview of example one:

The first example in the course is to implement one variable linear regression.  The regression in linear regression is a regression towards a mean or moving closer towards a mean.

Partial Approach for Gradient Descent with Octave

In the example, data points are read from a file and after running the example from Octave, this plot is generated.

Overview of example one in Java:

The Java implementation as you might expect is more verbose than the Octave equivalent.  Java doesn't include a matrix library in the standard toolkit so it took 5-10 lines more code to implement basic matrix multiplication as opposed to the seamless multiplication in Octave.

Java Swing Example of MlClass Ex1, regression line and data points


Note:  I tried not to provide a full matlab implementation from the machine learning course as that wouldn't be fair to the students.  Plus the implementation is in Java and really ideal for the actual course.


berlin dot brown at

"In the tumultuous business of cutting-in and attending to a whale, there is much running backwards and forwards among the crew. Now hands are wanted here, and then again hands are wanted there. There is no staying in any one place; for at one and the same time everything has to be done everywhere. It is much the same with him who endeavors the description of the scene. "

Wednesday, December 14, 2011

Quick LaTeX Equation Examples for use by programmers on windows, convert to PNG

LaTeX/TeX is a complex documenting system that is mostly used in a academic setting but can also be used by anyone to convey information.  It is a complete system but a massive system that has been in development for decades so it isn't something that you skim over and become fluent in.  But I did want to provide some full setup scripts so you can add write an equation and add an image of that equation or pseudo code to your blog or word documents.

Install Cygwin and tetex

You can install all of the tex software through cygwin.  Use the cygwin easy click through install wizard.  Select all of the Publishing/tetex*  applications.

1.1 Install of tetex through Cygwin setup
Install Cygwin, make and gcc and vim

gcc and make aren't required for tetext but I use a make script to run tex.  Install gcc and make through the cygwin installer.

Download my make script and example tex files

There are several makefiles on the Internet for running tex files into tex and then converting them into some output.  Download the Makefile that I have in my link and you can simply type 'make' in a directory that has a collection of tex files.

1.2 At directory, see makefile, launch cygwin and run 'make' at a directory with tex files

Write a simple equation and convert to PNG

You will need to follow a three step process to in order to add an equation or pseudo image to your blog; write the equation in vim, execute the provided makefile, run the dvigif command.  Enter this equation using vim.

1.3 Equation in vim

1.4 Running 'make' and then dvigif command

dvigif --png -T'6.6in,7in' b.dvi

1.5 PNG image output after running make build on tex  files and the dvigif command
1.6.a Tex source with various equations and pseudo code

1.6.b Output PNG image from tex source defined in figure 1.6.a
1.7 Source with pseudo code
1.7.b Output from pseudo code
Additional Resources

[1]. Example Source -




Tested with:


CYGWIN_NT-5.1 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin

TeX 3.141592 (Web2C 7.5.4)

"The extreme Cerebral differs from other types chiefly in the fact that while his head is unusually large compared to the body, his alimentive, thoracic, muscular and bony systems are smaller and less developed than the average. The latter fact is due to the same law which causes the Alimentive to have a large body and a small head. Nature is a wonderful efficiency engineer. She provides only as much space as is required for the functioning of any particular organ, giving extra space only to those departments that need it."

--- Berlin Brown