Friday, June 29, 2012

Arduino and Open Hardware

I heard about Arduino before, however I never took the time to look into it. In case you don't know, Arduino is an open source electronic board that allows you to easily interact with it and create... just about anything!
If it wasn't clear up until now, I am a great enthusiast of open source software and hardware, and Arduino seems to be both. It has a very community of contributes and many people customize it for their own needs.

What I like most about it that you can find free sketches for things you might want to do. Things like a server, barometer, and even a well designed mirror that plays music from your iPod. All available freely.


More than that, with organizations like Open Hardware and the dropping prices of 3D printers we are looking into a new age of making. One that even allows you to build your own village! (bulldozers and everything)


If you are interested in that sort of stuff check out he video below, it is a TED about Arduino and shows off some neat stuff people do.








BTW, I know of there is concern that things like Arduino are "dumbing" down electronics. People use it and don't understand all the implications of what they are doing. In software we had the same debate regarding .Net, which makes programming so simple we sometimes feel like .Net developers are cheating and are not real developers. And I am also reminded of the debate that Ubuntu is not real Linux because it is so simple.
I am against such approaches. While I myself like to understand exactly what and why everything occurs (i.e. low-level programming), I know most people don't, and these things (Arduino, Ubuntu, not so sure about .Net) are good things. Things may be simpler, but more people use them and that is the important thing.

Tuesday, June 26, 2012

Coding as a second language (or why everyone should learn to program)

Lately I've encountered quite a few posts about teaching coding to EVERYONE. Some were pro the subject and some against it, some also changed their minds or decided to clarify their intentions.

I must admit that I belong to that last group. I read Jeff' Atwood's excellent post Please Don't Learn To Code and I couldn't agree more. Jeff went out against the whole "everyone should be a programmer" trend that seems to be sweeping the internet and his ideas seem to agree with my own. Coding should be left to professionals, people should do their own jobs and you don't want your mayor turning into a script-monkey and start hacking Perl. He should do what he does best, which is run your city (or at least I hope that is what he does best). Jeff's post apparently brought a lot of anger and he later published a clarification post that he didn't mean people who want to learn coding shouldn't, but at the time I tended to agree with his original post more, most people shouldn't code.

I believed, and still believe, that coding should be left to those of us who like to code. In my CS studies I've met too many people who had nothing to do with computer and they only came to do the degree for the high salaries the field offers. They plunge themselves into a field which they know nothing about, and this is something they are supposedly going to be doing for a very long time, it is no wonder to me that these people usually make poor programmers and often turn out to be disgruntled employees.
I believe that a programmer should be someone who lives the code and enjoys doing it. There are exceptions of course, but for the most part I do think that people who enjoy what they are doing (and there for will also invest their own free time to explore, improve and develop that skill) will make far superior employees to those who don't.

But I am getting off-topic here, what I really wanted to talk about is if everyone should learn how to code, and I do. This may sound like a contradiction to what I've written above but it's not. Computers have become such an integral part of our lives that I think everyone should know how write their own programs just like everyone should know how to write. However, that does mean that everyone should be a programmer, just like not everyone are writers.

So what made me change my mind you might ask. Two things. The first (which actually happened after the second item) is reading 'The Matrix is a system, Neo': Ten reasons coding literacy should be a human right by Daniela Capistrano. This article certainly lit some bolbs in my head, and only strengthened the thoughts I was having because of the second item (which happened a few days earlier), this second thing is an incident that happened to me with my project partner. In our project we need to process hundreds of very large text files. On this specific milestone my partner was required to run the program he wrote in order to process about 90 text files in a folder. My partner sent me the results by email and when we met I asked my partner to change something in the output. A very small and simple change.
After a few minutes I noticed my partner keeps editing and restarting the application. I asked my partner what is going on and was amazed to learn that the application had a single variable for the name of the file being processed, and my partner changed that variable for each file and restarted the application. My partner had done so last time for the 90 files, and now my partner was going to repeat the process again for all the files.

When I asked why didn't she just read all the files in the folder into a list and make a loop to go over them my partner said the idea never crossed her mind.

My partner is a senior student in CS with decent grades and she passed all programming courses.Yet my partner is so foreign to how computers work that the thought of the computer doing all the work for her never crossed her mind. I wish I could say that this is an isolated case, one in a million, but it isn't. As CS becomes more main stream, more and more people who don't understand computers graduate. And this is what needs to be changed (the understanding of computer ways, not the graduation. Maybe that too).

Children need to be thought about coding and how computers work in school. They should learn to write small scripts that can ease their lives and make them understand the true powers of computers (and no, it is not Facebook).

Imagine how empowered all industries will be if everyday workers would understand computers. If the secretary in the office knew how to make the computer create personalized documents for her, instead of opening the document for each employee and changing the name. Or if the archeologist would be able to search all databases one just one click, instead of going into several sites and searching one by one. Or just imagine how many catastrophies would have been saved if someone in every home and office knew how to automatically copy files and would build a backup utility for his network.

I don't think everyone should work in programming, and programs can quickly become so complex that writing them is better left off for professional programmers. However when the masses have the knowledge and power the possibilities and ideas are endless. Just try and think of all the things we haven't yet thought about.

Update: I think I found a very good example of how helpful it would be if everyone would know how to code, just think of all the sleepless nights it can save or the money you'd spent on an expansive cradle.
http://www.youtube.com/watch?v=uweJGm7l1Nc

Tuesday, June 19, 2012

Finding Genetic Open Reading Frames (ORF) In FASTA

A recent project I've worked on required that I find Open Reading Frames (ORF) of certain minimal length in genetic material which arrived as FASTA files (.fa).

My natural choice for this string match was of course regular expressions, and the language I use in the project is Perl.

After a few attempts I finally settled on the following code:

my $FIND_ORF_REGEXREADY = "(ATG(?:[ATGCN]{3}){13,}(?:TAG|TAA|TGA))";
if($FASTA =~ m/$FIND_ORF_REGEXREADY/)
                { //handle $1 }
elsif (reverse($CDSString) =~ m/$FIND_ORF_REGEXREADY/i) #check reverse
                { //handle $1 }

I'll break down the code:
I use the match option (m/) to extract the found match into a variable.
The string I'm searching must begin with ATG, and be followed by 3 letters before ending with one of the Stop codons (TAG, TAA,TGA).
Since the code should only be composed of A,T,G,C or N (N can be any of the bases) I placed it in an OR statement (the brackets), and since this should be repeated 3 times it needs to be placed inside a (). In case you are wondering, when you want to do an OR you usually use (), but if that OR is inside another () than you need to use [].
I've also added the {13,} to enforce a certain minimal length to the ORF, in my case the length was 45 (3 + 3*13 + 3). The curly brackets tell us that it should be repeated a minimal number of times and the , tells it to have no maximal length. If I wanted a maximal value I would add a number after the , (like {13, 20}.
I also added the (?:...) in order to have a non-capturing group. More on what that means here.
Finally I closed with an /i to make sure the avoid upper-case/lower-case issues (although there shouldn't have been).

The if was pretty simple, I search it in one direction. If I found good, if not I reverse the string and search the other direction.

More on regular expressions can be found at this excellent cheat sheet and Perl Documentation