Download CSC598BIL675-2016

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Shell scripts on Pegasus 2
• Log into pegasus2 using ssh <username>@pegasus2.ccs.miami.edu
• To start a job you need a shell script
which shell?
job name
#!/bin/bash
file for stderr
#BSUB -J HIV
file for stdout
#BSUB -e %HIV.err
#BSUB -o %HIV.out
number of cores
#BSUB -n 1
queue
#BSUB -q general
#BSUB -W 72:00
time allocation
#
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
your script
Shell scripts on Pegasus 2
• submit a job with bsub < script.sh
• bjobs
returns the status of current jobs
• transfer data through
• scp <user>@pegasus2-gw.ccs.miami.edu:~/. into your home directory
• scp <user>@pegasus2-gw.ccs.miami.edu:/scratch/<user>
into scratch directory
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!”
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."
Variables & Types
• Numbers - Python supports two types of numbers - integers and floating
point numbers.
myint = 7
myfloat = 7.0
myfloat = float(7)
coercing an int into a float
• Strings - Strings are defined either with a single quote or a double quotes.
mystring = 'hello’
mystring = “hello”
mystring = "Don't worry about apostrophes"
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
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
#!/usr/bin/python
one = 1
two = 2
hello = "hello"
#would this work?
print one + two + hello
assigning 1 to a and 2 to b
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
Lists
• What would happen here?
#!/usr/bin/python
mylist = [1,2,3]
print(mylist[10])
• catching errors
#!/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
Basic operators
• Just as any other programming languages, the addition, subtraction,
multiplication, and division operators can be used with numbers.
#!/usr/bin/python
number = 1 + 2 * 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
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 = 1 + 2 * 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