Presentation is loading. Please wait.

Presentation is loading. Please wait.

Why? – Examples Speaking Computer-ise – How – What – Environment (windows) Basic Instructions – Declare – Conditional – Loop – Input Write a quiz game.

Similar presentations


Presentation on theme: "Why? – Examples Speaking Computer-ise – How – What – Environment (windows) Basic Instructions – Declare – Conditional – Loop – Input Write a quiz game."— Presentation transcript:

1

2 Why? – Examples Speaking Computer-ise – How – What – Environment (windows) Basic Instructions – Declare – Conditional – Loop – Input Write a quiz game Programming in bioinformatics – Transcription – Gene Structure – Blast

3 Computers do tedious work without complaining Computers don’t make arithmetic errors (but they can make a rounding error) We want to be lazy Its fun!

4 Declare a variable Define a data structure Test a condition Iterate through a loop Get input

5 Calculating huge equations accurately – projectile tables – Discrete models Searching – Quickest route – Matches to a database – faces in a picture Examples?

6 Calculating huge equations accurately – projectile tables – Discrete models Searching – Quickest route – Matches to a database – faces in a picture Examples?

7 Make Diagnoses – Identify mutations – Organize and decode test results (fMRI) Develop treatments – Create and parse connected graphs Research – Simulating an environment or reaction (protein folding) – Deriving probabilities of dependent states

8 Transcribe DNA Identify genomic positions Parse a BLAST report

9 Piano Roll, Sewing loom punch cards (1800) FORTRAN (1940s) C++, PERL (1980s) Ruby, Python (1990s) Go, C#, Clojure (2000s)

10 Write Code Computer Interprets Programmed Results

11 A text editor to store commands (code) in a text (source) file – We will use notepad ++ A command line to talk to the computer (execute code) – We’ll use cygwin to call Perl on our code Cygwin Perl Notepad++

12 Edit source file Save Execute source file (run) View results Repeat

13 Edit source file Save Execute source file (run) View results Repeat Notepad++

14 Edit source file Save Execute source file (run) View results Repeat Notepad++ Cygwin Perl

15 Edit source file Save Execute source file (run) View results Repeat Notepad++ Cygwin Perl

16 1. Launch Cygwin from the desktop 2. Type (all on one line): hyphen q big o hyphen wget -qO- http://euler.phys.cmu.edu/wforan1/sams/get.sh | bashhttp://euler.phys.cmu.edu/wforan1/sams/get.sh This will retrieve all the code and launch notepad++

17 Use “hot corners” to organize the command line and the text editor

18 In Cygwin Change directory to codecd code List Filesls Execute 00_start_here.pl perl 00_start_here.pl OR try “tab completion” perl 0push tab button In notepad Edit fileedit between the “ and ” Save fileFile->Save OR Ctrl+S Re-Runperl 00_start_here.pl OR perl 0push tab

19 In Cygwin Change directory to codecd code List Filesls Execute 00_start_here.pl perl 00_start_here.pl OR try “tab completion” perl 0push tab button In notepad Edit fileedit between the “ and ” Save fileFile->Save OR Ctrl+S Re-Runperl 00_start_here.pl OR perl 0push tab

20 In Cygwin Change directory to codecd code List Filesls Execute 00_start_here.pl perl 00_start_here.pl OR try “tab completion” perl 0push tab button In notepad Edit fileedit between the “ and ” Save fileFile->Save OR Ctrl+S Re-Runperl 00_start_here.pl OR perl 0push tab

21 In Cygwin Change directory to codecd code List Filesls Execute 00_start_here.pl perl 00_start_here.pl OR try “tab completion” perl 0push tab button In notepad Edit fileedit between the “ and ” Save fileFile->Save OR Ctrl+S Re-Runperl 00_start_here.pl OR perl 0push tab

22 RunEdit and SaveRun CygwinNotepad++Cygwin perl 00_start_here.plCtrl+Sperl 00_start_here.pl

23 SAVE your changes before RUNNING every time you edit your file and want to run it save or the new code will not run (it’s not saved!) In a string of text always remember to close your quotation marks: “ bioinformatics” “ ”, ( ), and { } should exist in pairs Always remember the ; semicolon at the end of each command.

24 In notepad++, replace the first (and only) line with: print scalar reverse (“TTGAGC”); What happened? Why is this not the reverse complement? Edit and SaveRun Notepad++Cygwin Ctrl+Sperl 00_start_here.pl

25 We’ve only looked at executing one line code We need a bit more “fluff” for more complicated programs Lets check out how Perl code usually start

26 Open file boiler.pl Open Notepad++ Ctrl+O OR File->Open Select boiler.pl

