印度昌迪加尔市微生物技术研究所生物信息学课件_第1页
印度昌迪加尔市微生物技术研究所生物信息学课件_第2页
印度昌迪加尔市微生物技术研究所生物信息学课件_第3页
印度昌迪加尔市微生物技术研究所生物信息学课件_第4页
印度昌迪加尔市微生物技术研究所生物信息学课件_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Introduction to Perl & BioPerlDr G. P. S. Raghava Bioinformatics CentreIMTECH, ChandigarhEmail: raghavaimtech.res.inWeb: Perl IntroductionUsesShell scriptsCGI, web enginesGood atText processingSmall/Medium sized projectsQuick and dirty solutionsPortability (to a certain degree)PerlPractical Extracti

2、on and Report LanguageCreated by Larry WallRuns on just about every platformMost popular on Unix/Linux systemsExcellent language for file and data processingBasic ConceptsPerl files extension .PlCan create self executing scriptsAdvantage of PerlCan use system commandsComment entryPrint stuff on scre

3、enSimple Program#!/usr/local/bin/perl# This is a comment line. This program prints “Hello World.”# to the screen.print “Hello world.n”;On Unix, this is the location of the Perl interpreterComments start with # and end with the end of the lineProgram statements are terminated with semicolonsNewline c

4、haracterHow to Store ValuesScalar variablesList variablesPush,pop,shift,unshift,reverseHashes,keys,values,eachRead from terminal, command line argumentsRead and write to filesPerl Data TypesThree Main DatatypesScalarA single number, string or reference.$society = “Redbrick”;ListA collection of scala

5、r datatypes.societies = ( “RB”, “Drama”, “Film”);Length of an array with “scalar list”HashPairs of scalars, accessed by keys.%hash = ( “colour” = “red”,“make” = “corvette” ); Perl Basics ifSelective evaluate blocks of code depending on a condition.If ($string eq “blah”)print “String is blahn”;elsif

6、($string eq “spoo”)Print “String is spoon”;elsePrint “What the hell?n”;Perl Basics for Practically the same as C/C+/Javafor ($i = 0; $i 10; $i+)print “i is “ . $i . “n”;Perl Basics foreachA handy way of processing a listforeach $grocery (groceries)scan($grocery);Can use the default variable ($_)fore

7、ach (groceries)scan($_);Control Structures#!/usr/local/bin/perl# Print out 0,1,2,3,4,5,6,7,8,9# in this case, $x is local only to the loop because my is usedfor (my $x = 0; $x 10; $x+) print “$x”; if ($x 9) print “,”; print “n”;Control Structures#!/usr/local/bin/perl# Demonstrate the foreach loop, w

8、hich goes through elements# in an array.my users = (“bonzo”, “gorgon”, “pluto”, “sting”);foreach $user (users) print “$user is alright.n”;FunctionsUse sub to create a function.No named formal parameters, assign _ to local subroutine variables.#!/usr/local/bin/perl# Subroutine for calculating the max

9、imumsub max my $max = shift(_); # shift removes the first value from _ foreach $val (_) $max = $val if $max filename.txt” Truncate and write to file.“filename.txt” Append to file.Perl File I/O - ReadReading$string = ;list = ;while ($string = )print “LINE : “ . $string;Perl File I/O - WriteWriting to

10、 a file.print FILEHANDLE “Hello”;foreach $item (list)print FILEHANDLE $item;foreach (list)print FILEHANDLE;FilesFile handles are used to access filesopen and close functions#!/usr/local/bin/perl# Open a file and print its contents to copy.txtmy $filename = $ARGV0;open(MYFILE, “$filename”); # indicat

11、es writeopen(OUTPUT, “copy.txt”);while ($line = ) # The operator reads a line print OUTPUT $line; # no newline is needed, read from fileclose MYFILE; # Parenthesis are optionalPlatformsHP-UX / Itanium (ia64) 11.0 HP-UX / PA-RISC 11.0 MacOSMacOS XCygWin NT_5 v. 1.3.10 on Windows 2000 5.00 Win32, WinNT i386 IRIX64 6.5 SGI Solaris 2.8 UltraSparc OpenBSD 2.8 i386 RedHat Linux 7.2 i686 Linux i386 Perl CGI Example #!/usr/bin/perl w# My Third Perl script.# I call this scr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论