DNA Visualization

Screen capture from R.M's code.
Screen capture from R.M’s code.

Another interesting project that came out of the Creativity Interim was a VPython program that uses the DNA Writer translation table to convert text into a DNA sequence that is represented as a series of colored spheres in a helix.

The code, by R.M. with some help from myself, is below. It’s pretty rough but works.

dna_translator.py

from visual import *
import string

xaxis = curve(pos=[(0,0),(10,0)])

inp = raw_input("enter text: ")
inp = inp.upper()


t_table={}



t_table['0']="ATA"
t_table['1']="TCT"
t_table['2']="GCG"
t_table['3']="GTG"
t_table['4']="AGA"
t_table['5']="CGC"
t_table['6']="ATT"
t_table['7']="ACC"
t_table['8']="AGG"
t_table['9']="CAA"
t_table['start']="TTG"
t_table['stop']="TAA"
t_table['A']="ACT"
t_table['B']="CAT"
t_table['C']="TCA"
t_table['D']="TAC"
t_table['E']="CTA"
t_table['F']="GCT"
t_table['G']="GTC"
t_table['H']="CGT"
t_table['I']="CTG"
t_table['J']="TGC"
t_table['K']="TCG"
t_table['L']="ATC"
t_table['M']="ACA"
t_table['N']="CTC"
t_table['O']="TGT"
t_table['P']="GAG"
t_table['Q']="TAT"
t_table['R']="CAC"
t_table['S']="TGA"
t_table['T']="TAG"
t_table['U']="GAT"
t_table['V']="GTA"
t_table['W']="ATG"
t_table['X']="AGT"
t_table['Y']="GAC"
t_table['Z']="GCA"
t_table[' ']="AGC"
t_table['.']="ACG"

dna=""

for i in inp:
    
    dna=dna+t_table[i]
print dna

m=0
r=3.0
f=0.5
n=0.0
dn=1.5


start_pos = 1
for i in dna:
    rate(10)
    n+=dn
    m+=1
    x = n
    y=r*sin(f*n)
    z=r*cos(f*n)
    a=sphere(pos=(x,y,z))
    #print x, y, z
    if (i == "A"):
        a.color=color.blue
    elif (i== "G"):
        a.color=color.red
    elif (i== "C"):
        a.color=color.green

Getting Started with a Raspberry Pi

Student wires the breadboard attached to a Raspberry Pi.
Student wires LED’s to a circuit on a breadboard attached to a Raspberry Pi.

Raspberry Pi‘s are small computers that are remarkably easy to use if you know what you’re doing. Unfortunately, I did not quite know what I was doing. On the other hand, fortunately, I had Mr. Schmidt available to give me the kick start I needed to get going. In this post, I’ll outline, in as much detail as possible, how we got started; how we helped a student put together a synchronized LED light and digital sound project.

You should just be able to plug your Pi into a monitor using the HDMI cable that comes with the starter kit (like this kit by Adafruit) and power it up. However, we did not have a monitor that could take an HDMI cable, so we had to connect the hard way: by plugging the Pi into an ethernet cable and finding it on the local network. This is what’s called a headless setup — with no monitor and no keyboard — and I followed a lot of Robert A. Wood’s instructions on headless setups.

Install the Raspbian Operating System for remote access

First you have to make sure you have a bootable operating system on the Pi’s SD card that will allow you to connect remotely through the internet. The card that came with the starter kit had the basic NOOBS operating system installed, but NOOBS does not allow remote access by default.

I downloaded the Raspbian raw image to my computer then copied the image to the SD card using the terminal program dd. Follow this procedure with caution because you can do a lot of damage if you copy the image over your computer’s hard drive (which is remarkably easy to do with dd). The procedure follows:

1) Once you plug the SD card into your computer it should mount automatically. You need to detect where it is mounted using (on a Mac running OSX) the diskutil program:

> diskutil list

This should give you a list of all of your mounted disks. Identify the one that is the SD card. It should look something like this:

Output from 'disktuil list'.
Output from ‘disktuil list’.

It shows my 4 gigabyte disk located at ‘/dev/disk1’.

2) If you’re absolutely sure you’ve identified the SD card you need to unmount it:

> diskutil unmountDisk /dev/disk1

