Difference between revisions of "I2rda Course Cheatsheet"

From wiki
Jump to: navigation, search
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
= Ways of getting out of things =
 +
* Typing <code>exit</code> (the terminal, command-line, queue system, screen program)
 +
* <code>Ctrl+C</code>, usually interrupts a process
 +
* <code>q()</code>in R.
 +
* <code>q</code> in less and xpdf
 +
* alt-F4, sometimes for R plots for instance.
 +
* <code>Ctrl+W</code>, to close a tab.
 +
 +
= the <code>module</code> software loading program =
 +
 +
* <code>moduleav</code> to see what's available
 +
* <code>moduleav |grep samtools</code> to see only those lines containing <code>samtools</code>
 +
* <code>module help samtools</code>, to see any possible help information (<code>samtools</code> in this case) on the module (not always informative).
 +
* <code>module list</code> to see your currently loaded software modules
 +
* <code>module load samtools</code> to load a certain (<code>samtools</code> in this case) module (Default modules do not need version numbers).
 +
* <code>module unload samtools</code> to unload a certain (<code>samtools</code> in this case) module (Default modules do not need version numbers).
 +
 +
= GNU screen program =
 +
 +
* type <code>screen</code> to get in.
 +
* type <code>exit</code> to get out of your screen sessions
 +
* <code>ctrl+l, n</code>: cycle through screen windows
 +
* <code>ctrl+l, :hardcopy RET</code>: create a file with a copy of all inputs and outputs of your session.
 +
* <code>ctrl+l,d</code>: detach screen session
 +
* type <code>screen -r</code> to recover a detached session.
 +
* <code>ctrl+l,K</code>: abandon current session. It will be lost.
 +
* <code>ctrl+l,ESC</code>: enter scroll or copy mode. <code>PgUp</code> an <code>PgDn</code> will now work. <code>Esc</code> to get out.
 +
One thing to note with <code>screen</code> and scolling up and down through past pages of long output, it is not direct, you need:
 +
* ctrl+l,<code>Esc</code>, then you can use the <code>PgUp</code> and <code>PgDn</code>. To get our of this scroll or copy-mode as it's called, <code>Esc</code>.
 +
 +
= Graphical programs =
 +
 +
* Note Using graphical programs on the cluster is slow, because very many pixels all have to be sent down the network.
 +
* to view pdf files: <code>xpdf <file.pdf></code>.<code>q</code> will exit.
 +
* to view spreadsheet, tsv or csv files: <code>gnumeric <file.csv></code>. <code>Alt-F4</code> to get out.
 +
* When <code>R</code> pops up a plot, <code>Alt-F4</code> to get out.
 +
 
= Command-line Navigation =
 
= Command-line Navigation =
 +
(majority of these work both on Unix/Linux command-line '''and''' in the R interpreter)
 +
 
* <code>ctrl + a</code>: go to beginning of line
 
* <code>ctrl + a</code>: go to beginning of line
 +
* <code>ctrl + d</code>: delete a character (useful when used after above)
 
* <code>ctrl + e</code>: go to end of line
 
* <code>ctrl + e</code>: go to end of line
 +
* <code>alt + b</code>: move backwards word-wise.
 +
* <code>alt + f</code>: move backwards word-wise
 +
* <code>alt + d</code>: delete current word forwards, next word if in space
 +
* <code>ctrl + k</code>: delete to end of line
 
* <code>ctrl + w</code>: delete current word backwards, word behind if in space
 
* <code>ctrl + w</code>: delete current word backwards, word behind if in space
 +
* <code>ctrl + y</code>: yank, or paste most recent deletion (useful when used after above to repeat deletion)
 
* <code>ctrl + /</code>: undo changes
 
* <code>ctrl + /</code>: undo changes
 
* <code>ctrl + x, <BACKSPACE></code>: search backwards for a character, here?
 
* <code>ctrl + x, <BACKSPACE></code>: search backwards for a character, here?
 
* <code>ctrl + r, ?</code>: search backwards for a character, here?
 
* <code>ctrl + r, ?</code>: search backwards for a character, here?
* <code>alt + b</code>: move backwards word-wise.
 
* <code>alt + f</code>: move backwards word-wise
 
* <code>alt + d</code>: delete current word forwards, next word if in space
 
* <code>ctrl + k</code>: delete to end of line
 
 
= Pagers: <code>man</code>, <code>less</code> and <code>vim</code> keys =
 
 
* This is a continuous and very important activity
 
