Unix for Bioinformaticians A survival guide Paolo Marcatili - Programmazione 08-09
Agenda Unix Folders Files Processes Redirection Paolo Marcatili - Programmazione 08-09
Unix He can smell your fear Paolo Marcatili - Programmazione 08-09
What is Unix ? Unix Paolo Marcatili - Programmazione 08-09
What is Unix ? Unix Paolo Marcatili - Programmazione 08-09
What is Unix ? Unix Paolo Marcatili - Programmazione 08-09
What is Unix ? Unix Paolo Marcatili - Programmazione 08-09
What is Unix ? Operating system stable, multi-user, multi-tasking for servers, desktops and laptops. Unix Paolo Marcatili - Programmazione 08-09
Types of Unix Solaris OS-X Linux! Unix Paolo Marcatili - Programmazione 08-09
Unix Operating System Unix Paolo Marcatili - Programmazione 08-09
What’s in Unix? Files Processes Unix Paolo Marcatili - Programmazione 08-09
Unix Filesystem Unix Paolo Marcatili - Programmazione 08-09
Terminal It makes the difference! Powerful Transparent User-unfriendly Unix Paolo Marcatili - Programmazione 08-09
Our Task Today Yes, I can! Paolo Marcatili - Programmazione 08-09
Human Immunoglobulins Task Paolo Marcatili - Programmazione 08-09
Human Immunoglobulins Task Paolo Marcatili - Programmazione 08-09
The data We have 3 files Fasta Sequences of Heavy (heavy.fasta) Lambda (lambda.fasta) Kappa (kappa.fasta) Task Paolo Marcatili - Programmazione 08-09
The Task Look data Correct errors Do some analysis Make a single fasta file Task Paolo Marcatili - Programmazione 08-09
Folders: read and write Paolo Marcatili - Programmazione 08-09
Change Directory To know where you are >pwd /home/bioinfoSMFN Let’s move! >cd /home/bioinfoSMFN/Desktop/task Or >cd Desktop/ Folders Paolo Marcatili - Programmazione 08-09
Folder content Let’s check what’s in the folder: >ls Better >ls -la Cheat: parameters are useful! >ls -lart Folders Paolo Marcatili - Programmazione 08-09
Wildcards Extremely useful! >ls -la *heavy* >ls -la heavy.?asta *= 0,1,2,…. occurences of whatever ?= exactly 1 occurence of whatever Folders Paolo Marcatili - Programmazione 08-09
Commands To know more about a command: >man ls >whatis ls >apropos ls Or Google! Folders Paolo Marcatili - Programmazione 08-09
Unix Permissions Folders Paolo Marcatili - Programmazione 08-09
Folders - summary Command Meaning ls list files and directories ls -a list all files and directories mkdir make a directory cd directory change to named directory cd change to home-directory cd ~ change to home-directory cd .. change to parent directory pwd path of the current directory Folders Paolo Marcatili - Programmazione 08-09
Files: read and write Paolo Marcatili - Programmazione 08-09
Backup original data Create a directory >mkdir backup Copy all the files in the directory >cp heavy.fasta backup/ >cp heavy.fasta heavy_copy.fasta >mv heavy_copy.fasta backup/heavy_backup.fasta Files Paolo Marcatili - Programmazione 08-09
Read a file Let’s see… >cat heavy.fasta Files Paolo Marcatili - Programmazione 08-09
Read a file Let’s see… >cat heavy.fasta Mmh… >less heavy.fasta Hint: q to quit… but if you are stuck try ctrl+c Files Paolo Marcatili - Programmazione 08-09
Look for text If we want to look for something while in less: / 91979410 (enter) Files Paolo Marcatili - Programmazione 08-09
Edit a file Let’s remove the first H sequence >vi heavy.fasta >nano heavy.fasta For those who live in 2008 >gedit heavy.fasta Files Paolo Marcatili - Programmazione 08-09
Look for text How many Igs in each file? We can count the lines! >wc heavy.fasta Files Paolo Marcatili - Programmazione 08-09
Look for text How many Igs in each file? We can count the lines! >wc heavy.fasta Lines > proteins!!! Files Paolo Marcatili - Programmazione 08-09
Grep # of proteins = # of “>” in a file >grep “>” heavy.fasta >grep -c “>” heavy.fasta Do it for all the files and write the result (I think they are too many…) Files Paolo Marcatili - Programmazione 08-09
Grep >grep -c V-region heavy.fasta >grep -c v-region heavy.fasta >grep -ci v-region heavy.fasta Ok, better! Files Paolo Marcatili - Programmazione 08-09
Files: sumary cp file1 file2 copy file1 and call it file2 mv file1 file2 move or rename file1 to file2 rm file remove a file cat file display a file less file display a file a page at a time head file display the first few lines tail file display the last few lines grep 'key' file search a file for keywords wc file number of lines Files Paolo Marcatili - Programmazione 08-09
Processes Paolo Marcatili - Programmazione 08-09
Run a process Process = execution of some instructions Usually the instructions are in a file. e.g. less -> /usr/bin/less So >/usr/bin/less heavy.fasta Processes Paolo Marcatili - Programmazione 08-09
Run - It’s simple Ok, so let’s try >./loop.pl Processes Paolo Marcatili - Programmazione 08-09
Run - It’s simple Ok, so let’s try >./loop.pl Ok, and now? Processes Paolo Marcatili - Programmazione 08-09
Controlling processes Ctrl+z -> go to sleep Now you’ve got the control again! But it’s not still dead… bg Ctrl+C Processes Paolo Marcatili - Programmazione 08-09
Controlling processes Or: >./loop.pl Ctrl+z >ps >top ( q to exit) >kill the_number_that_you_have_just_read Processes Paolo Marcatili - Programmazione 08-09
Redirection Control the force Paolo Marcatili - Programmazione 08-09
Inputs and outputs Keyboard Mouse Tablet Kernel Display Printer File Redirection Paolo Marcatili - Programmazione 08-09
Write into a file >Cat > lista.txt Heavy 29061 Ctrl+d And >less lista.txt Redirection Paolo Marcatili - Programmazione 08-09
Append to a file >Cat >> lista.txt Kappa 7476 Ctrl+d And >less lista.txt Redirection Paolo Marcatili - Programmazione 08-09
The big one! >cat heavy.fasta > bigone.fasta >cat kappa >> bigone.fasta >cat lambda.fasta >> bigone.fasta >grep -c “>” bigone.fasta Redirection Paolo Marcatili - Programmazione 08-09
Extract headers >grep “>” bigone.fasta > headers.head >sort headers.head > headers_sort.head Do we need the first file? Redirection Paolo Marcatili - Programmazione 08-09
Extract headers >grep “>” bigone.fasta > headers.head >sort headers.head > headers_sort.head Do we need the first file? No! >grep “>” bigone.fasta | sort > headers_sorted.head | is called pipe, and it’s something Redirection Paolo Marcatili - Programmazione 08-09
Redirect everything! >grep ">" biggone.fasta 2> err.log >less err.log Redirection Paolo Marcatili - Programmazione 08-09
Redirect - summary command > file redirect std output to a file command >> file append std output to a file command < file redirect std input from a file cmd1 | cmd2 pipe the output of cmd1 to the input of cmd2 cat f1 f2 > f0 concatenate f1 and f2 to f0 sort sort data Redirection Paolo Marcatili - Programmazione 08-09
Quiz What does this command perform? >grep -v &quot;>&quot; heavy.fasta How many proteins in each file? How many residues in each file? (hint: wc -m counts the # of char in a line) Average length of proteins in each file? Average content of Prolines of VH, VL and VK? (hint: look at grep parameters) Paolo Marcatili - Programmazione 08-09

Unix Master

  • 1.
    Unix for BioinformaticiansA survival guide Paolo Marcatili - Programmazione 08-09
  • 2.
    Agenda Unix FoldersFiles Processes Redirection Paolo Marcatili - Programmazione 08-09
  • 3.
    Unix He cansmell your fear Paolo Marcatili - Programmazione 08-09
  • 4.
    What is Unix ? Unix Paolo Marcatili - Programmazione 08-09
  • 5.
    What is Unix ? Unix Paolo Marcatili - Programmazione 08-09
  • 6.
    What is Unix ? Unix Paolo Marcatili - Programmazione 08-09
  • 7.
    What is Unix ? Unix Paolo Marcatili - Programmazione 08-09
  • 8.
    What is Unix ? Operating system stable, multi-user, multi-tasking for servers, desktops and laptops. Unix Paolo Marcatili - Programmazione 08-09
  • 9.
    Types of UnixSolaris OS-X Linux! Unix Paolo Marcatili - Programmazione 08-09
  • 10.
    Unix Operating SystemUnix Paolo Marcatili - Programmazione 08-09
  • 11.
    What’s in Unix?Files Processes Unix Paolo Marcatili - Programmazione 08-09
  • 12.
    Unix Filesystem UnixPaolo Marcatili - Programmazione 08-09
  • 13.
    Terminal It makesthe difference! Powerful Transparent User-unfriendly Unix Paolo Marcatili - Programmazione 08-09
  • 14.
    Our Task TodayYes, I can! Paolo Marcatili - Programmazione 08-09
  • 15.
    Human Immunoglobulins TaskPaolo Marcatili - Programmazione 08-09
  • 16.
    Human Immunoglobulins TaskPaolo Marcatili - Programmazione 08-09
  • 17.
    The data Wehave 3 files Fasta Sequences of Heavy (heavy.fasta) Lambda (lambda.fasta) Kappa (kappa.fasta) Task Paolo Marcatili - Programmazione 08-09
  • 18.
    The Task Lookdata Correct errors Do some analysis Make a single fasta file Task Paolo Marcatili - Programmazione 08-09
  • 19.
    Folders: read andwrite Paolo Marcatili - Programmazione 08-09
  • 20.
    Change Directory Toknow where you are >pwd /home/bioinfoSMFN Let’s move! >cd /home/bioinfoSMFN/Desktop/task Or >cd Desktop/ Folders Paolo Marcatili - Programmazione 08-09
  • 21.
    Folder content Let’scheck what’s in the folder: >ls Better >ls -la Cheat: parameters are useful! >ls -lart Folders Paolo Marcatili - Programmazione 08-09
  • 22.
    Wildcards Extremely useful!>ls -la *heavy* >ls -la heavy.?asta *= 0,1,2,…. occurences of whatever ?= exactly 1 occurence of whatever Folders Paolo Marcatili - Programmazione 08-09
  • 23.
    Commands To knowmore about a command: >man ls >whatis ls >apropos ls Or Google! Folders Paolo Marcatili - Programmazione 08-09
  • 24.
    Unix Permissions FoldersPaolo Marcatili - Programmazione 08-09
  • 25.
    Folders - summaryCommand Meaning ls list files and directories ls -a list all files and directories mkdir make a directory cd directory change to named directory cd change to home-directory cd ~ change to home-directory cd .. change to parent directory pwd path of the current directory Folders Paolo Marcatili - Programmazione 08-09
  • 26.
    Files: read andwrite Paolo Marcatili - Programmazione 08-09
  • 27.
    Backup original dataCreate a directory >mkdir backup Copy all the files in the directory >cp heavy.fasta backup/ >cp heavy.fasta heavy_copy.fasta >mv heavy_copy.fasta backup/heavy_backup.fasta Files Paolo Marcatili - Programmazione 08-09
  • 28.
    Read a fileLet’s see… >cat heavy.fasta Files Paolo Marcatili - Programmazione 08-09
  • 29.
    Read a fileLet’s see… >cat heavy.fasta Mmh… >less heavy.fasta Hint: q to quit… but if you are stuck try ctrl+c Files Paolo Marcatili - Programmazione 08-09
  • 30.
    Look for textIf we want to look for something while in less: / 91979410 (enter) Files Paolo Marcatili - Programmazione 08-09
  • 31.
    Edit a fileLet’s remove the first H sequence >vi heavy.fasta >nano heavy.fasta For those who live in 2008 >gedit heavy.fasta Files Paolo Marcatili - Programmazione 08-09
  • 32.
    Look for textHow many Igs in each file? We can count the lines! >wc heavy.fasta Files Paolo Marcatili - Programmazione 08-09
  • 33.
    Look for textHow many Igs in each file? We can count the lines! >wc heavy.fasta Lines > proteins!!! Files Paolo Marcatili - Programmazione 08-09
  • 34.
    Grep # ofproteins = # of “>” in a file >grep “>” heavy.fasta >grep -c “>” heavy.fasta Do it for all the files and write the result (I think they are too many…) Files Paolo Marcatili - Programmazione 08-09
  • 35.
    Grep >grep -cV-region heavy.fasta >grep -c v-region heavy.fasta >grep -ci v-region heavy.fasta Ok, better! Files Paolo Marcatili - Programmazione 08-09
  • 36.
    Files: sumary cpfile1 file2 copy file1 and call it file2 mv file1 file2 move or rename file1 to file2 rm file remove a file cat file display a file less file display a file a page at a time head file display the first few lines tail file display the last few lines grep 'key' file search a file for keywords wc file number of lines Files Paolo Marcatili - Programmazione 08-09
  • 37.
    Processes Paolo Marcatili- Programmazione 08-09
  • 38.
    Run a processProcess = execution of some instructions Usually the instructions are in a file. e.g. less -> /usr/bin/less So >/usr/bin/less heavy.fasta Processes Paolo Marcatili - Programmazione 08-09
  • 39.
    Run - It’ssimple Ok, so let’s try >./loop.pl Processes Paolo Marcatili - Programmazione 08-09
  • 40.
    Run - It’ssimple Ok, so let’s try >./loop.pl Ok, and now? Processes Paolo Marcatili - Programmazione 08-09
  • 41.
    Controlling processes Ctrl+z -> go to sleep Now you’ve got the control again! But it’s not still dead… bg Ctrl+C Processes Paolo Marcatili - Programmazione 08-09
  • 42.
    Controlling processes Or:>./loop.pl Ctrl+z >ps >top ( q to exit) >kill the_number_that_you_have_just_read Processes Paolo Marcatili - Programmazione 08-09
  • 43.
    Redirection Control theforce Paolo Marcatili - Programmazione 08-09
  • 44.
    Inputs and outputsKeyboard Mouse Tablet Kernel Display Printer File Redirection Paolo Marcatili - Programmazione 08-09
  • 45.
    Write into afile >Cat > lista.txt Heavy 29061 Ctrl+d And >less lista.txt Redirection Paolo Marcatili - Programmazione 08-09
  • 46.
    Append to afile >Cat >> lista.txt Kappa 7476 Ctrl+d And >less lista.txt Redirection Paolo Marcatili - Programmazione 08-09
  • 47.
    The big one!>cat heavy.fasta > bigone.fasta >cat kappa >> bigone.fasta >cat lambda.fasta >> bigone.fasta >grep -c “>” bigone.fasta Redirection Paolo Marcatili - Programmazione 08-09
  • 48.
    Extract headers >grep“>” bigone.fasta > headers.head >sort headers.head > headers_sort.head Do we need the first file? Redirection Paolo Marcatili - Programmazione 08-09
  • 49.
    Extract headers >grep“>” bigone.fasta > headers.head >sort headers.head > headers_sort.head Do we need the first file? No! >grep “>” bigone.fasta | sort > headers_sorted.head | is called pipe, and it’s something Redirection Paolo Marcatili - Programmazione 08-09
  • 50.
    Redirect everything! >grep&quot;>&quot; biggone.fasta 2> err.log >less err.log Redirection Paolo Marcatili - Programmazione 08-09
  • 51.
    Redirect - summarycommand > file redirect std output to a file command >> file append std output to a file command < file redirect std input from a file cmd1 | cmd2 pipe the output of cmd1 to the input of cmd2 cat f1 f2 > f0 concatenate f1 and f2 to f0 sort sort data Redirection Paolo Marcatili - Programmazione 08-09
  • 52.
    Quiz What doesthis command perform? >grep -v &quot;>&quot; heavy.fasta How many proteins in each file? How many residues in each file? (hint: wc -m counts the # of char in a line) Average length of proteins in each file? Average content of Prolines of VH, VL and VK? (hint: look at grep parameters) Paolo Marcatili - Programmazione 08-09