3) Now if you’re still absolutely sure you have the right location of the SD card copy the image. Note that in the example below the option ‘if‘ means input file, while ‘of‘ means output file:

> dd if=~/raspberry/raspi/2014-01-07-wheezy-raspbian.img of=/dev/disk1

I had the devil of a time trying to install the raw image of the Raspbian operating system. After a few hours of frustration I finally pulled an SD card from my small camera and lo-and-behold the copy went through easily. So make sure you have a good quality card.

Talking to the Pi

Plug the SD card with Raspbian installed into the Pi, plug the Pi into a power outlet, then and plug an ethernet cable into the Pi. The Pi should boot up and connect to the internet automatically. Now you just have to find it from your computer. Mr. Schmidt helped a lot with this step, but I also used Pete Taylor’s instructions as well.

The ifconfig command will tell you your computer’s IP address. Look under the section en1.

> ifconfig

My IP address turned out to be 191.163.3.218.

To find the Pi I had to download and install nmap to locate all things on the local network. Once installed I used:

> sudo nmap -sP 191.163.3.0/24

You should find something labeled ‘Raspberry Pi’ with an IP address that’s almost identical to yours except for the last of the four numbers. I found mine at 191.163.3.214.

Now, you can log in to the Raspberry Pi using the username ‘pi’ and the password ‘raspberry’:

> ssh pi@191.163.3.214

And, ‘Bam’, you’re in.

Configure and Update

I used the configuration utility ‘raspi-config’ to expand the root file system to take up the entire SD Card: expand_rootfs:

pi> raspi-config

Update the software using the two commands:

pi> sudo apt-get update
pi> sudo apt-get upgrade

You can also set up the Pi for remote window access by running a Virtual Network Computing (VNC) server and using a vnc client (like Chicken on the Mac). I installed ‘tightvnc’ and started the vnc server on the Pi with:

pi> sudo apt-get install tightvncserver
pi> vncserver :1

We never did end up using the vnc window, however.

The light circuit

We hooked up the LED circuit to the output pin GPIO 17 in series with a resistor and then back into a ground pin of the Pi, pretty much as the Gordon’s Projects page describes.

Talking to the Circuits/Pins

In order to get the Pi to operate the LED lights you have to control the pins that communicate in and out. Our starter kit came with a ribbon cable and breakout board that connects the pins from the Pi to a breadboard, which makes it easier to build circuits.

But first we have to be able to control to the Pi’s pins. I tried two different methods. The first was to use wiringPi, which is a set of command line tools, while the second was to use the Rpi.GPIO library for the Python programming language. We found it was much easier to use Python for its ease of programming.

Command line: wiringPi:

To get wiringPi, download it with ‘git‘, go to its directory, then build it (Gordon’s Projects has the instructions):

pi> git clone git://git.drogon.net/wiringPi
pi> cd wiringPi
pi> ./build

Now you can manipulate pin 0 (GPIO 17, which is labeled #17 on the breakout board) by: 1) setting to output mode; 2) turning it on, and; 3) turning it off:

pi> gpio mode 0 out
pi> gpio write 0 1
pi> gpio write 0 0

The following short script (red-light-flash.s) turns the light on and off ten times:

red-light-flash.s

#!/bin/bash
# a single blinking led light attached to gpio0
# based on 
# https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/

for i in `seq 1 10`
do
gpio write 0 1
sleep 0.5
gpio write 0 0
sleep 0.5
done

The script needs to be given execute permissions:

pi> chmod 777 red-light-flash.s

then run:

pi> ./red-light-flash.s

Python: Rpi.GPIO

As I mentioned above, it’s much easier to write programs in Python than to use shell scripts. So we’ll install the Python library, RPi.GPIO, to that allows us to communicate with the Pi. To get RPi.GPIO we first need the Python Development toolkit:

pi> sudo apt-get install python-dev

Then install Rpi.GPIO:

pi> sudo apt-get install python-rpi.gpio

To operate the GPIO-17 (turn it on and off every half second) we use the following program:

flash.py

#!/usr/bin/env python
 
from time import sleep
import RPi.GPIO as GPIO

cpr = 17  ## The GPIO Pin output number

GPIO.setmode(GPIO.BCM) ## Use board pin numbering

GPIO.setup(cpr, GPIO.OUT) ## Setup GPIO Pin 7 to OUT

for i in range(10):
	GPIO.output(cpr, True)
	sleep(0.5)
	GPIO.output(cpr, False)
	sleep(0.5)
GPIO.cleanup()

We run the program using the command:

pi> sudo python flash.py

Addendum: A Student’s Light and Sound Project

During our Creativity interim, one student chose to use the python program flash.py as a starting point to make a program to combine light and musical notes.

Dendrochronology with Bradford Pears

A slice out of the trunk of a Bradford Pear tree.
A slice out of the trunk of a Bradford Pear tree.

With the help of Scott Woodbury from the Shaw Nature Reserve, Dr. Sansone lead the effort to remove the six mature Bradford Pear trees from the front of the school over the last interim. We collected slices of each of the trees so students could do a little dendrological work with the tree rings.

The trees were planted as part of the original landscaping of the school campus. They’re pretty in the spring and fall, but are an aggressive invasive species.

The fast growth, however, make for wide growth rings. In fact, in addition to the annual rings, there are several millimeter wide sub rings that are probably related to specific weather events within the year. I’d like to see if we can co-relate some of the sub-ring data to the longer term instrumental record of the area.

The tree cutting was quite fun as well, despite being done on a cold day near the end of November. Students helped stack logs and organize branches along the road for the woodchipper. I learned how to use a chainsaw.

Six Bradford Pear tree slices, cut on  November 25th, 2013.
Six Bradford Pear tree slices, cut on November 25th, 2013.

Dissecting Computer: Building a Hovercraft

Extracting the hard drive from an old computer.

Our school was recycling some old computers, so my students convinced me that it would be worthwhile o dissect a few of them to see if there was anything worth saving. It was quite remarkable to see just how interested they were in examining the insides of the machines — a few desktop computers and a monitor — but I guess I shouldn’t have been surprised. After all, it’s getting harder and harder to open up their iPods and other electronics, and even more difficult to repair and repurpose them, so I can see why students would jump at the chance of looking inside a device. Also, they tend to like to break things.

Pulling apart a monitor.

To get them to think a little more about what they were seeing, I got a couple students to draw a scale diagram of one of the motherboards, and write up a report on what they’d done.

Diagramming a motherboard.

Some of the other students spent their time trying to make all the motors, LED’s, and lasers work by hooking them up to 9-Volt batteries. Then they found the fans… and someone had the brilliant idea that they could use it to make a hovercraft. Using a gallon sized ziplock bag and some red duct tape, a prototype was constructed.

Hovercraft prototype.

The fan would inflate the bag which would then let air out the bottom through small holes. I convinced them to try to quantify the effectiveness of their fans before they put the holes in by hooking the bag up to one of our Vernier pressure sensors that plug into their calculators. Unfortunately, the sensor was not quite sensitive enough.

Attempting to measure the hovercraft’s bag pressure using a gas pressure sensor connected to a calculator.

This was not how I had planned spending those days during the interim, but the pull of following the students’ interests was just too strong.

Ski Trip (to Hidden Valley)

Approaching a change in slope.

We took a school trip to the ski slopes in Hidden Valley. It was the interim, and it was a day dedicated to taking a break. However, it would have been a great place to talk about gradients, changes in slopes, and first and second differentials. The physics of mass, acceleration, and friction would have been interesting topics as well.

Calculus student about to take the second differential.

This year has been cooler than last year, but they’ve still struggled a bit to keep snow on the slopes. They make the snow on colder nights, and hope it lasts during the warmer spells. The thermodynamics of ice formation would fit in nicely into physics and discussion of weather, while the impact of a warming climate on the economy is a topic we’ve broached in environmental science already.

The blue cannon launches water into the air, where, if it’s cold enough, it crystallizes into artificial snow. The water is pumped up from a lake at the bottom of the ski slopes.

Harvesting and Processing Chickens

We successfully harvested and processed three chickens during last week’s interim. It was my first time going through the entire process, but fortunately we had a very experienced guide in Dr. Samsone who also happens to be a vet.

The interim focused on where food comes from (students also saw the documentary “King Corn”), and the cleaning of the chickens was tied into our Biology students’ study of anatomy (I’d done fish and squid before). Unfortunately, I was unable to find someone who knew how to read the entrails so we could tie the process into history and language arts as well.

Student holds a kidney. A heart is in the background.

When we were done with the processing and analysis, Mr. Elder cooked the chickens on our brand new grill (which worked quite well he says). The chickens were free-range (donated by Ms. Eisenberger), but a little on the old side, at about 7 months old; the chickens you buy at the grocery are somewhere around 2 months old.

Dr. Samsone recommended that next time we raise the chickens ourselves from chicks, which I’d love to try, but I suspect would run into some serious resistance from the students. We’d only had the chickens we harvested for five minutes before they’d all been given names. Raising chickens from chicks would bring a whole new level of anthropomorphizing.

Chicken on the grill. The culmination of the interim.

References

Being new to the chickens, I spent a bit of time researching how it is done.

Ken Bolte, from the Franklin County Extension of the University of Missouri, recommended the University of Minnesota’s Extension site on Home Processing of Poultry (the page on evisceration provided an excellent guide), as well as Oklahoma State’s much briefer guide (pdf).

Dr. Samsone recommended the series of videos from the Featherman Equipment Company. Videos are particularly useful for novices like myself.

Herrick Kimball’s excellent How to Butcher a Chicken is also a great reference.

How to do Research on the Internet: A Lesson

This morning I did a little presentation with the middle school on how to do research on the internet, and we actually had a very good discussion. I focused on two key things: assessing credibility and writing citations (giving credit).

Credibility

[Henry] Hudson’s main goal as an explorer was to find a northern passage to the Orient. … He started his journey in May of 1607 and returned in September of the same year when his route was blocked by the Great Barrier Reef.

— All About Explorers (accessed Feb. 2012): Henry Hudson

I started by having the students to look up some explorers. If you prefix an explorer’s name with “all about explorers” (e.g. “all about explorers Christopher Columbus) the first link on google leads to the right website.

They were supposed to read the page and recorded three facts that they found interesting, but, in doing so, it pretty quickly becomes apparent that the information might not be very reliable; Columbus did not, after all, have to rely on infomercials to build support for his expedition.

The All About Explorers website was created by a group of teachers to be a tool for teaching about how to do research on the internet.

Having them see the site come up on google is, I think, better than sending them directly to the url. Google is usually their first recourse for researching anything, so it’s nice to see that google does not give information about credibility.

The discussion that ensued ranged pretty widely, but a key question that kept recurring was: how do you judge the credibility of a website. We talked a little bit about the possible biases of commercial .com and .net websites, and about the fact that .org’s may well also have their own biases, since it does not require any credentials to set one up (see montessorimuddle.org for example). On the other hand, while .gov and .edu domains (as well as most U.S. state and other country websites) are restricted to governments and colleges, that improves their credibility, but, in itself, is no guarantee of accuracy or being unbiased.

So much of assessing websites’ credibility comes from experience, which students just don’t have much of yet, so I recommended that checking with teachers and adults might be a good bet. Confirming data from multiple sources also helps, but you have to be careful, since so many websites now use Wikipedia as a source (or even reprint things directly from Wikipedia) that any errors in a Wikipedia page can spread far and wide pretty fast.

We did not get into how to use Wikipedia well (go for the sources at the bottom of the page), but we’ll get to that later.

Citing

For the second part of the lesson, I had them look up the same explorers they’d searched on the All About Explorers website. They had free range to search anywhere they wanted, but not only did they have to now collect facts but were to also find a good picture.

I’d wanted the pictures so we could talk about copyright and getting permissions to use media, but we did not get that far.

While they were satisfyingly more skeptical about where they got their information from, they were quite happy to give me the facts they’d found without attribution.

So I took the chance to talk about citing sources: to give credit where it is due; to avoid even the appearance of plagiarism; to give your reader an idea of how credible your sources are (and by extension how credible you are); and to let you readers know how up-to-date your information is.

An example of a citation for a website.

Conclusion

For the next week or so the middle and high school are on an interim. This is our writing interim, so they’ll be working on research projects (including how to do research) and creating publications (I’m in charge of the science journal).

Since more and more research is going online, hopefully this was a good primer to get students started.