* Linux has a large and comprehensive documentation system called <code>man</code>
 
* Linux manual pages are referred to as man pages.
 
* To open the man page for a particular command, you just need to type man followed by the name of the command you are interested in.
 
* To browse through a man page, use the up,down,pgup and pgn keys.
 
* To close (quit) the man page simply hit the q key on your keyboard.
 
followed by the type of thing you are trying to do. An example of this is in exercise 1-3, part c).
 
 
==Exercise ==
 
 
* Look up the manual information for the ls command by typing the following in a terminal:
 
man echo
 
man mkdir
 
 
* What can you say about this command?
 
  
Now try:
+
= Pagers: <code>man</code>, <code>less</code>, <code>vim</code> and <code>R</code>-help =
man ls
 
  
* Did you think you knew this command already?
+
* <code>q</code>, to get out again.
* What does the <code>-h</code> option do? What about the <code>-a</code> option? What would running <code>ls -lrt</code> do?
+
* <code>gg</code>, for top of the page
* Press the <code>q</code> key when you want to quit reading the man page.
+
* <code>G</code>, for bottom of page
* Try running <code>ls</code> using some of the options mentioned above.
+
* <code>Ctrl+f</code>, to advance one page forward.
 
+
* <code>Ctrl+b</code>, to move one page back.
* Look up some programs with man pages with the keywords "list directory"
+
* <code>/</code> to search, it allows you type in a search term at the bottom.
man –k "list directory"
+
* The <code>up</code>,<code>down</code>,<code>PgUp</code> and <code>PgDn</code> keys all work as expected.
  
 
= Linux shortcut symbols =
 
= Linux shortcut symbols =
Line 51: Line 73:
 
* <code>|</code> often called the pipe operator: directs output of one command into another command.
 
* <code>|</code> often called the pipe operator: directs output of one command into another command.
  
== Keybindings for using the history file ==
+
= Keybindings for using the history file =
  
 
* <code>:<RET></code>: save command in history, do not execute.
 
* <code>:<RET></code>: save command in history, do not execute.
Line 62: Line 84:
 
* <code>!!:gs/then/now/:p<RET></code>: as above except do not execute.
 
* <code>!!:gs/then/now/:p<RET></code>: as above except do not execute.
  
== An important note on line endings – CR and LF ==
+
= Using vim =
 
 
* Besides spaces in filename, there is another major pitfalls when transferring file over to Linux.
 
* In Linux, the end of line is called a new line, symbol with <code>\n</code>.
 
* Windows uses <code>CR</code> and <code>LF</code> .. called the <code>DOS</code> format.
 
* Old Macs used <code>LF</code>
 
* the tools <code>dos2unix</code> and <code>mac2unix</code> convert
 
 
 
= Text editing =
 
 
 
* There are very many text editors, but one of the most powerful and dependable is <code>vi</code>.
 
* It has a steep but tiny learning curve, which we hope to conquer in this section.
 
 
 
* "vi" is an old version and is available on all Unix/linux systems by default
 
* Vim is the modern version, it used <code>ncurses</code> to use the whole screen
 
* It's free and has graphical version call gvim and a Windows version too.
 
 
 
== Using vim ==
 
  
 
* type <code>vim</code> to get in, and <code>:q!</code> to get out without saving.
 
* type <code>vim</code> to get in, and <code>:q!</code> to get out without saving.
Line 100: Line 105:
 
* "dw" delete current word
 
* "dw" delete current word
 
* Command: Activated by ":", sub-box at the bottom open, rich command language
 
* Command: Activated by ":", sub-box at the bottom open, rich command language
* Visual: Activated by "v" or "V" (visual block), sub-box at the bottom open, rich command language
+
* Visual: Activated by <code>v</code> or <code>ctrl+v</code> (visual block), sub-box at the bottom open, rich command language
  
 
== Advanced but really useful commands ==
 
== Advanced but really useful commands ==
  
* ":colorscheme desert" chang to the desert colour scheme, "morning" "delek" many others
+
* <code>:colorscheme desert</code> change to the desert colour scheme, there are many others: <code>morning</code>, <code>delek</code>.
 
* <code>:%s/snooze/sneeze/gc</code> also works
 
* <code>:%s/snooze/sneeze/gc</code> also works
 
* <code>:g/sneeze/d delete all lines without sneeze&quot;</code>
 
* <code>:g/sneeze/d delete all lines without sneeze&quot;</code>
 
