13.07.2015 Views

Introduction to Unix

Introduction to Unix

Introduction to Unix

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Introduction</strong> <strong>to</strong> <strong>Unix</strong> ICarolin KosiolInstitute of Population GeneticsVetmeduni ViennaSpezielle Bioinformatik in der BiomedizinSS 2013


<strong>Unix</strong>: not just an unfortunate name“Hold it right there, buddy”“That scruffy beard… Those suspenders. That smug expression”“You’re one of those condescending unix computer users!”“Here’s a nickel kid. Get yourself a better computer”SourcesDILBERT ©2009, UNITED FEATURE SYNDICATE, INC (Scott Adams)Ken and Dennis: Wikipedia, public domain


Why? It’s cool now …Every Apple computer, the iPhone and most recent iPodshave a <strong>Unix</strong> base underneath their façade.


But really...why?~ 1KB / day100GB / run~300 million fragmentsMultiplex 96 different samples300GB / run~1.5 billion fragments


File SystemFiles on a <strong>Unix</strong> system are in a tree structureRoot direc<strong>to</strong>ry, also called /Top level direc<strong>to</strong>riesKeith’s filespwd/Users/student/unix/# The following refer <strong>to</strong> the same file. First, absolute filename from the root# A forward slash / separates direc<strong>to</strong>ry names# cat prints the contents of a file on the screencat /Users/student/unix/haikuA crash reducesyour expensive computer<strong>to</strong> a simple s<strong>to</strong>ne.# File name relative <strong>to</strong> current location (/Users/student/unix/)cat unix/haiku


File system


Terminal & Command line


whoamistudent1pwd/Users/studentlsDocuments … … unixcd Dcd D cd Decd ..cdGetting from ‘A’ <strong>to</strong> ‘B’


Move and Copypwd/Users/student/unix/MoveCopylsalignmnet.fasta read-only test testmv alignmnet.fasta alignment.fastalsalignment.fasta read-only test testcp alignment.fasta alignment_copy.fastalsalignment.fasta alignment_copy.fasta read-only test test


Dealing with Multiple Filespwd/Users/student/unix/MultipleFilesmkdir Fasta Treecp *.fasta Fastacp *.tree Tree


Removing files and direc<strong>to</strong>riespwd/Users/student/unix/MoveCopyrm read-onlyrm:rm /dev/nullrm testalignment.fasta read-only test testrmdir testls testafilerm test/afilerm test/afilermdir test


Man pages (Getting help)man lsman cdman man (yes even the man command has a manual page)ls -lls -a


SummaryTheabsolutebasicsBasic file controlViewing/creating/editing filesMisc.usefulcommandsPowercommandsProcessrelatedcommandsls mv less man uniq <strong>to</strong>pcd cp head chmod sort pspwd mkdir tail source cut killrmdir <strong>to</strong>uch wc trrm nano curl grepI (pipe)sed> (write <strong>to</strong> file)< (read from file)


ExercisesThe exercises are already installed on the institute computersTo install on your own computer, use the following recipe.To download and install exercises# Type commands in bold# Lines starting with hash are comments# Make sure you are in home direc<strong>to</strong>rycd# Download file containing exercises (curl) and unpack (tar)curl –L ‘http://tinyurl.com/32a2gbk/unix.tgz’ | tar –zx# List files and make sure everything worked.#You should see a direc<strong>to</strong>ry called exerciseslsTo remove# Make sure you are in home direc<strong>to</strong>rycd# Remove exercises. The direc<strong>to</strong>ry and everything in it,# including subdirec<strong>to</strong>ries, will be deletedrm –rf exercise


<strong>Introduction</strong> <strong>to</strong> <strong>Unix</strong> IICarolin KosiolInstitute of Population GeneticsVetmeduni ViennaNext Generation Sequencing CourseSS 2013


Are we just making life hard for ourselves?Every command• reads text from its standard input (“stdin”)• writes text <strong>to</strong> standard output (“stdout”)• writes errors <strong>to</strong> standard error (“stderr”)KeyboardstdinCommandstdoutScreenUse a pipe | <strong>to</strong> connect the stdout of one command <strong>to</strong> the stdin of anotherKeyboardCommand 1Command 2ScreenChain commands <strong>to</strong> perform more complex tasks5 individual commands 25 possible pairs 125 triplets …


UNIX pipespwd/Users/student1/unix/Pipescat transcripts.fasta.gz | gunzipgunzip < transcript.fasta.gz | grep ‘^>’ | cut –d ‘|’ –f|_sort | uniq –c > transcript_counts.txt


First shell scriptpwd/Users/student/unixecho ‘echo $VAR’ > scriot..shVAR=“Hello”chmod +x script.sh./script.shHello


R Language for Statistical Computing> x y print(y) # print (vec<strong>to</strong>r) y[1] 1 4 9 16 25 36> mean(y) # Calculate average (arithmetic mean) of (vec<strong>to</strong>r) y;# result is scalar[1] 15.16667> var(y) # Calculate sample variance[1] 178.9667> lm_1 print(lm_1) # Print the model from the (linear model object) lm_1q();


Appendix


ThanksforlisteningInstitute of Population Genetics(Univ of Veterinary Medicine Vienna)Tim Massingham(European Bioinformatics Institute)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!