UNIX Course Part III Advanced Operations Andy Hauser LAFUGA Gene - - PowerPoint PPT Presentation

unix course part iii advanced operations
SMART_READER_LITE
LIVE PREVIEW

UNIX Course Part III Advanced Operations Andy Hauser LAFUGA Gene - - PowerPoint PPT Presentation

UNIX Course Part III Advanced Operations Andy Hauser LAFUGA Gene Center Munich LMU June, 2016 1 How many sense vs. anti- sense genes are in ecoli? 2 Solutions from last session $ grep 'CDS' | cut -f 7 ecoli_1-7.gtf | sort | uniq -c 2367


slide-1
SLIDE 1

UNIX Course Part III Advanced Operations

Andy Hauser LAFUGA Gene Center Munich LMU June, 2016

1

slide-2
SLIDE 2

How many sense vs. anti- sense genes are in ecoli?

2

slide-3
SLIDE 3

$ grep 'CDS' | cut -f 7 ecoli_1-7.gtf | sort | uniq -c 2367 + 2198 -

$ grep -c "CDS\t.*\t\-" ecoli_1-7.gtf 2198 $ grep -c "CDS\t.*\t\+" ecoli_1-7.gtf 2367

$ grep "CDS\t.*\t\-" ecoli_1-7.gtf | wc -l 2198 $ grep "CDS\t.*\t\+" ecoli_1-7.gtf | wc -l 2367

Solutions from last session

3

slide-4
SLIDE 4

Some other solutions

slide-5
SLIDE 5

seq - creating number sequences

$ seq 1 5 1 2 3 4 5 $ seq 5 1 5 4 3 2 1 $ seq 9 2 13 9 11 13 $ seq -w 9 11 09 10 11

  • w adds padding 0s

arguments are range from and to also goes form higher to lower third argument in the middle is step size

slide-6
SLIDE 6

paste - join columns

$ seq 1 5 > 1to5 $ seq 5 1 > 5to1 $ paste 1to5 5to1 1 5 2 4 3 3 4 2 5 1

slide-7
SLIDE 7

tr - transliterate

$ echo hello world | tr e a hallo world $ echo hello world | tr ehw aHW Hallo World $ echo hello world | tr a-z A-Z HELLO WORLD

slide-8
SLIDE 8

rev - reverse lines

$ echo hello world | rev dlrow olleh

Hey what do we need that for … ?!?

slide-9
SLIDE 9

How to get the reverse complement of a DNA sequence?

slide-10
SLIDE 10

How to get the reverse complement of a DNA sequence?

$ echo AAAGTAAC | tr AGTC TCAG | rev GTTACTTT

slide-11
SLIDE 11

read - a line into a variable

$ echo hello world | read myline $ echo $myline hello world

slide-12
SLIDE 12

while loop

$ while read myline; do echo line: $myline done < 1to5 line: 1 line: 2 line: 3 line: 4 line: 5

slide-13
SLIDE 13

for loop

$ for i in 1 2 3 4 5; do echo line: $i done line: 1 line: 2 line: 3 line: 4 line: 5

slide-14
SLIDE 14

subshells

$ echo `cat 1to5` 1 2 3 4 5 $ for i in `cat 1to5`; do echo line: $i done line: 1 line: 2 line: 3 line: 4 line: 5

slide-15
SLIDE 15

Regular Expressions

  • [] one character from set, e.g. [abc] or ranges [a-z]
  • $ matches line end, e.g. "png$"
  • ? in shell: any one character
  • . in grep any one character
  • * in shell any characters
  • .* in grep any characters
slide-16
SLIDE 16

awk - programming language

$ seq 8 12 > 8to12 $ awk '{print length}' 8to12 1 1 2 2 2 $ awk '/1/ {print length}' 8to12 2 2 2 $ paste 1to5 8to12 1 8 2 9 3 10 4 11 5 12 $ paste 1to5 8to12 | awk '{print $1}' 1 2 3 4 5 $ paste 1to5 8to12 | awk '{print $2}' 8 9 10 11 12

// matches like grep

slide-17
SLIDE 17

sed - streaming editor

$ sed 's/1/2/' 8to12 8 9 20 21 22 $ sed '/11/s/1/2/' 8to12 8 9 10 21 12 $ sed -n '/11/s/1/2/p' 8to12 21 $ sed -n '/1./s/1/2/p' 8to12 20 21 22

sed takes grep like regular expressions lines to act on can be selected with // Many commands. e.g. s/// for replacing text