* <code>:v/sneeze/d delete all lines with sneeze&quot;</code>
 
* <code>:v/sneeze/d delete all lines with sneeze&quot;</code>
 
* ":42y[RET]p" paste line 42
 
* ":42y[RET]p" paste line 42
* "d214G" delete to line 214
+
* "d214G" delete up to line 214
* "y214G" delete to line 214
+
* "y214G" copy up to line 214
 
* <code>:set list</code>, all non-printing characters are also shown.
 
* <code>:set list</code>, all non-printing characters are also shown.
* <code>:set hlsearch</code>, will highlight all search occurences.
+
* <code>:set hlsearch</code>, will highlight all search occurrences.
 
* <code>:set nu</code>, show line numbers.
 
* <code>:set nu</code>, show line numbers.
  
 +
= a fast pdf viewer: <code>xpdf</code> =
 +
* <code>xpdf mypdffile.pdf</code> opens <code>mypdffile.pdf</code> using the X11 graphical system
 +
* <code>q</code> to get out
 +
* <code>+</code> to maker bigger
 +
* <code>-</code> to make smaller
 +
* <code>Spacebar</code> for bottom of page
 +
* <code>n</code> for next page
 +
* <code>p</code> for previous page
 +
* <code>alt+f</code> toggle for full screen and back
  
== Exercises ==
+
= IGV Genome browser keys =
Type:
+
* ctrl-R Defines the region currently in view as a region of interest.
screen
+
* ctrl-F/ctrl-B Skip forward to the next feature and back to the last feature.
Then:
+
* ctrl-shift-F/ctrl-shift-B If you have the feature track expanded and have selected one of the rows, this will skip forward to the next exon or back to the last exon.
* <code>ctrl+l, n</code>: cycle through screen windows
+
* alt-left/alt-right, move you back and forward through your IGV history.
* <code>ctrl+l, :hardcopy RET</code>: create a file with a copy of all inputs and outputs of your session.
+
* Arrow-keys Pans left, right, up, and down in the current chromosome.
* <code>ctrl+l, d</code>: detach screen session
+
* Home/End-keys Skips to the page top or bottom of the current view, then pages right or left respectively.
* type <code>screen -r</code> to recover a detached
+
* PageUp/PageDown-keys Pages up and down the current view.
* type exit to get out of your screen sessions
 

Latest revision as of 19:29, 11 May 2017

Ways of getting out of things

  • Typing exit (the terminal, command-line, queue system, screen program)
  • Ctrl+C, usually interrupts a process
  • q()in R.
  • q in less and xpdf
  • alt-F4, sometimes for R plots for instance.
  • Ctrl+W, to close a tab.

the module software loading program

  • moduleav to see what's available
  • moduleav |grep samtools to see only those lines containing samtools
  • module help samtools, to see any possible help information (samtools in this case) on the module (not always informative).
  • module list to see your currently loaded software modules
  • module load samtools to load a certain (samtools in this case) module (Default modules do not need version numbers).
  • module unload samtools to unload a certain (samtools in this case) module (Default modules do not need version numbers).

GNU screen program

  • type screen to get in.
  • type exit to get out of your screen sessions
  • ctrl+l, n: cycle through screen windows
  • ctrl+l, :hardcopy RET: create a file with a copy of all inputs and outputs of your session.
  • ctrl+l,d: detach screen session
  • type screen -r to recover a detached session.
  • ctrl+l,K: abandon current session. It will be lost.
  • ctrl+l,ESC: enter scroll or copy mode. PgUp an PgDn will now work. Esc to get out.

One thing to note with screen and scolling up and down through past pages of long output, it is not direct, you need:

  • ctrl+l,Esc, then you can use the PgUp and PgDn. To get our of this scroll or copy-mode as it's called, Esc.

Graphical programs

  • Note Using graphical programs on the cluster is slow, because very many pixels all have to be sent down the network.
  • to view pdf files: xpdf <file.pdf>.q will exit.
  • to view spreadsheet, tsv or csv files: gnumeric <file.csv>. Alt-F4 to get out.
  • When R pops up a plot, Alt-F4 to get out.

Command-line Navigation

