生物資訊程式設(shè)計實習(xí)(二)_第1頁
生物資訊程式設(shè)計實習(xí)(二)_第2頁
生物資訊程式設(shè)計實習(xí)(二)_第3頁
生物資訊程式設(shè)計實習(xí)(二)_第4頁
生物資訊程式設(shè)計實習(xí)(二)_第5頁
已閱讀5頁,還剩72頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、96-Summer生物資訊程式設(shè)計實習(xí)(二)Bioinformatics with Perl8/138/22 蘇中才8/248/29 張?zhí)旌?/31 曾宇鳯1ScheduleDateTimeSubjectSpeaker8/13 一13:3017:30Perl Basics蘇中才8/15 三13:3017:30Programming Basics蘇中才8/17 五13:3017:30Regular expression蘇中才8/20 一13:3017:30Retrieving Data from Protein Sequence Database蘇中才8/22 三13:3017:30Perl c

2、ombines with Genbank, BLAST蘇中才8/24 五13:3017:30PDB database and structure files張?zhí)旌?/27 一8:3012:30Extracting ATOM information張?zhí)旌?/27 一13:3017:30Mapping of Protein Sequence IDs and Structure IDs張?zhí)旌?/31五13:3017:30Final and Examination曾宇鳳2Reference BooksLearning Perl(Perl 學(xué)習(xí)手冊)Beginning Perl for Bioinfor

3、maticsBioinformatics Biocomputing and Perl: An Introduction to Bioinformatics Computing Skills and Practice34Learning Perl5PerlPractical Extraction and Report LanguageCreated by Larry Wall in the middle 1980s.Suitable for “quick-and-dirty”Suitable for string-handlingPowerful regular expression6Prepa

4、rationDownloading putty.exe / pietty.exeGetting materials for this course: Server: ssh 86Id : course1 course20Password:7Installing Perl on WindowsDownload package fromVersions of PerlUnix, Linux, Windows (ActivePerl), Mac (MacPerl)8Text EditorsA convenient (text) editor for programmingUl

5、traedit: good for meNotepad: just an editorVim: UNIX/Linux loverJoe : easy to use for Unix beginner9Finding HelpBest resource finding tool On-line Resources, useHTML Help in ActivePerlCommand Line (highly recommended)perldoc f # search functionperldoc q # search FAQperldoc # search moduleperldoc per

6、ldoc10Perl BasicStarting11$ vi welcome#! /usr/bin/perl -wprint “Hello, worldn”;$ chmod +x welcome$ ./welcomeHello, world$ perl welcomeHello, worldProgram: run thyself!sbbgene perl$ ls -al-rw-rw-r- 1 sbb sbb 20 Jul 2 15:27 welcomesbbgene perl$ chmod +x welcomesbbgene perl$ ls -al-rwxrwxr-x 1 sbb sbb

7、20 Jul 2 15:27 welcome12#! /usr/bin/perl -w# The forever program - a (Perl) program,# which does not stop until someone presses Ctrl-C.use constant TRUE = 1;use constant FALSE = 0;while ( TRUE ) print Welcome to the Wonderful World of Bioinformatics!n; sleep 1;Using the Perl while construct13$ chmod

8、 +x forever$ ./foreverWelcome to the Wonderful World of Bioinformatics!Welcome to the Wonderful World of Bioinformatics!Welcome to the Wonderful World of Bioinformatics!Welcome to the Wonderful World of Bioinformatics!Welcome to the Wonderful World of Bioinformatics!Welcome to the Wonderful World of

9、 Bioinformatics!Welcome to the Wonderful World of Bioinformatics!Welcome to the Wonderful World of Bioinformatics!Welcome to the Wonderful World of Bioinformatics!.Running forever . 14Perl BasicVariables15VariablesScalar ($)Number1; 1.23; 12e34String“abc”; ABC ; “Hello, world!”;Array / List ()Hash (

10、%)16Introducing variable containersThe simplest type of variable container is the scalar (純量).In Perl, scalars can hold, for example, a number, a word, a sentence or a disk-file.$name$_address$programming_101$z$abc$swissprot_to_interpro_mapping$SwissProt2InterProMappingVariable naming is ART !17scal

