RSS

Tag Archives: code

The Book Scavenger

Screen Shot 2016-09-11 at 9.56.03 AM.png>Spoiler Alert! Or Trigger Warning, if you are emotionally tied to storytelling. This post will discuss some of the secret codes used in a book. If you haven’t yet read ‘The Book Scavenger,’ I suggest that you do so. Until that time, don’t read beyond the following paragraph!<

I picked up a copy of The Book Scavenger by Jennifer Chambliss Bertman from Denver’s Tattered Cover Book Store so that my wife would have something to read on the scant downtime she had during the AMVA Conference held there this past summer. It was advertised as the One Book One Denver selection for 2016.

Read the rest of this entry »

 
Leave a comment

Posted by on September 11, 2016 in Uncategorized

 

Tags: , , , , , , ,

A really challenging puzzle – even with hints

Unknown-2I’ve been watching cryptography videos again on Khan Academy. In doing so, I created this puzzle. But don’t worry about it. It’s really hard, even with the hints I provide.

 
Leave a comment

Posted by on November 23, 2014 in Uncategorized

 

Tags: , , , , ,

Cryptography

Today is the first day of the Coursera Cyrptography class taught by Stanford Professor, Dan Boneh. I follow courses like this every once in a while in order to learn a bit about topics that I would not otherwise get any exposure to. Boneh’s course is a little math-intense, but there is another more concept-driven course on the same topic being offered on Khan Academy. If you haven’t taken advantage of either of these two sites, you should look into them. Both are entirely free, and both are taught by excellent educators.

Here’s a video from the Khan Academy site introducing the Caesar Cipher, a simple cipher like those used on radio dramas of the past (get your secret decoder ring!).

If you want to crack a simple substitution cipher like this, you might want to start by using a frequency chart of letters used in the English language, like this one:


The Caesar cipher: Brit explains the Caesar cipher, the first popular substitution cipher, and shows how it was broken with “frequency analysis”

frequencies

 

 

 

However, once you figure out the easiest letters (e,t,and a), things get a bit more difficult. At this point, you will probably have to start looking at letter pairings (Bigrams) to see if any useful patterns show up there. Here’s a listing of the most common Bigrams (again, in English).

bigrams

 

 

 

 

 

It’s interesting that these kinds of codes might ever have been considered sophisticated enough to use in the real world. After all, it’s easy to find examples of these types of ciphers in daily newspapers around the world presented as cryptograms that people do for fun.

 

KT RPP EXRDJ PXZ’J KX BOXD EVDIXI,

KSZ DBZ JB BOXD EVDIXI ZQRZ BSA KARVDJ YRPP BSZ.

                                               -AVWQRAI IRCNVDJ

 
Leave a comment

Posted by on September 8, 2014 in Education

 

Tags: , , , , , , ,

Codon Usage Bias – Part I

To the molecular biologists:

Optimize ye codons while ye may

For time is a-flying

And this clone you have in R & D today

Tomorrow will be … in manufacturing- and it’s just impossible to change anything at that point, so forget it.

Image

I”m no rocket surgeon

 Codon Usage Bias – Part I

I read an article yesterday about codon bias that has been stuck in my head ever since. The article, appeared as a ‘Perspectives’ piece in the 13 Dec 2014 issue of Science, with the title, ‘The Hidden Codes That Shape Protein Evolution.’

This article addresses some details not often considered in how DNA directs the synthesis of proteins.

 I spend a lot of time in my classes discussing the basic mechanism by which DNA –>RNA –> Protein, known as the Central Dogma. A lot gets left out of these lectures in order to keep it simple, which sometimes keeps the way I think about the flow of information pretty simplified as well.

Fortunately, this article rattled my cage enough to open my mind to the myriad influences that go into the stuff of life. Here, Weatheritt and Babu, look at how DNA sequences may be under selective pressures independent of just the proteins they encode.

I’ve done a fair amount of molecular biology in my life, including cloning genes and moving them into other organisms for expression as drugs or drug components. One example of this was in a lab where we used live-vectors as immunogens in order to take advantage of the uniquely broad immune response this single-cell pathogen elicits. The immune responses we wanted to trigger / amplify were typically against human tumor proteins or the products of human viruses (e.g. HIV, HPV), however the organism we were using as a vaccine was a bacteria.

As I said above, I usually teach the Central Dogma in a way that omits many of the complications seen in the real world. So, when we look at a codon chart, we see the redundancy (multiple DNA codons make the same amino acid) to illustrate how a change in the DNA sequence can often fail to change the protein sequence at all. These are called ‘silent mutations’.

 Image

The way these codon charts work is by triangulating a position in the middle of the chart using the bases depicted along three of the four edges. For example, the codon AUG is read by locating the ‘A’ on the left margin, the ‘U’ on the top margin, and the ‘G’ on the right margin. The location this identifies is an amino acid called Methionine (abbreviated as met) on this chart.

Notice that if the first two bases in a codon are CU, then it does not matter what the third base is, no matter what, this codon will call for a Leucine (leu).. This means is the sequence of RNA is CUU originally, but mutates to CUC, there will be no change in the protein.

What codon optimization addresses is the fact that different organisms tend to prefer some codons over others, even if they encode the same amino acid. This has been appreciated for many years now so when a molecular biologist takes a protein (e.g. from a human tumor) that they want made by bacteria and they redesign the DNA sequence in a way that codon preferences are maximized in the organism that will express the protein.

