unix course part iii advanced operations
play

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


  1. UNIX Course Part III Advanced Operations Andy Hauser LAFUGA Gene Center Munich LMU June, 2016 1

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

  3. Solutions from last session $ 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 3

  4. Some other solutions

  5. seq - creating number sequences $ seq 1 5 arguments are range from and to 1 2 3 4 5 $ seq 5 1 also goes form higher to lower 5 4 3 2 1 $ seq 9 2 13 third argument in the middle is step size 9 11 13 $ seq -w 9 11 -w adds padding 0s 09 10 11

  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

  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

  8. rev - reverse lines $ echo hello world | rev dlrow olleh Hey what do we need that for … ?!?

  9. How to get the reverse complement of a DNA sequence?

  10. How to get the reverse complement of a DNA sequence? $ echo AAAGTAAC | tr AGTC TCAG | rev GTTACTTT

  11. read - a line into a variable $ echo hello world | read myline $ echo $myline hello world

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

  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

  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

  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

  16. awk - programming language $ seq 8 12 > 8to12 $ awk '{print length}' 8to12 1 1 2 2 2 $ awk '/1/ {print length}' 8to12 // matches like grep 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

  17. sed - streaming editor $ sed 's/1/2/' 8to12 Many commands. 8 e.g. s/// for replacing text 9 20 21 22 $ sed '/11/s/1/2/' 8to12 lines to act on can be selected with // 8 9 10 21 12 $ sed -n '/11/s/1/2/p' 8to12 21 $ sed -n '/1./s/1/2/p' 8to12 sed takes grep like regular expressions 20 21 22

Recommend


More recommend