11、ar#!/usr/bin/perl -w# lower case for user defined ; upper case for system defaultmy $ARGV = “example.pl;my $number = 1.2;my $string = Hello, world!;my $123 = 123;#errormy $abc = 123;my $_123 = 123;my $O000OoO00 = 1;my $OO00Oo000 = 2;my $OO00OoOOO = 3;$abc = $O000OoO00 * $OO00Oo000 - $OO00OoOOO;print

12、 $abc x 4 . n;print 5 x 4 . n;print 5 * 4 . n;18NumberFormat (range: 1e-100 1e100 ?)20001.25-6.5e45 (-6.5*1045)123456789123_456_789Other format0377 #octal (decimal 255)0 xFF #hexadecimal0b11111111#binary19number$integer = 12;$real = 12.34;$oct = 0377;$bin = 0b11111111;$hex = 0 xff;$long = 123456789;

13、$long_ = 123_456_789;$large = 1E100;#1E200$small = 1E-100;#1E-200print integer : $integern;print real : $realn;print oct=$oct bin=$bin hex=$hexn;#printf(oct=0%o bin=0b%b hex=0 x%xn,$oct,$bin,$hex);20parameters of printf (ref : number)21operator2 + 3#55.1 2.4#2.73 * 12#3614 / 2#710.2 / 0.3#3410 / 3#3

14、.33310 % 3#122OperatorOperatorFunction+Addition-Subtraction, Negative Numbers, Unary Negation*Multiplication/Division%Modulus*ExponentOperatorFunction=Normal Assignment+=Add and Assign-=Subtract and Assign*=Multiply and Assign/=Divide and Assign%=Modulus and Assign*=Exponent and Assign$number = $num

15、ber + 100; $number += 100;23Take a break modulus10.5 % 3.2 = ?exponentiation23 = ?24stringFormatSingle quoteshellohellonhellohello,$nameDouble quotes“hello”“hellonhello”“hello,$name”Exceptions“”#!/usr/bin/perl wprint hello;print “hello”;25Backslash escapes26conversion between String and number$answe

16、r = “Hello ” . “ “ . “ worldn”;$answer = “12” . “3”;$answer = “12” * “3”;$answer = “12Hello34” * “3”;#warning !$answer = “A” . 3*5;$answer = “A” x (3*5);$answer = “12”x”3”;27#! /usr/bin/perl -w# The tentimes program - a (Perl) program,# which stops after ten iterations.use constant HOWMANY = 10;$cou

17、nt = 0;while ( $count 1;use constant FALSE = 0;use constant HOWMANY = 5;$count = 0;while ( TRUE ) $count+; print Welcome to the Wonderful World of Bioinformatics!n; if ( $count = HOWMANY ) last; Using the Perl if construct30#! /usr/bin/perl -w# The oddeven program.use constant HOWMANY = 4;$count = 0

18、;while ( $count HOWMANY ) $count+; if ( $count % 2 = 0 ) print “$count : evenn; else # $count % 2 is not zero. print “$count : oddn; The oddeven program31Comparison operatorComparisonNumberStringEqual=eqNot equal!=neLess thangtLess than or equal=geComparisoncmp32Variable Interpolation#! /usr/bin/per

19、l -w# The interpolation program which interpolate variables by variable.$language = “Perl”;$string = “I love $language”; print $string.”n”;$string = I love $language”; print $string.”n”;$string = I love .$language; print $string.”n”;$string = “I love $language”; print $string.”n”;$string = “I love $

20、languages”; print $string.”n”; #$languages33list_of_sequencestotalsprotein_structures( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA )list_of_sequences = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA );Arrays: Associating Data With Numbers34The list_of_sequences Array35print $list_of_sequences1n;GCTCAGTTCT$list_of_sequ

21、ences1 = CTATGCGGTA;$list_of_sequences3 = GGTCCATGAA;Working with array elements36The Grown list_of_sequences Array37print The array size is: , $#list_of_sequences+1, .n;print The array size is: , scalar list_of_sequences, .n;The array size is: 4.How big is the array?38sequences = ( TTATTATGTT, GCTC

22、AGTTCT, GACCTCTTAA );sequences = ( sequences, CTATGCGGTA );print sequencesn;TTATTATGTT GCTCAGTTCT GACCTCTTAA CTATGCGGTAsequences = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA );sequences = ( CTATGCGGTA );print sequencesn;CTATGCGGTAAdding elements to an array39sequences = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTA

23、A );sequences = ( sequences, ( CTATGCGGTA, CTATTATGTC ) );print sequencesn;TTATTATGTT GCTCAGTTCT GACCTCTTAA CTATGCGGTA CTATTATGTC sequence_1 = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA );sequence_2 = ( GCTCAGTTCT, GACCTCTTAA );combined_sequences = ( sequence_1, sequence_2 );print combined_sequencesn;TTAT

24、TATGTT GCTCAGTTCT GACCTCTTAA GCTCAGTTCT GACCTCTTAAAdding more elements to an array40sequences = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA, TTATTATGTT );removed_elements = splice sequences, 1, 2;print removed_elementsn;print sequencesn;GCTCAGTTCT GACCTCTTAATTATTATGTT TTATTATGTT#clean all elements of an ar

25、raysequences = (); Removing elements from an array41#! /usr/bin/perl -w# The slices program - slicing arrays.sequences = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA, CTATGCGGTA, ATCTGACCTC );print sequencesnn;seq_slice = sequences 1 . 3 ;print seq_slicen;print sequencesnn;removed = splice sequences, 1, 3;p

26、rint sequencesn;print removedn;The slices program42TTATTATGTT GCTCAGTTCT GACCTCTTAA CTATGCGGTA ATCTGACCTCGCTCAGTTCT GACCTCTTAA CTATGCGGTATTATTATGTT GCTCAGTTCT GACCTCTTAA CTATGCGGTA ATCTGACCTCTTATTATGTT ATCTGACCTCGCTCAGTTCT GACCTCTTAA CTATGCGGTAResults from slices . 43#! /usr/bin/perl -w# The iterate

27、W program - iterate over an entire array # with while.sequences = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA, CTATGCGGTA, ATCTGACCTC );$index = 0;$last_index = $#sequences;while ( $index = $last_index ) print $sequences $index n; +$index;Processing every element in an array44TTATTATGTTGCTCAGTTCTGACCTCTTAA

28、CTATGCGGTAATCTGACCTCResults from iterateW . 45#! /usr/bin/perl -w# The iterateF program - iterate over an entire array # with foreach.sequences = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA, CTATGCGGTA, ATCTGACCTC );foreach $value ( sequences ) print $valuen;The iterateF program46sequences = ( TTATTATGTT,

29、GCTCAGTTCT, GACCTCTTAA, CTATGCGGTA, ATCTGACCTC );sequences = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA, CTATGCGGTA, ATCTGACCTC );sequences = qw( TTATTATGTT GCTCAGTTCT GACCTCTTAA CTATGCGGTA ATCTGACCTC );Making lists easier to work with47Quoted words#!/usr/bin/perl -w# The quoted_words programlist_of_seque

30、nces = ( TTATTATGTT, GCTCAGTTCT, GACCTCTTAA );list_of_sequences = qw/TTATTATGTT GCTCAGTTCT GACCTCTTAA/;list_of_sequences = qwTTATTATGTT GCTCAGTTCT GACCTCTTAA;list_of_sequences = qw!TTATTATGTT GCTCAGTTCT GACCTCTTAA!;list_of_sequences = qwTTATTATGTT GCTCAGTTCT GACCTCTTAA;list_of_sequences = qw;list_of

31、_sequences = qw#TTATTATGTT GCTCAGTTCT GACCTCTTAA#;print list_of_sequencesn;print The array size is: , $#list_of_sequences+1, .n;48pop/push/shift/unshift#!/usr/bin/perl -w#The “array_operator” programarray = 5.9;print array = arrayn;$item = pop array;print item = $itemn;print array = arrayn;push arra

32、y, 9;print array = arrayn;$item = shift array;print item = $itemn;print array = arrayn;unshift array, 1.5;print array = arrayn;49pop/push/shift/unshiftarray = 5 6 7 8 9=pop=item = 9array = 5 6 7 8=push 9=array = 5 6 7 8 9=shift=item = 5array = 6 7 8 9=unshift 1.5=array = 1 2 3 4 5 6 7 8 950reverse /

33、 sort#!/usr/bin/perl -w#The “array_operator1” programarray = qw /5 4 9 8 1 3 6 2 7 10/;print array = arrayn;array_reverse = reverse array;print reverse array = array_reversen;array_sorted = sort array;print sort array = array_sortedn;array_reversesorted = reverse sort array;print reverse sort array

34、= array_reversesortedn;array_sortedreverse = sort reverse array;print sort reverse array = array_sortedreversen;51reverse / sortarray = 5 4 9 8 1 3 6 2 7 10=reverse array = 10 7 2 6 3 1 8 9 4 5=sort array = 1 10 2 3 4 5 6 7 8 9=reverse sort array = 9 8 7 6 5 4 3 2 10 1=sort reverse array = 1 10 2 3

35、4 5 6 7 8 952split/join#!/usr/bin/perl -w#The “array_operator2” program - join / split$string = 5 4 9 8 1 3 6 2 7 10;array = split/ /, $string;print array = arrayn;$string = join , array;print array = $stringn;array = 5 4 9 8 1 3 6 2 7 10array = 5,4,9,8,1,3,6,2,7,1053How to map between IP and domain

36、 name ?IPDomain .tw54Use 2 array to map between IP and domain name ?IP869190Domain_.tw01201255

37、How to search a certain ip or domain name ?IP869190Domain_.tw01201256Why Hash ?%Domain_.tw869190Key

38、Value 57How to get a certain domain name?%Domain_.tw869190Key Value $Domain_name“86”58Examples of Hash59Hashes: Associating Data With Words%nucleotide_bases%nucleotide_bases = ( A, Adenine

39、, T, Thymine );%nucleotide_based = ( A = Adenine, T = Thymine);keyvalue60print The expanded name for A is $nucleotide_bases A n;The expanded name for A is AdenineWorking with hash entries61%nucleotide_bases = ( A, Adenine, T, Thymine );hash_names = keys %nucleotide_bases;print The names in the %nucl

40、eotide_bases hash are: hash_namesn;The names in the %nucleotide_bases hash are: A T%nucleotide_bases = ( A, Adenine, T, Thymine );$hash_size = keys %nucleotide_bases;print The size of the %nucleotide_bases hash is: $hash_sizen;The size of the %nucleotide_bases hash is: 2How big is the hash?62$nucleo

41、tide_bases G = Guanine; $nucleotide_bases C = Cytosine;%nucleotide_bases = ( A = Adenine, T = Thymine, G = Guanine, C = Cytosine );Adding entries to a hash63The Grown %nucleotide_bases Hash64delete $nucleotide_bases C ;$nucleotide_bases C = undef;Removing entries from a hash65#! /usr/bin/perl -w# Th

42、e slicing_hashes program extract a certain subset among a hash %gene_counts = ( Human = 31000, Thale cress = 26000, Nematode worm = 18000, Fruit fly = 13000, Yeast = 6000, Tuberculosis microbe = 4000 );counts = gene_counts Human, “Fruit fly”, Tuberculosis microbe ;print countsn;Slicing hashes31000 1

43、3000 400066#! /usr/bin/perl -w# The bases program - a hash of the nucleotide bases.%nucleotide_bases = ( A = Adenine, T = Thymine, G = Guanine, C = Cytosine );$sequence = CTATGCGGTA;print nThe sequence is $sequence, which expands to:nn;while ( $sequence = /(.)/g ) print t$nucleotide_bases $1 n;Worki

44、ng with hash entries: a complete example67The sequence is CTATGCGGTA, which expands to:CytosineThymineAdenineThymineGuanineCytosineGuanineGuanineThymineAdenineResults from bases . 68#! /usr/bin/perl -w# The genes program - a hash of gene counts.use constant LINE_LENGTH = 60;%gene_counts = ( Human =

45、31000, Thale cress = 26000, Nematode worm = 18000, Fruit fly = 13000, Yeast = 6000, Tuberculosis microbe = 4000 );Processing every entry in a hash69print - x LINE_LENGTH, n;while ( ( $genome, $count ) = each %gene_counts ) print $genome has a gene count of $countn;print - x LINE_LENGTH, n;foreach $genome ( sort keys %gene_counts ) print $genome has a gene count of $gene_counts $genome n;print - x LINE_LENGTH, n;The genes program, cont.70-Human has a gene count of 31000Tuberculosis microbe has a gene count of 4000Fruit fly has a gene cou

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論