Lab 1: Forward simulation
Plan for first lab
- Additional information on CTMCs
- How to get started writing the code in R:
- How to create a
runcommand - How to read command line argument
- How to create a
- 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.
Write your code in some file (for example,
q1.r). Write the following lines inq1.rfor 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 hereCreate a file and name it as
runwithout any file extension. Type the below line in therunfile:Rscript q1.r $1 $2To test that your program, you can execute the file
runfrom 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.txtIf you are using Java, the content of the
runfile 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 $2I 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.
First, check where the
Rscriptprogram is located by typing the following at the command line prompt:$ which Rscript /usr/bin/RscriptCreate a file and name it as
runwithout any file extension. Place the below lines of code in therunfile:#!/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: