Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial 2.11

Similar presentations


Presentation on theme: "Tutorial 2.11"— Presentation transcript:

1 Tutorial 2.11 http://creativecommons.org/licenses/by-sa/2.0/

2 Tutorial 2.12 Unix Tutorial 2.1a Mike Wilson

3 Tutorial 2.13 Unix tutorial 2.1a 1.Review of some essential UNIX commands 1.Hands on demo of cat, grep and du 2.Getting into your shell 3.A few more commands 4.Using sim4 to align cDNA to genomic sequence 5.Time to play!!!! Time to play: open up your laptops

4 Tutorial 2.14 A review of the essential cd – change directory ls – list cp – copy a file mv – move or rename a file rm – remove a file (use caution) mkdir – make a directory rmdir – remove a directory (must be empty) pwd – print working directory

5 Tutorial 2.15 Redirecting and reading files cat can be used to display file contents cat is also used to concatenate files 1) Move to unixtutorial directory 2) Type: cat bka.txt unix.txt > both.txt –Copies contents of bka.txt and unix.txt into one file called both.txt –Note that if you already had a file called both.txt it would be overwritten! –Type less both.txt to read the file 3) Type: cat unix2.txt >> both.txt –Appends unix2.txt to both.txt

6 Tutorial 2.16 Grep grep = global regular expression print grep is powerful for searching file names and contents grep [options] regexpression [files] –grep –e [vfy][fyw].*[gstne][gstqcr][fyw].*p filename searches for this pattern in filename -e option indicates expression pattern; [ ] one of any of the character.* zero, one or more of any character Goal: use grep to look for fun in one of your files 1) Go to unixtutorial directory if you aren’t there already 2) Type: grep fun both.txt Looks for “fun” in the file “both.txt” Did you find fun? Are you having fun?

7 Tutorial 2.17 du [options] directory –du by itself prints current directory and all sub- directory names and sizes –du –a prints information for all files as well Du you want to find a file? –du –a | grep filename –you can of course search for partial filenames with your wild cards/arguments etc. –go to home and look for unix.txt Print disk usage: du

8 Tutorial 2.18 Shell files and aliases A buffer between you and the operating system Bourne-again shell (BASH) is the standard Linux shell (from GNU) The shell is interactive, it allows you to customize your Linux session as well as program

9 Tutorial 2.19 Common Shell symbols >redirect output >> append output <redirect input | pipe output &run process in background *match any characters in filename ? match single character in filename [ ] match any characters enclosed \ quote following character

10 Tutorial 2.110 Customizing your shell Special BASH files you will find in your home directory.bash_profileexecuted at login.bashrcexecuted at shell startup.bash_logoutexecuted at logout.bash_historycontains your previous commands Type: ls –al to see all your files Customizing your shell usually will involve editing the.bashrc file

11 Tutorial 2.111 Aliases: making HOME feel like home aliases can make your life easier typing alias will reveal ‘default aliases’ you can add temporary aliases alias lf=‘ls –F | less’ unalias will remove this: unalias lf you can add permanent aliases to your.bashrc file

12 Tutorial 2.112 I don’t know much about history Scroll through your history with  Look at your history file by typing history history lists your previous commands next to a number. you can rerun any given number by typing !n !55 would re-execute command 55 in my history It’s worth learning more about history

13 Tutorial 2.113 Environment variables Environment variables are settings that control specific aspects of the system –each program has its own variables –the shell (a program we spend a lot of time with) has variables too –you can look at all your shell environment variables by typing set Some common environment variables for the shell HOME –points to the home directory PATH –places that the shell will look for your commands PS1 –determines what is displayed at the command prompt

14 Tutorial 2.114 Customizing environment variables variables can be used in commands and filenames by preceding them with a $ sign –i.e. $HOME/unixtutorial/unix.txt you can use $PATH in a command to add a new directory to your PATH –export PATH=$PATH:$HOME/unixtutorial –this appends the new PATH to the existing one –to view your PATH: echo $PATH $PATH refers to current path : separates current PATH from new one export makes shell variable PATH global new PATH to be added

