Lab 1: Forward simulation

07 Jan 2014

Plan for first lab

  • Additional information on CTMCs
  • How to get started writing the code in R:
    • How to create a run command
    • How to read command line argument
  • Quick survey to determine what will be covered in next labs
  • Logistics: checking everybody can log in the machines

Notes from Seong: How to create run file for submission

There are two ways to do this, you can choose whichever approach you prefer. I will assume that you are programming in R.

  1. Write your code in some file (for example, q1.r). Write the following lines in q1.r for reading in the command line arguments:

    # below code loads the command line arguments to character vector ``args``
    args<-commandArgs(TRUE)
    dnaFilePath<-args[1]
    matrixFilePath<-args[2]
    
    # write your code here
    

    Create a file and name it as run without any file extension. Type the below line in the run file:

    Rscript q1.r $1 $2
    

    To test that your program, you can execute the file run from the command line prompt:

    $ chmod 700 run # this command gives the owner of the file execution permission (as well as read and write)
    $ ./run dnafile.txt matrixFile.txt
    

    If you are using Java, the content of the run file would look different. Assuming that your code is written in a file named Question1.java and that you have compiled it to produce Question1.class file, it would look something like this:

    java -cp . Question1 $1 $2
    

    I assumed that you are running the code from the directory that contains .class file. If not, replace the . (dot) above by the path that contains the .class file that you wish to execute.

  2. First, check where the Rscript program is located by typing the following at the command line prompt:

    $ which Rscript
    /usr/bin/Rscript
    

    Create a file and name it as run without any file extension. Place the below lines of code in the run file:

    #!/usr/bin/Rscript
    
    args<-commandArgs(TRUE)
    dnaFilePath<-args[1]
    matrixFilePath<-args[2]
    
    # rest of your code goes here
    

Lab activities to do by the next lab

  • Setting up a java environment:
  1. Download Eclipse
  2. Install Java on your machine if it is not installed already