The problem was:
$seq = ‘GAGTATCTGGAAGACAGGCAGACTTTTCGCCACAGCGTGGTGGTACCTTATGAGCCACCCGAGGCCGGCT’;
use a loop and substr to print its “codons”, one per line.
The problem was:
$seq = ‘GAGTATCTGGAAGACAGGCAGACTTTTCGCCACAGCGTGGTGGTACCTTATGAGCCACCCGAGGCCGGCT’;
use a loop and substr to print its “codons”, one per line.
Some of you had some problems with the exercise on Perl hashes, this is a short review about them. Continue reading
This post will review how to pass arguments to a Perl script. This is something you can’t test online with codepad (unfortunately), because codepad only runs the script, without emulating a whole system with a shell and files to read…
Learning how to play with the Linux shell we understood that each program (or command) can be launched alone, or with parameters. We refer to these parameters as “arguments”.
An example below:
ls ls -l ls /usr/bin
The three commands always start with the program to run, but the first only ask the shell to execute the ls program, while the second and the third one also pass some “arguments” to it.
This is a core functionality of any Perl program: its the way we, the user, can ask the Perl program what to do.
If we save a Perl script as demo.pl, we know that to launch it we should type (provided that the script is in our current directory):
perl demo.pl
provided that this is the way we launch the command we now want to pass parameters the same way we did with ls, like:
perl demo.pl -l -n ciao
In the line above I gave three parameters to the script. As we cant figure out how many parameter a program needs, Perl stores all the passed arguments into an array, called @ARGV (remember that Perl is case sensitive!!!).
We are going to create a param1.pl (lab04 folder, of course) program that prints the first parameter you passed to it. It’s very simple:
print "The first parameter is $ARGV[0].\n";
Now create a script that will print all the parameters passed, not just the first. Save it as params.pl in the lab04 folder.
We want to print one parameter per line, like “The parameter is …“, and at the end it will print “You passed # total parameters“.
Submit it as usual, using hw4.1 as code.
This post explains how to read a file from Perl. This is an optional part of laboratory04, so don’t try this unless you really feel confident about all the rest.
Here is the solution to the fourth homework, hw4. Continue reading
This post shows the solution for the homework coded hw2.
Continue reading
Today we are going to learn about a new function with the friendly name of “substr”! Its purpose is to extract a piece of a string, also known as substring. This is homework hw6.
This time we are going to put together things we already know to do something a bit more complicated. We are going to write a program that translates a DNA sequence to RNA and then to the protein it encodes. This is a real example of what you can do, not bad uh?
This is also the hardest homework of this gap, and to be honest after this one you will have just one final “review” homework.
Remember hashes? They are like arrays, a collection of boxes. The main difference is that each box has a name instead of a number. Today’s homework is about hashes!
Continue reading