1 / 37

Computer Programming for Biologists

Computer Programming for Biologists. Oct 30 th – Dec 11 th , 2014 Karsten Hokamp ( kahokamp@tcd.ie ) http://bioinf.gen.tcd.ie/GE3M25/programming  Fill out survey, please!. Computer Programming for Biologists. Organisation. Classes: Lectures i nterspersed with

Download Presentation

Computer Programming for Biologists

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Programming for Biologists Oct 30th – Dec 11th, 2014 Karsten Hokamp (kahokamp@tcd.ie) http://bioinf.gen.tcd.ie/GE3M25/programming  Fill out survey, please!

  2. Computer Programming for Biologists Organisation Classes: Lectures interspersed with excercises and practicals Exam: 2-hour exam during last double lecture (11th Dec)

  3. Class I: Overview and Motivation Questions • What is computer programming? • Why do we need computer programming? • How do we program computers?

  4. Class I: Overview and Motivation What is and what is not computer programming? • Write shell scripts • Write programs • Write one-liners • Automate tasks • E-mailing • Web browsing • Run programs

  5. Class I: Overview and Motivation The greater context: Bioinformatics Increase of data led to greater need for computational methods  Informatics (computer science) + Biology = Bioinformatics also: Computational Biology

  6. Class I: Overview and Motivation Why do we need computer programming? • Automate tasks • Modify existing programs • Combine programs • Increase control • New ‘laboratory’ skill

  7. Class I: Overview and Motivation Use of programming • Scientific research • Efficiency • Not only for biological data • Data (re-)formatting and extraction • File organization, backups, etc.

  8. Class I: Overview and Motivation How do we program computers? • Pick a programming language • Learn the basics • Start writing programs • Practice and improve

  9. Practical! Example programming with Scratch http://scratch.mit.edu

  10. Class I: Overview and Motivation Programming languages (examples) Faster development, slower execution Slower development, faster execution

  11. Class I: Overview and Motivation Advantages of Perl • Quick development cycle • Easy to learn • Wide-spread use • Great for text processing • Many bioinformatics extensions

  12. shell prompt Class I: Overview and Motivation The command line • Access through console or terminal • Use of keyboard instead of mouse

  13. Next Unix Basics

  14. Unix File Hierarchy bin etc data Users lib root (/) sbin sw tmp usr var

  15. User-related folders bin core programs etc data Users home directories lib root (/) sbin sw tmp temporary storage space user programs and packages usr var

  16. Home directories bin user1 etc data user2 Users user3 lib root (/) sbin user4 sw tmp usr var

  17. Login location bin user1 etc data user2 Users user3 lib root (/) prompt sbin user4 sw user2 $ tmp usr var

  18. Print working directory (pwd) bin user1 etc data user2 Users user3 lib root (/) command sbin user4 sw user2 $ pwd tmp usr var

  19. Print working directory (pwd) bin user1 etc data user2 Users user3 lib root (/) output: full path sbin user4 sw user2 $ user2 $ pwd pwd tmp user2 $ /home/user2 /Users/user2 usr var separator

  20. Change directory bin user1 etc Desktop data user2 Documents Users user3 lib command root (/) sbin argument user4 sw user2 $ change to new location in file hierarchy cd Desktop tmp pwd user2 $ usr /Users/user2/Desktop var

  21. cd go to home directory cd - go to previous directory cd .. go to upper directory Change directories bin user1 etc Desktop data user2 Documents Users user3 lib root (/) sbin user4 sw tmp usr var

  22. Path specifications bin user1 etc Desktop data user2 Documents Users user3 lib root (/) sbin user4 sw tmp usr var

  23. Create new directory bin user1 etc Desktop data user2 Users user3 lib root (/) sbin user4 sw user2 $ mkdir class1 user2 $ pwd user2 $ mkdir class1 tmp user2$ /home/user2 user2 $ mkdir ‘test dir’ usr var

  24. Create new directory bin class1 user1 etc Desktop test dir data user2 Users user3 lib root (/) sbin user4 sw Two new directories (or folders) created tmp usr var

  25. . (single dot) current directory .. (two dots) upper directory ~ (tilde) home directory Special directories bin class1 user1 etc Desktop test dir data user2 Users user3 lib root (/) sbin user4 sw tmp usr var

  26. cd change directory (defaults to home directory) ls listing of directory (defaults to current directory) mkdir create a directory mv move or rename file or directory rm remove file rmdir remove empty directory Other commands

  27. Find more information! Manual pages for Unix tools: man ls ls –h ls –help ls --help EMBnet Quick Guides: • A Quick Guide to UNIX • A Quick Guide to PERL • A Quick Guide to PERL Regular Expressions http://www.embnet.org/embnet-quickguides

  28. Practical! A few exercises to get you familiar with the command line and the Unix environment…. Go to: http://bioinf.gen.tcd.ie/GE3M25/programming/class1 and click on the ‘UNIX’ topic. I hear and I forget. I see and I remember. I do and I understand. Confucius, Chinese philosopher & reformer (551 BC - 479 BC)

  29. Class I: First Program Perl example # My first Perl program # define the message $text = "Hello World!\n"; # print message to screen print $text; exit;

  30. Class I: First Program Perl example # My first Perl program # define the message $text="Hello World!\n"; # print message to screen print$text; exit; comments variable assignment string special character built-in function Statements end with semicolon!

  31. Class I: First Program Running the script • Save script to a file (e.g. hello.pl) • Pass on to interpreter: $ perl hello.pl Hello World! $

  32. Class I: First Program Perl flow • Shell calls interpreter (perl) • Passes on code (script) • Syntax check • Translation into operational code • Execution

  33. Class I: First Program Perl errors What to do when things go wrong, e.g. • Take a good look at the error message • Check syntax syntax error at hello.pl line 7, near "print" Execution of hello.pl aborted due to compilation errors.

  34. Practical! A few exercises to get you started with writing and running Perl scripts …. Go to: http://bioinf.gen.tcd.ie/GE3M25/programming/class1 and click on the ‘Editor’ topic.

  35. Perl on a Windows PC • Perl Installations • CygWin (http://www.cygwin.com) Unix environment for Windows, includes Perl • ActiveState Perl http://www.activestate.com/activeperl/downloads  any version 5.x c) Strawberry Perl: (http://strawberryperl.com) Perl Source and Binaries: http://www.perl.org/get.html

  36. Computer Programming for Biologists References R.L. Schwartz, Learning Perl, O’Reilly James Tisdall, Beginning Perl for Bioinformatics, O’Reilly Free online books: http://www.perl.org/books/library.html

  37. Next week: • A short online quiz • Introduction of the course project • More Perl

More Related