1 / 29

Gen712/812: Module 1 – Session 1 Introduction to Perl programming for Bioinformatics

Gen712/812: Module 1 – Session 1 Introduction to Perl programming for Bioinformatics. Outline 1.0 What to expect 1.1 Introduction to programming: Hardware VS Software 1.2 Types of programming Languages 1.3 Types of Operating systems 1.4 Introduction to Linux/Unix 1.5 SSH.

dory
Download Presentation

Gen712/812: Module 1 – Session 1 Introduction to Perl programming for Bioinformatics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Gen712/812: Module 1 – Session 1Introduction to Perl programming for Bioinformatics Outline 1.0 What to expect1.1 Introduction to programming: Hardware VS Software 1.2 Types of programming Languages 1.3 Types of Operating systems 1.4 Introduction to Linux/Unix 1.5 SSH

  2. Three Modules • Introduction to Linux/Unix • working on Linux/Unix system • logging in • managing passwords • navigating the Linux/Unix file system • Core PERL • Basic language syntax • Applied PERL • Using perl to do bioinformatics

  3. 1.1 What is a Computer? • Computer • Device capable of performing computations and making logical decisions at speeds millions of times faster than human beings • Computers process data under the control of sets of instructions called computer programs, or scripts. • Has two inseparable components • Hardware • The various physical components comprising a computer • Keyboard, screen, mouse, disks, memory, • CD-ROM, central processing units • Software • Tested and working step-by-step instructions that are bundled as a unit and can run on a computer

  4. 1.2 Computer Organization Six logical units in every computer: • Input unit • Obtains information from input devices (keyboard, mouse) • Output unit • Outputs information (to screen, to printer, to control other devices) • Memory unit • Rapid access, low capacity, stores input information • Arithmetic and logic unit (ALU) • Performs arithmetic calculations and logical decisions • Central processing unit (CPU) • Supervises, coordinates and prioritizes computing jobs • Secondary storage unit • Cheap, long-term, high-capacity storage • Stores programs and data for loading and processing by ALU/CPU

  5. 1.3 Types of programming languages • Three types of programming languages • Machine languages • Strings of numbers giving machine specific instructions • Example: +1300042774 (100111101011001001010) +1400593419 (101010101111100010001) +1200274027 (100100101000010010010) • Assembly languages • English-like abbreviations representing elementary computer operations (translated via assemblers) • Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY

  6. 1.3 Types of programming languages • High-level languages Code that is: • Written in non redundant, unambiguous subset of everyday English and Mathematical notations • Human readable • Incomprehensible to computers unless translated by compiler or interpreter programs • Example: grossPay = basePay + overTimePay

  7. 1.3.1 High-level Languages • Examples of high-level languages • C, C++, C#, Java • Used for major applications in various fields • FORTRAN • Used for scientific and engineering applications • COBOL • Used to manipulate large amounts of data • Pascal • Intended for academic /instructional use • Perl, Python, Ruby … • Interpreted , good for the web applications, • Fast text and data manipulation …

  8. Introduction to Linux/Unix

  9. 1.4 Introduction to Linux/Unix • What is Linux/Unix • An architecture independent Operating system: - Multiuser - Multitasking - Secure mode *Each user restricted to his/her home directory: *Can’t access other peoples home directory • Secure login shell • Case sensitive • Uses forward slash as directory separator “/” • Prime development environment for bioinformatics software, webserver applications

  10. 1.4 Introduction to Linux/Unix • Logging in/out • Type username at prompt • Supply password when prompted • Issue exit/logout command to exit • Password resetting: • Type passwd at the command prompt • Issue current password when prompted • Issue new password when prompted • Re-issue new password to confirm • Choose a good password • Longer than six letters & digits • Mix upper case, lowercase, digit and punctuation marks

  11. 1.4.1 Linux/Unix Layers of interaction • http://www.linux-tutorial.info/modules.php?name=MContent&pageid=5

  12. Outline • Overview of the Linux System • Basic Commands • Relative & Absolute Path • Redirection and Pipe • File/Directory Permissions • Process Management • The nano Text Editor

  13. Linux OS: Kernel + Shell • Kernel is a main program of Unix system. it controls hard wares, CPU, memory, hard disk, network card etc. • Shell is an interface between user and kernel. Shell interprets your input as commands and pass them to kernel. User input Shell Kernel

  14. Linux Overview Directory Structure • Files are placed in directories/folders. • All directories are in a tree like hierarchical structure. • Users can add and remove files and directories on the tree • If they have proper level of authority. • Top Most directory is “/”, which is called or root. • Users have their own directory called home directory • Users can create and delete files and folders they own • Users can give permission to others on their files and folders

  15. common Linux directory structure

  16. Basic Linux Commands • When you log on too Linux machines, you will see a prompt • On cisunix/wildcats it is a % with a blinking cursor • On other machines it looks like: [user@host ~]$ [feseha@perl ~]$ The prompt is called a shell prompt and waits for user commands User commands consists of three basic parts (in order): • command name eg. ls • options (modifiers) eg. -la (l= long form, a = all file types) • arguments the entity to be acted upon • eg: /usr/local/bin NB: options and arguments are optional [user@host ~]$ ls –la /usr/local/bin

  17. Basic Linux Commands • ls show files in current position • cd change directory • cp copy file or directory • mv move file or directory • rm remove file or directory • pwd print Working directory • mkdir create directory • rmdir remove directory • less display file contents one screen full at a time • more display file contents one screen full at a time (with less and more: press space bar to see next screen full or press the letter ‘q’ to quit and get the prompt back) • cat concatenates and display contents of one or more files (pipe it to more or less to prevent continuous flow and read contents) • man display online manual

  18. Basic Linux Commands • passwd change password (following its instruction) • head show the top 10, or more with options, lines of a file • tail show the bottom 10, or more with options, lines of a file • sort Sort file contents by the first field in ascending alphabetical order • grep search file and retrieve lines containing pattern • wc word or line count

  19. Relative & Absolute Path • Path refers to the position of a file / folder in the directory tree. • Paths can be expressed as relative path or absolute path. • Relative path expression: • the path is not defined uniquely • expressed relative to current position. • ../../../fileName • FileName is two directories up! • ../foldername/fileName • File is in folderName one directory up! • Absolute path expression: • the path is defined uniquely • does not depend on your current path • It goes all the way from root position to the target file/folder position • Eg. /home/feseha/public_html/cgi-bin/w777/junk.txt

  20. Output Redirection & Pipe By default, output of commands, if any, is displayed on screen. • Output can be directed to: • File • Other commands to process it further • Use: >fileName to redirect command output from screen to a file. • NB: “>” also means overwrite the file if it exists so pay attention to what you write to! • Using “>>” instead of “>” appends the output to the end of the file if the file already exists or creates a new file if it doesn’t exist. Output can be redirected to other commands via a pipe “|” Eg. 1. If the output of a command is longer than the screen size, you can pipe it to less or more so that one screen full can be viewed at a time ls –l | more Eg. 2. If you want to peruse a many concatenated documents spanning more than one screen, pipe it to “more” or “less” to view one screen full at a time head *.pl| more (* = anything so *.pl means all files ending in “.pl” i.e. perl scripts)

  21. Output Redirection and Pipe Eg. 3. You just want to know how many lines are in the output of ls. You can pipe its output to wc –l as follows ls | wc –l Eg. 4. You want to see the lines 250 to 265 in a file that has 1000 lines in it. You can use head to get the first 265 line and pipe it to tail to get the last 15 lines head -265 targetFile.txt | tail -15 If you want the lines saved to result.txt instead of the screen, redirect it with > head -265 targetFile.txt | tail -15 > result.txt

  22. Sorting sort Sorts a file /list with the first field of each line. • Options: • -n numerical sorting on first fiels • -k sort by field number following k • -r sort in reverse descending order ( z – a or say 100 to 1) • -n Sorts considering the numeric value of the strings • -k3 Sorts using the third field of each line • -rnk3 Sorts in reverse order, using the numeric value of field # 3

  23. Output Redirection and Pipe • What does the following command achieve? ls –la /bin/ | sort –nk5 | tail -1 First figure out what each command is supposed to do … ls – la /bin/ sort –nk5 tail -1

  24. File/Folder Permissions • All of files and directories have specific owner and permission. • There are three types of permission: • Readable, r • Writeable, w and • eXecutable, x • Permissions are set at three user levels: • owner, u (u from user) • group member, g and • World, o (All Others outside owner and owner’s group). • ALL, a i.e u+g+o Example: ls -l .bash_profile -rw-r--r-- 1 cnotred cnotred 191 Jan 4 13:11 .bash_profile • r:readable, w:writable, x: executable

  25. Setting/changing Permissions Command Outcome_____________________ • chmod change file mode, add or remove permission • chown change owner of the file Examples: chmod a+w filename add writable permission to all users chmod o-x filename remove executable permission from others chmod a+x Gives permission to the user to execute a file • u: user (owner), g: group, o: others a: all

  26. Set/change Permission by numbers • r = 4, w = 2, x = 1 • rwxrwxrwx • 421 421 421 • 7 7 7 • a+rwx • 421 001 001 • rwx --x –x Command line usage: • chmod 711 fileName • Set the permission at three levels • chownuserName myFile.txt • (I passed ownership to another user!)

  27. Checking Permissions • Check permission ls –l .bash_profile cp .bash_profile sample.txt ls –l sample.txt • Remove readable permission from all. chmod a-r sample.txt ls –l sample.txt less sample.txt • Add readable & writable premissions to file owner. chmod u+rw sample.txt ls –l sample.txt less sample.txt rm sample.txt

  28. The nano text Editor Nano is a user friendly text editor! • Arrow-keysMove cursor____________________________ • CTRL+a Move to the beginning of the current line. • CTRL+e Move to the end of the current line. • CTRL+v Move forward one page. • CTRL+y Move backward one page. • CTRL+w Search for text. • CTRL+dDelete the current character. • CTRL+k Remove (cut) current line or selected text. • CTRL+u Paste (uncut) last cut text at the cursor position. • CTRL+oSave (output) the file. • CTRL+xExit nano, saving the file.

  29. The nano text Editor • Create the file Hello.pl nano hello.pl • Write hello.pl as follows. #!/usr/bin/perl print “Hello World\n”; • Make it executable chmod u+x hello.pl • Run it! ./hello.pl

More Related