15 Tutorial 2.115 Editing.bashrc with emacs –make your changes to the PATH memorable by editing.bashrc open.bashrc in a text editor (emacs or gedit or vi) add PATH=$PATH:$HOME/unixtutorial

16 Tutorial 2.116 Installing programs in Linux/Unix Unix and Linux comes with many applications preinstalled You will likely want to install more This can sometimes prove to be difficult for a few reasons some of which inlcude: –what flavour of unix/linux you are running –what privledges you have as a user (i.e. root) –the nature and quality of the program you want to install Much softwares builds upon previous work, programs, libraries etc. Sometimes you need to find and install these yourself. Depending on the nature of the program and implementation this can become a really annoying scavenger hunt. The art of installation can take patience and practice

17 Tutorial 2.117 Implementation energy –situation A some energy needed to install and learn new program energy is regained from the time saved obtaining results –situation B energy spent installing and learning program is more than time/energy saved –Experience takes energy and time (so everything may look like a B when you start) – Even experience may not make up for time wasted implementing a poorly written or compiled program

18 Tutorial 2.118 Making and breaking tar files File is now filename.tar –Tar is short for tape archive –It is mostly used to bundle files and directories To untar a tar file –Type: tar -xvf filename.tar directoryname –When extracting make sure the directory you choose is where you want the files (could be messy) Create a tar file of everything inside of a directory –Type: tar -cvf filename.tar directoryname cCreates (a new tar file) xExtracts (a tar file) fFiles vVerbose (lets you see files created) zUse (tar -xzvf) to uncompress and untar in one step

19 Tutorial 2.119 Un/compressing files Most UNIX software you download will be compressed and bundled. These files often look like: filename.tar.gz –To uncompress type: gunzip filename.tar.gz –File is now filename.tar To compress a file type: gzip filename –You then get a smaller file named: filename.gz

20 Tutorial 2.120 A process is a program in action –To suspend a process type: control z –Situation:You are working on a buffer in emacs and want to get back to the command prompt without closing emacs – type: control z emacs is suspended and you are back at the command prompt You can type ps to see what processes are running –Now type: fg You are back in emacs working on your buffer –If you type bg it will run the process in the background (as opposed to suspending it) –somtimes you may want to run a process in the background from the start. Use & mozilla &

21 Tutorial 2.121 A process is a program in action –To check out the action type: ps –To put a stop to the action type: kill processnumber You can also can use the command top to manage processes and check memory usage etc. (more powerful than ps) In top –Type u and then enter your username to see processes you are running –Type k and enter process ID to kill a program –Type q to leave top

22 Tutorial 2.122 Sim4- A Computer Program for Aligning a cDNA Sequence with a Genomic DNA Sequence. (Florea et al 1998) Align cDNA, EST data with genomic sequences Uses BLAST based technique finds “exon cores” of a given word size. Takes into account conventional splicing logic and possibility of sequencing errors. Sim4 is a useful, efficient and commonly used bioinformatic program It’s also well documented and easy to install. Try it at home or work! Usage: –sim4 seqfile1 seqfile2db {[WXKCRDAPNB]=value} –sim4 my_genomic my_cDNA_list K=15 C=11 A=3 W=10 For the rest of the lab you will use sim4 to do some bioinformatic work and get to know your shell

23 Tutorial 2.123 Sim4 You can see the parameters of sim4 by typing: sim4 We will use default parameters but you will have to look at the instructions (its important to do this for all bioinformatic programs). A basic sim4 run will look like: sim4 genomic_sequence list_of_cdnas A=3 > outfile

24 Tutorial 2.124 A little aside about the Linux mascot Tux Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had. -- Linus Torvalds

25 Tutorial 2.125 Unix Tutorial- when you have had enough

26 Tutorial 2.126 A few more Resources http://www.gnu.org/software/bash/ manual/bash.html –The official BASH manual from GNU http://linux.org.mt/article/terminal –excellent tour of the BASH shell! http://www.tldp.org/ –the linux documentation project. Great resource http://globin.cse.psu.edu/globin/ht ml/docs/sim4.html –info about and download sim4

27 Tutorial 2.127 The last resources- have fun!


Download ppt "Tutorial 2.11"

Similar presentations


Ads by Google