Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shell scripts on Pegasus 2

Similar presentations


Presentation on theme: "Shell scripts on Pegasus 2"— Presentation transcript:

1 Shell scripts on Pegasus 2
Log into pegasus2 using ssh To start a job you need a shell script which shell? job name #!/bin/bash #BSUB -J HIV #BSUB -e %HIV.err #BSUB -o %HIV.out #BSUB -n 1 #BSUB -q general #BSUB -W 72:00 # cd ${HOME}/Viruses/HIV/ (../Python/distanceClustering2.py ../human_mint_biogrid_hprd_hint.ppi HIV_targets_HPIDB.txt ../human_essential_genes.txt > HIV_ess) >& HIV_ess.log file for stderr file for stdout number of cores queue time allocation your script

2 Shell scripts on Pegasus 2
submit a job with bsub < script.sh bjobs transfer data through scp into your home directory scp into scratch directory returns the status of current jobs

3 Python Python is a very simple language, and has a very straightforward syntax. It encourages programmers to program without boilerplate (prepared) code. There are two major Python versions, Python 2 and Python 3. Python 2 and 3 are quite different. Python 2 is more widely used and supported. However, Python 3 is more semantically correct, and supports newer features. For example, one difference between Python 2 and 3 is the print statement. In Python 2, the "print" statement is not a function, and therefore it is invoked without parentheses. However, in Python 3, it is a function, and must be invoked with parentheses. Our first Python program: #!/usr/bin/python print “Hello world!”

4 Intendation Python uses indentation for blocks, instead of curly braces. Both tabs and spaces are supported, but the standard indentation requires standard Python code to use four spaces. For example: #!/usr/bin/python x = 1 if x == 1: # indented four spaces print "x is 1."

5 Variables & Types Numbers - Python supports two types of numbers - integers and floating point numbers. myint = 7 myfloat = 7.0 myfloat = float(7) Strings - Strings are defined either with a single quote or a double quotes. mystring = 'hello’ mystring = “hello” mystring = "Don't worry about apostrophes" coercing an int into a float

6 Variables & Types Simple operators can be executed on numbers and strings: #!/usr/bin/python one = 1 two = 2 three = one + two print three hello = "hello" world = "world" helloworld = hello + " " + world print helloworld sum = str(one) + " " + (two) print sum coercing an int into a string

7 Variables & Types Assignments can be done on more than one variable "simultaneously" on the same line like this: #!/usr/bin/python a,b = 1,2 print a, b one = 1 two = 2 hello = "hello" #would this work? print one + two + hello assigning 1 to a and 2 to b

8 Lists Lists are very similar to arrays. They can contain any type of variable, and they can contain as many variables as you wish. Lists can also be iterated over in a very simple manner. #!/usr/bin/python mylist = [] mylist.append(1) mylist.append(2) mylist.append(3) print(mylist[0]) # prints 1 print(mylist[1]) # prints 2 print(mylist[2]) # prints 3 # prints out 1,2,3 for x in mylist: print x

9 Lists What would happen here? catching errors #!/usr/bin/python
mylist = [1,2,3] print(mylist[10]) #!/usr/bin/python mylist = [1,2,3] try: print(mylist[10]) except IndexError: pass expect an error to occur catch the error what to do if the error occurred

10 Basic operators Just as any other programming languages, the addition, subtraction, multiplication, and division operators can be used with numbers. #!/usr/bin/python number = * 3 / 4.0 print number remainder = 11 % 3 print remainder squared = 7 ** 2 cubed = 2 ** 3 print squared, cubed does python follow order of operations? modulo operation equivalent to 7*7 equivalent to 2*2*2

11 Basic operators - numbers
Just as any other programming languages, the addition, subtraction, multiplication, and division operators can be used with numbers. #!/usr/bin/python number = * 3 / 4.0 print number remainder = 11 % 3 print remainder squared = 7 ** 2 cubed = 2 ** 3 print squared, cubed does python follow order of operations? modulo operation equivalent to 7*7 equivalent to 2*2*2


Download ppt "Shell scripts on Pegasus 2"

Similar presentations


Ads by Google