This figure examines the percentage of times a gene uses a particular codon to make Leucine. In the bacteria, E. coli, CTG is used nearly 50% of the time. Meanwhile, in the yeast, S. cerevisea, TTA and TTG are preferred.

 (Note that T in DNA = U in RNA)

 Image

 

————

So, what does this mean? Consider a simplified example…

I want to clone this protein from a yeast and grow it up in bacteria:

Met – Leu – Leu   [stop]

ATG- TTA – TTG – TAG

 We would take this DNA from the yeast and then modify the sequence by changing the two Leucine codons into the preferred sequence in bacteria (CTG):

Met – Leu – Leu   [stop]

ATG- CTG – CTG – TAG

The result should be a sequence of DNA that the bacteria will be able to optimally translate into protein. 

———

This has worked out to be much longer and more technical than I intended – and I haven’t even addressed the new ideas brought up in the Science article.

Therefore, I’m going to stop here and continue tomorrow with part II

 
Leave a comment

Posted by on February 9, 2014 in Uncategorized

 

Tags: , , , , , , , ,

Stack Overflow hates me

ImageI tend to ask a lot of questions that stack overflow considers useless. I understand the format of the site – it’s a place where people can ask questions that can be answered accurately and with references. An easy way to get your question flagged is to ask for a recommendation for something – a question that can only be answered by opinion and therefore does not have a discrete, ‘provable’ answer.

However, I still want my questions answered. I really do need help and I’m not sure where else to turn to get it (to reach such a well experienced audience).

What I am dealing with is:

ImageI have a small C++ program that I have developed in Xcode. Things are pretty close to working, but I would like to take my program and wrap it in a more attractive user  interface. Somehow, I thought I was just needing to learn some more C++. I thought that was all in ‘book 2’ or something. But I am getting the impression that I need another program and I have no idea where to start.

(The layers of programming are amazingly deep)

So, please write if anyone out there knows of

#1 a good program to do this with -or- a way to approach it by linking my C++ programs in XCode to an objective-C interface (blahblah, these are words I can repeat, but I don’t understand how to do it)  

#2 know a website / book / youtube channel that embodies a walkthrough approach to doing this

 
Leave a comment

Posted by on August 2, 2013 in Uncategorized

 

Tags: , , , , , , , , ,

Codecademy – Recursion explanation

Image

Russian Nesting Dolls

This post is primarily for those readers who are working through the Codecademy.com course on javascript. I was having trouble with mastering the recursion problem for solving factorials there and noticed that many others were in the same boat.

This code was really blowing my mind. I was having the worst time understanding it. I was OK with the idea of recursion, but I don’t think I was really understanding it.

I was following the code and could see it is working, but didn’t see why it actually returned the correct value. Additionally, I had a conceptual block – i.e. how does the code store the value of each recursion without a variable?

Here’s the problem:

Write a recursing code that solves for the factorial of any given value.

Recall that factorials are the product of all numbers from 1 to n, where n is the value you are solving for. For example, the factorial of 3 : In mathematical terms this is written, 3!, so

3! = 1*2*3 = 6

4! = 1*2*3*4 = 12

The problem suggests that you set a ‘base case’ as returning 1 if n === 0, and that you use a terminator to prevent crash if negative numbers are entered (because they will otherwise never get to the terminator)

Here’s my code:

function factorial(n) {

if (n<0){

console.log(“We can only compute factorials from positive integers”);

return;     // the catch-all in case a negative number is entered

}

if (n ==0){

return 1;    // the base case

}

else{

return n* factorial (n-1);    // the nested function call

}

}

factorial(4);    // function call to test program

If we start at 4 (as an example), then we go through the code and get to the nested function call that says

return n * factorial(n-1)

if we sub in the actual values for n, it would read:

return (4) * factorial(3)

But factorial(3) is not a number – it is a function call, so before (4) is multiplied by anything, it sends a new value to factorial. This keeps happening until we get to n=0. At that point we’re at the base case and no further recursion will happen – the code simply returns 1.

So, we have to start moving our way back out of the loop. We set n=1 here, so the innermost recursion actually looks like this:

return 1* factorial(0)

because factorial(0) returns 1, we are actually doing this:

return 1*1     (*   = 1    *)

then we back out to the next step:

return 2* 1     (*   = 2   *)

then we get to…

return 3*2…   (*    = 6     *)

return 4*6      (*    = 24     *)

Or, if you can see this more clearly, this is how the computer sees the code:

return 4 * (return 3 * (return 2 * (return 1 * (1))));

work backwards doing the math from the inside out:

1*1 = 1

2*1 = 2

3*2 = 6

4*6 = 24

Q.E.D.

 

postscript: I just received a reply to my post on codecademy.com from a moderator, Alex. He directed me towards an article he had written explaining the same topic using a very elegant flow diagram. You can find that article here.  – I had to write this as a postscript, because his article is so clear that if you read it first, you would have no need to read mine.

 
Leave a comment

Posted by on September 21, 2012 in Uncategorized

 

Tags: , , , , , , , ,

How to program ‘ZombieCatchAlice’

OK, I’ve thrown together a quick program with a Zombie chasing Alice through the streets of a little city. He says ‘Brains!’, she yells ‘Oh, Help!’, runs a couple of paces, turns, yells for help again and runs a few paces. All the while, the zombie is following her around the screen and the camera follows the action. 

What I don’t know how to do is program an event that is triggered by the zombie ‘catching’ alice. I’d like to see the zombie get her, turn her into a zombie and the two can go after other characters on the screen.

 

Help is greatly appreciated.

 

 
Leave a comment

Posted by on September 5, 2012 in Uncategorized

 

Tags: , , , , , ,