New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here


by: Vivienne Dickens


Vivienne Dickens
Virginia Commonwealth University
GPA 3.73


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in BioInformatics

This 7 page Class Notes was uploaded by Vivienne Dickens on Wednesday October 28, 2015. The Class Notes belongs to BNFO 601 at Virginia Commonwealth University taught by Staff in Fall. Since its upload, it has received 13 views. For similar materials see /class/230696/bnfo-601-virginia-commonwealth-university in BioInformatics at Virginia Commonwealth University.

Similar to BNFO 601 at Virginia Commonwealth University




Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/28/15
Version 8272005 304 PNI BNFO 601 Integrated Bioinformatics Introduction to Personal Programming Part 1 There is a wide range of experience amongst you reading these notes Some have a passing acquaintance with Perl Some have no acquaintance with Perl but considerable programming experience Some have no programming experience Ideally there would be notes tailored to each of your individual needs but until true machine intelligence becomes a reality we39re limited by my meager resources So I 39ve tried to make this one version of the notes serve multiple purposes Those with a great deal of programming experience might skim the notes and focus on the yellow boxes that appear periodically You may be able to use them to grasp the essential di erences between Perl and languages with which you are already familiar The rest of the notes are pitched primarily at those with little experience I Basic Considerations IA Why personal programming Computer programming is the most general and most powerful tool in bioinformatics It is the tool that makes tools One may work productively in biology without knowing how to program a computer just as one can get a lot out of a trip to China without knowing Chinese but so much more is possible with the ability to perceive the world with one s own eyes and ears and respond creatively Fortunately computer programming is easy Don t misunderstand 7 it is extraordinarily difficult to write a program that will be used on a variety of platforms by a variety of people in a way that is easy to use and idiot proof Programmers get paid a lot of money to do this sort of thing and they deserve every penny However it is quite a different matter to write a program that will be used only by yourself on your own computer and if it encounters an unforeseen situation 7 no problem you re there to deal with it Anyone who can master a natural human language can accomplish the far easier task of gaining a working knowledge of a computer language You can too Some of you know several computer languages Others don t know any None of us are masters of the computer language called Perl though some have a passing acquaintance By the end of this summer all of you should be able to understand a wellwritten program in Perl and to make modifications in it to suit your needs It would be nice if you could also write certain kinds of programs from scratch but that may be beyond what we can accomplish in our limited time It is not the primary goal ot this course to teach Perl Rather we will use programs written in Perl as teaching aids windows into the concepts and tools that underlie your research projects IB How to learn a programming language Undoubtedly the most effective way to learn a language is to use it exploring the limits of all that is new to you It follows that your first important step in learning Perl is to gain access to the language Fortunately Perl is free and readily available To get it go to the Resources amp Links section of the course web page You39ll probably be much happier using an editor to input programs as it will help you identify inevitable errors You can get a free editor from a link on the same page but many other editors are also available You can also write programs using any text editor eg Notepad supplied by Windows The rest of these notes presumes that you have already downloaded and installed Perl IC What are computer languages Knowing nothing of the languages of the Mowri or Basque you may nonetheless I 7 3 feel certain that they possess 39 5 4 3 80 81 words that describe hunger and 7 79 any other condition at the core of human experience So it is with 3 8 computer languages All must 6 6 9 7 2 manipulate the same machine 7 the digital computer 7 and so all must share certain capabilities For our purposes we may imagine the computer as a very long string of boxes each box containing a number its contents and identi ed by a different number its address Programs can put things into specific boxes take things out of specific boxes and manipulate the contents of boxes in a variety of ways The program can interpret the numbers in the boxes as parts of larger numbers as letters or most powerfully as instructions how to manipulate the contents of other boxes 0 9 757677 73 O 7 769 32768 Any computer language must at minimum be able to do the following Put information into specific locations in memory Take information from specific locations in memory Manipulate the data in certain ways eg arithmetic Allow instructions to be executed in a defined order Allow instructions to be executed only if certain conditions are met Allow blocks of code to be reused Communicate with peripheral devices e g the screen a disk or a printer In addition languages may have particular set of peculiarities and strengths For Perl one outstanding strength is its ability to strings l of 39 It39s not so good in number crunching ID How to run a Perl program 1 Using Notepad within Windows Copy and paste the following oneline program into Notepad and save it as printpl print quotI am Samquot Get to a DOS prompt by doing one of the following 0 Click on a DOS icon 0 Click the S TART button then Run then type command and press Enter 0 Click the S TART button then Run then type command and press Enter Typeperl printplandp mSEnter 2 Using the EnginSite Perl script editor Launch the editor Click File New Copy and paste the following oneline program into the upper large window below the default rst line print quotI am Samquot 0 Click Run Syntax check and if syntax is OK then click Run STDOUT only 3 Running within a LinuxUnixOS X environment Copy and save the following as a text file lusrlocalbinperl print quotI am Samquot Click on the file you created or at a unixlinux prompt invoke the file II Elements of Perl IIA Perl commands Play with the program you just ran I39ll give an example here of what quotplayquot means Henceforth play with everything new you encounter 1 Run the program print quotI am Samquot You should get output similar to I am Sam 2 What is the role of the word quotprintquot Delete quotprintquot from the program and rerun it The output should now be gone but otherwise no harm seems to be done 9 Modify the program by adding a new line as follows use warnings quotI am Samquot Now running this program produces the warning Useless use of a constant in void context at temppl line 2 V39 0 apes Evidently Perl considers the contents of line 2 quotI am Sam quot to be a constant and to be useless under the circumstances Put quotprintquot back into the program retaining use warnings Now the output is back and the warning is gone From this you learn that the command print evidently is necessary for Perl to know enough to print the given message you re probably not surprised by this By the way from this moment on always begin programs with the command use warnings This directs Perl to advise you as well as it can of potential problems it sees in your programs Try the following similar program use warnings print quotI am Samquot and the following program use warnings print quotI am Samquot The output should not be affected From this you learn that Perl doesn39t care about extra spaces and extra lines This feature frees you to format commands as you wish in order to highlight the logic of the program Make maximal use of logical formatting In a one line program there s no need but once programs start running to multiple lines formatting is essential to maintain intelligibility Fool around with the semicolon First try adding an extra semicolon after print Then try deleting all semicolons You should have heard no complaint from Perl after the last attempt Lets move up to a slightly more complicated program use warnings print quotI am Samquot print quotand you are notquot No errors or wamigns but perhaps you re not completely satisfied with the output Fix the program so the output is more beautiful Now get rid of all the semicolons and rerun the program What is the problem How do semicolons solve the problem Put back the semicolons one at a time What rule for the use of semicolons can you infer Run the original program with the following modification use warnings print quotI am Samquot This line declares an unlikely identity Run it also with the symbol omitted You should get a particularly opaque error message Your program has totally confused Perl 12 Put the symbol back but at the beginning of the line use warnings print quotI am Samquot 13 Finally try adding the symbol to the multiline program you made earlier This line declares an unlikely identity print This line declares an unlikely identity quotI am Samquot What rule for the use of the pound Sign can you infer Playing in this way should have taught you something about Perl syntax It also may have taught you that Perl error messages and warnings are seldom very clear This is not going to change and it doesn t to any good to yell athe computer Fortunately you are a human and it is possible for you to change Note the appearance of speci c error messages and associate them with their causes In this way you ll learn that 0 Useless use of a constant in void context often indicates that a command e g print is missing 0 syntax error is often associated with missing semicolons etc IIB Perl variables 1 Run the program sentence quotI am Samquot print sentence You should get output similar to I am Sam 2 Modify the program to read x quotI am Samquot print X Try also T7am7notisam quotI am Samquot print Tiam7notisam Henceforth it is presumed thatyour program begins with a use warnings command and confused quotI am Samquot confused quotI am not Samquot sentence 47 print confused quotquot sentence quotquot Let s look at this more carefully particularly the variable Iiam7notisam Somewhere in memory there are eight consecutive boxes with the contents quot1quot quot quot quotaquot quotmquot quot quot quotSquot quotaquot and quotmquot The boxes actually contain numbers that can be decoded as letters and this fact along with the address of the first box and the total number of letters is stored elsewhere in memory in a location we can access through the variable name Iiam7notisam It39s like you look up a name in the telephone directory get the telephone number call it and some random person picks up the phone It can happen The name Is not the olllect Of course your life would be made much easier if the name in the telephone directory is related to the person at the other end of the telephone number Likewise things will be much better off if you use variable names that somehow describe the object they refer to But that s your choice The computer doesn39t care 2 Does case matter in variable names Try modifying the original program IIB1 so that the variable is spelled SENTENCE Try changing just the first instance then just the second instance then both instances 3 What is the role of the sign in variable names Delete one or both and rerun the program All scalarf variables have names marked by an initial A scalar variable is one that contains a single value as opposed to a list of values we39ll encounter those later on in these notes Legal characters for making variable names include quotAquot through quotZquot quotaquot through quot2quot quot0quot through quot9quot and quot7quot underscore not hyphen 4 Modify the original program by replacing sentence with a variety of different variable names thereby exploring the limits of what names are possible IIC Perl literals The programs in the previous section initialized variables with text within double quotation marks like quotI am Sam quot The quotation marks indicate that the words within are not to be interpreted as variables or any other symbol but are to be used as they are You should therefore be able to put anything you like between the quotes l quotscalarquot is derived from the Latin word for ladder and is supposed to evoke in your mind something that can be completely defined by its magnitude in the case of the ladder how many rungs it has In mathematics quotscalarquot stands in contrast to quotvectorquot which contains multiple elements e g magnitude and direction 1 Run the program sentence quotQWERTYUIOP l quot The second line on the keyboard print sentence You should get the second line of the keyboard printed N Now try the top line on the keyboard sentence quot l 3951 A amp 07quot The top line on the keyboard print sentence What did you get look carefully Do multiple experiments to gure out why your expectations were not met and to develop an explanation for what is going on 3 With that lesson in mind perhaps the following may make some sense x quotTNTERPOLATTONquot sentence x print sentence or perhaps of more potential utility negation quotquot print quotThis isnegation what I expected quot negation quotn39tquot print quotThis isnegation what I expectedHW You might imagine a program that printed explanation that were created depending on speci c results Text within double quotation marks are literally interpreted except when the text contains the name of a variable In that case the variable name is replaced by the value of the variable There is another exception 4 What if you want to print a message that contains quotation marks Try this print quotHere39s an example of a literal string quotI am Samquotquot Why does this program raise an error Fix program as minimally as possible so that the error goes away 5 Unless you knew something you probably didn t think of the following solution to the problem print quotHere39s an example of a literal string quotI am Samquotquot Play with the symbol trying it out in different contexts but don t try to figure out all the weird effects you may encounter The symbol serves as what is known as the quotescape characterquot It means escape from the standard interpretation of the character that follows Thus quot is not interpreted as the symbol marking the end of the string but rather as the character quot with no further implications There are two other major uses of the escape character at least as I use it n means don t interpret n as the letter 11 but rather as a newline and t means don t interpret t as the letter t but rather as a tab 6 Try out n and t in strings bounded by double quotation marks


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Janice Dongeun University of Washington

"I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.