First computer lab

Welcome to the Computer Lab #1

From text editor to program execution

Today we start playing with our computer: we want to

  1. start using the shell terminal
  2. start using a programming editor
  3. preparing and executing simple Perl scripts
  4. Make Primer3 design a couple of primers

1. Shell terminal

UNIX shells are a text-only tools to administrate a computer and to do a lot more. Please have a look at this online manual: it’s a very good tutorial. Let’s see some basic commands (you already used them during your 1st year course with Prof. Stoianov). Also don’t forget the power of the Tab key.

pwd, print working directory, prints the current directory to the screen. It’s so important to know where you are that you should keep this command in mind. Consider that:

  • you have a personal directory – called the home directory – that is something like /home/yourname/, and it’s abbreviated with ~.
  • A dot “.” is a shortcut for the current directory.
  • A double dot “..” is a shortcut for the upper directory (the one that contain the current)

cd, change directory. With this command you can navigate the filesystem. If you are in your home directory and you type “cd Documenti” you are asking to enter the Documenti directory located within the current directory. If you now type “pwd” you should see that you changed directory. And if you type “cd ..” you should return to the upper level. As the ~ is a shortcut for the home folder typing “cd ~” will transport you in your home.

ls, list. This command lists the content of your current directory or the specified directory. If you type “ls ~/Documenti” you are asking to print the files within the Documenti directory in your home. If you type “ls -l” you have a list with more details.

mkdir directoryname
creates a new directory.

cat filename
display the content of a (text) file.

head filename
prints the first 10 lines of a file. If you type “head -n 24 filename” prints the first 24 lines. There is a similar tail command that prints the last lines.

–> Create a ‘lab1‘ directory in your home. You have to save all the files of today’s lesson in that directory!

When you can “cd”, “ls”, and “cat” with some confidence… try the advanced features!

2. Programming editor

You’ll find a good text editor under “Application –> Accessories –> Text Editor”. Write the hello world program and save it as “hello.pl” in the lab1 directory.

Now open the terminal. It opens by default in your home directory, check that you are in your home with the pwd command. Now test your Perl script with:

perl lab1/hello.pl

3. Very simple Perl scripts

  • Create a new script and call it scalars.pl in the lab1 directory. Given the following piece of code:
$first = 10;
$second = 7.02;
now store the result of the division of the two variables into $divide and print just this number followed by a ‘new line’ character.
  • Now save the previous script as a new one calling it scalars2.pl. Have $divide to keep only the integer part of the division. Save it and test it.
  • Create a new script and call it array.pl (same directory). Below you find the script, you just have to substitute the ‘???’ with the appropriate code.
@people = ('Ann', 'Belle', 'Charlie', 'Dora', 'Evinrude');
$greeting = 'Hello ';
$peoplenumber = ???;
print "There are $peoplenumber people in my \@array.\n";
foreach $person (@people) {
     $counter++; 
     print "$greeting $person. You are number $counter.\n";
}
  • A much more complex task. Create a text file and save it as seq1.fasta, in the lab1 directory. Write innto it a single DNA sequence that you’ll download from the NCBI (about 1000bp).
    Now create a script (cat.pl) that takes as input a filename, opens the file and print it line by line. Test it using ‘seq1.fasta’.
  • Now create a script (wc.pl) that instead of printing the file itself – line by line with the $_ variable, count how many lines are there in the file and print the total. Can you also make the script printing the average line length?

4. Primer design with Primer3

We are going to use quite soon a program called Primer3 for primer design. For this first practical you are going to test a simple web interface to use the program (while we have to run it from command line, shell, in the future).
Now, given your fasta sequence (seq1.fasta), try designing primers using Primer3. You can select your desired melting temperature (see ‘General settings’) and also you can add symbols to specify which regions have to be included or not. Try it and become a master!

Tagged

Leave a Reply

Your email address will not be published.