(majority of these work both on Unix/Linux command-line and in the R interpreter)

  • ctrl + a: go to beginning of line
  • ctrl + d: delete a character (useful when used after above)
  • ctrl + e: go to end of line
  • alt + b: move backwards word-wise.
  • alt + f: move backwards word-wise
  • alt + d: delete current word forwards, next word if in space
  • ctrl + k: delete to end of line
  • ctrl + w: delete current word backwards, word behind if in space
  • ctrl + y: yank, or paste most recent deletion (useful when used after above to repeat deletion)
  • ctrl + /: undo changes
  • ctrl + x, <BACKSPACE>: search backwards for a character, here?
  • ctrl + r, ?: search backwards for a character, here?

Pagers: man, less, vim and R-help

  • q, to get out again.
  • gg, for top of the page
  • G, for bottom of page
  • Ctrl+f, to advance one page forward.
  • Ctrl+b, to move one page back.
  • / to search, it allows you type in a search term at the bottom.
  • The up,down,PgUp and PgDn keys all work as expected.

Linux shortcut symbols

  • . the directory you are currently in, often used with mv, cp or ln -s to mean "in here please"
  • .. the directory one level above the one you are currently in, aka. the parent directory
- To change directory to the one above your are in: cd ..
  • To returns to the last directory you were working in before this one: cd –
  • On its own, cd bring you to your home directory
  • ~ shorthand for your home directory, where all your data is kept.
  • > directs output of one command into a file
  • | often called the pipe operator: directs output of one command into another command.

Keybindings for using the history file

  • :<RET>: save command in history, do not execute.
  • !$<RET>: the final argument of the last command
  • !!<RET>: the entire last command
  • !:1-$<RET>: everthing except the first word of the last command
  • !$<RET>: the final argument of the last command
  • ^then^now<RET>: replace the first occurence of then in last command with now
  • !!:gs/then/now/<RET>: replace the ALL occurences of "then" in last command with "now"
  • !!:gs/then/now/:p<RET>: as above except do not execute.

Using vim

  • type vim to get in, and :q! to get out without saving.
  • ZZ to save onto to current filename. ":sav fname" otherwise
  • It opens in "normal" mode which is similar to less, in that direct editing is not expected.
  • This is changed by pressing i. To get back to normal mode, press the ESC key.
  • In normal mode u undoes any changes
  • : while in normal mode allows command sto be entered
  • Visual: enabled by "v" or "V" (visual block), sub-box at the bottom open.
  • After v or V, movement keys ":%" will operate on whole document, ":’a,’b" operate between two marks, ":42,45" between two line numbers
  • search via "/", ":set hlsearch" to see all the hits

Getting by in only normal mode

  • movement keys, "w" jump via start of words; "e" jump via ends; "fc" jump to next c
  • "0" for start of line, "A" for end of line and into insert mode
  • "x" delete current character, "xp" switch positions of current and next character
  • "yyp" copy current line and paste it underneath
  • "dd" delete line, "2d" delete this and following two lines. "dgg" delete to start, "dG" delete to end
  • "dw" delete current word
  • Command: Activated by ":", sub-box at the bottom open, rich command language
  • Visual: Activated by v or ctrl+v (visual block), sub-box at the bottom open, rich command language

Advanced but really useful commands

  • :colorscheme desert change to the desert colour scheme, there are many others: morning, delek.
  • :%s/snooze/sneeze/gc also works
  • :g/sneeze/d delete all lines without sneeze"
  • :v/sneeze/d delete all lines with sneeze"
  • ":42y[RET]p" paste line 42
  • "d214G" delete up to line 214
  • "y214G" copy up to line 214
  • :set list, all non-printing characters are also shown.
  • :set hlsearch, will highlight all search occurrences.
  • :set nu, show line numbers.

a fast pdf viewer: xpdf

  • xpdf mypdffile.pdf opens mypdffile.pdf using the X11 graphical system
  • q to get out
  • + to maker bigger
  • - to make smaller
  • Spacebar for bottom of page
  • n for next page
  • p for previous page
  • alt+f toggle for full screen and back

IGV Genome browser keys

  • ctrl-R Defines the region currently in view as a region of interest.
  • ctrl-F/ctrl-B Skip forward to the next feature and back to the last feature.
  • ctrl-shift-F/ctrl-shift-B If you have the feature track expanded and have selected one of the rows, this will skip forward to the next exon or back to the last exon.
  • alt-left/alt-right, move you back and forward through your IGV history.
  • Arrow-keys Pans left, right, up, and down in the current chromosome.
  • Home/End-keys Skips to the page top or bottom of the current view, then pages right or left respectively.
  • PageUp/PageDown-keys Pages up and down the current view.