Introductory Perl for Bioinformatics Crash Course in Perl

Introductory Perl For Bioinformatics Crash Course In Perl-Free PDF

  • Date:05 Apr 2020
  • Views:62
  • Downloads:1
  • Pages:20
  • Size:736.07 KB

Share Pdf : Introductory Perl For Bioinformatics Crash Course In Perl

Download and Preview : Introductory Perl For Bioinformatics Crash Course In Perl

Report CopyRight/DMCA Form For : Introductory Perl For Bioinformatics Crash Course In Perl


Why Use Perl,1 Perl is easier to learn,2 Perl is powerful. Quickly process text like the letters A C G T,3 Perl is free. Runs on any computer,4 Peer Pressure Everybody s doin it. Individual results may vary,The Basic Container of Perl Scalars. How do you store stuff in Perl,Single pieces of data are stored in variables.
Variables in Perl are called scalar variables, You can always tell a scalar because it starts with. blip This is a scalar variable,blip 3 14 blip has been assigned a value. blip Swordmonkey blip has been assigned a different value. A scalar variable can be assigned just about anything including. A numeric value 0 0 3 343232 0 99301 etc,A single character a 3 etc. A series of characters aka as string Swordmonkey Damian Fermin. Another variable varA 4 0, Other data types in Perl will deal with this later. Assigning Values to a Scalar,var1 0 034,var2 Damian Fermin.
var3 I hate this class,What does var4 have, How to print the contents of a variable to the screen. n is the new line character, print command allows you You put it where ever you want to start. to print stuff to the screen a new line,print var1 contains var1 n. print var2 contains var2 n,print var3 contains var3 n. print var4 contains var4 n,is the end of line,You put it at the end of.
every complete line of perl, Always start and end your print statements with quotes. Example Perl Script Using Scalar Variables,usr bin perl w. Example script using Scalar Variables, var2 Damian Assigning initial values to scalar variables. money 1 43,print Hello my name is var1 n,print I am var2 feet tall n. print I paid money dollars for this haircut n,Printing variables to screen.
What you get when you run this script Screen Output. Hello my name is Damian,I am 6 feet tall,I paid 1 43 dollars for this haircut. Basic Structure of a Perl Script,Line Num Perl Code What the line is. 1 usr bin perl Shebang Line,2 A simple script A comment. 3 name Damian Assignment of a variable,4 height 6 Assignment of a variable. 5 print Hello my name is name n Printing text an embedded variable. 6 print I am height feet tall n Printing text and embedded variable. 7 exit End of Program,Screen Output,Hello my name is Damian.
I am 6 feet tall,Practice at using Scalars in Perl. usr bin perl w,Example script using Scalar Variables. name Damian,areaCode 734,airSpeed I don t know,print n nMy name is name n. print My area code is areaCode n, print Maximum air speed velocity of an African Swallow airSpeed n n. What s the output My name is Damian,My area code is 734.
Maximum air speed velocity of an African Swallow I don t know. Array The Sequential Storage Container, An array is a collection of scalar variables stored sequentially. Syntax arrayName,Order is important in an array, An array can hold any type of scalar variable data. Each piece of data is stored in a specific memory location called an element. Array elements have addresses that ALWAYS start at 0. Each element address is called an index, Example of an Array ary1 55 0 42 10023 39 apple 993 Y toga party. How the data of ary1 is stored,Element Number index 0 1 2 3 4 5 6. Scalar Contents 55 0 42 10023 39 apple 993 Y toga party. You can access individual elements of an array, To do this you need to specify the exact element number you want.
Prints this to, print ary 6 contains ary 6 ary 6 contains toga party. the screen,Practice Using Arrays,usr bin perl,Example using Array. ary1 55 0 42 10023 39 apple 993 Y toga party,print n nContents of ary1 n. print ary1 0 ary1 0 n,print ary1 1 ary1 1 n,print ary1 2 ary1 2 n. print ary1 3 ary1 3 n,Output Contents of ary1,ary1 1 0 42.
ary1 2 10023 39,ary1 3 apple,Special Functions Reserved for Arrays. push Function used to add something to the END of an array. Syntax push ary1 scalar1,What s in newAry,var1 2 wet burrito. var2 wet burrito 1 002,ary1 1 002 3 220 4 005 3 22. newAry 4 005,push newAry var1,push newAry var2,push newAry ary1 What s in ary1 now. push ary1 var2 1 002,wet burrito, pop Function to pop off an element from the END of an array.
Element that is removed can be immediately assigned to another variable. Syntax pop arrayName Current Contents of newAry,wet burrito. Example 1 002,var1 2 4 005,var2 wet burrito,ary1 1 002 3 220 4 005 What does temp contain now. newAry temp 4 005,push newAry var1,push newAry var2. push newAry ary1,What does newAry contain now,temp pop newAry 2. wet burrito,To pop data off the front use shift command 3 22.
Associative Arrays aka Hashes,Do NOT store data in a sequential manner. Order is unimportant,Data is stored with a key value format. Each key is associated with exactly one value, Keys can be any scalar data letters numbers words etc. Syntax hashName,Two ways to initialize a hash with data. key value myHash key value key value,Real life example Internal Revenue Service.
You re a number not a name,Example keys,myHash values. name Damian,dept Basket Weaving,fruit tomato,You can access any value using its key. Syntax for assigning retrieving an individual value using a key. Retrieve myHash dept Returns Basket Weaving, Assign myHash dept Bioinformatics Assigns Bioinformatics. to the key dept,Special keywords for Hashes, You can retrieve just the keys of a hash or just the values of a hash using the keywords. keys and values respectively More on this later,Difference Between Array and a Hash.
How a Hash Stores Data How an Array Stores Data,key2 Index Data. value1 0 element0,1 element1,key3 2 element2, Data is not stored sequentially Data is stored sequentially. You can only get to data using a key You can get to data by knowing its index. Practice Using Hashes,usr bin perl w,Example using Hashes. name Damian Name Damian,dept Basket Weaving Department Basket Weaving. zipCode 48108 Zip Code 48108,print n nName myHash name n.
print Department myHash dept n,print Zip Code myHash zipCode n. Introductory Perl for Bioinformatics University of Michigan Program in Bioinformatics Summer Short Course 2003 Instructor Damian Fermin Crash Course in Perl

Related Books