27 Open file boiler.pl Open Notepad++ Ctrl+O OR File->Open Select boiler.pl

28 Open file boiler.pl #! is a “shebang” or “hashbang” – It directs the computer to the interpreter (PERL) use tells Perl to use a package. – warnings and strict help report errors Statements are ended with ; anything after a “#” is not seen by the computer (called a comment) Open Notepad++ Ctrl+O OR File->Open Select boiler.pl

29 We’re ready to look at some examples of – Variables my $variable – Conditionals if( ){ } else{ } – Input capture Try to determine the output of the follow code

30

31

32 wforan1@ug142 ~/code $ perl variable.pl Pyrimidine contains 2 nitrogen atoms on its ring(s)

33

34 wforan1@ug142 ~/code $ perl variable.pl Pyrimidine contains 2 nitrogen atoms on its ring(s) wforan1@ug142 ~/code $ perl variable.pl Purine contains 4 nitrogen atoms on its ring(s)

35

36

37

38

39 We are going to transcribe DNA to RNA This will require – changing the directory in cygwin – Opening a file in a new directory with notepad++ – And exploring unknown code Listen to the instructions first, then proceed – Visit the URL for more precise directions http://malaria.phys.cmu.edu/ sams/exercise/3-1.html

40 1.Run exercise (go to home directory) – cd ~ (go to exercise dir) – cd exercise/code/dna2rna/ (list files, check for dna2rna.pl) – ls (run exercise1 program) – perl dna2rna.pl (use this sequence file) enter sequence.txt http://malaria.phys.cmu.edu/ sams/exercise/3-1.html

41 1.Run exercise (go to home directory) – cd ~ (go to exercise dir) – cd exercise/code/dna2rna/ (list files, check for dna2rna.pl) – ls (run exercise1 program) – perl dna2rna.pl (use this sequence file) enter sequence.txt http://malaria.phys.cmu.edu/ sams/exercise/3-1.html 2. Open exercise file in notepad++ Ctrl+o (file->open) ; Go back one directory, then click on exercises then code then dna2rna Open dna2rna.pl

42 1.Run exercise (go to home directory) – cd ~ (go to exercise dir) – cd exercise/code/dna2rna/ (list files, check for dna2rna.pl) – ls (run exercise1 program) – perl dna2rna.pl (use this sequence file) enter sequence.txt http://malaria.phys.cmu.edu/ sams/exercise/3-1.html 2. Open exercise file in notepad++ Ctrl+o (file->open) ; Go back one directory, then click on exercises then code then dna2rna Open dna2rna.pl 3. Look for unfamiliar code 1. What is unfamiliar 2. What does it do

43 Background – Remember gene structure? (intron, exon, intergenic) – We will use human X chromosome. What is significant about this chromosome? Requires “print” and using defined variables my $variable = “badfadfy9osudlfj”; print “my variable is $variable,”; http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html

44 Open http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Steps 1 and 2 are already completed for you (chrX has been downloaded)

45 http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Open http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Steps 1 and 2 are already completed for you (chrX has been downloaded) Step 3-4: cd and run

46 http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Open http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Steps 1 and 2 are already completed for you (chrX has been downloaded) Step 5: open and edit the help message Step 3-4: cd and run

47 http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Open http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Steps 1 and 2 are already completed for you (chrX has been downloaded) Steps 6: get position status Step 5: open and edit the help message Step 3-4: cd and run

48 http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Open http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html http://malaria.phys.cmu.edu/ outreach/exercise/3-2.html Steps 1 and 2 are already completed for you (chrX has been downloaded) Steps 6: get position status Step 5: open and edit the help message Step 3-4: cd and run Step 7: modify output

49 We are going to parse a BLAST report First, we need to save a BLAST search for ATATGCGTGCTAGTGCAGTGGGTGGTAGCGTGAATGC to C:\cygwin\home\[username]\exercise\code\blast as blast_report Now we can code! http://malaria.phys.cmu.edu/ outreach/exercise/3-3.html

50 3. cd 4. run 5. Print all less than 100% 6. Modify the output to display something different

51 Declare variables – my $numRight = 0; my $userIn; Print question – print “What is my favorite color? “; Get input – $userIn = ; chomp($userIn); Count correct answers – if($userIn eq “pink”){ $numRight+=1} Tell the player how many they got right – print “You got $numRight correct\n”; BONUS: Give percent right – print $numRight/3; BONUS: Count the number wrong


Download ppt "Why? – Examples Speaking Computer-ise – How – What – Environment (windows) Basic Instructions – Declare – Conditional – Loop – Input Write a quiz game."

Similar presentations


Ads by Google