1 / 27

Object Oriented Perl

Object Oriented Perl. Object Oriented Perl. Object Oriented Programming is a common method for encapsulation of code Object Oriented Programming allows you to use very complex methods without ever having to write them or even understand them

niveditha
Download Presentation

Object Oriented Perl

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. Object Oriented Perl

  2. Object Oriented Perl • Object Oriented Programming is a common method for encapsulation of code • Object Oriented Programming allows you to use very complex methods without ever having to write them or even understand them • We will cover Object Oriented Perl because BioPerl is written as Object Oriented

  3. Object Oriented Perl Vocabulary: • Object: a collection of data that logically belongs together • Method: a subroutine that is associated with an object • Class: object definition and the collection of methods available to an object define a class

  4. Object Oriented Perl • For Example: a Genbank object would be a collection of data that logically belong together • sequence • accession • description • features • journal reference • Objects are often implemented as hashes

  5. Object Oriented Perl • Class methods are the subroutines that are associated with an object • Class methods are the only methods that may be used • This makes sure that objects behave as they are intended • You don't have to understand the internal workings of a method in order to use it

  6. Object Oriented Perl • BioPerl is a collection of Classes that are useful for bioinformatics • use perldoc to get information about the classes and their methods • perldoc Bio::Perl • perldoc Bio::Seq • perldoc Bio::SeqIO

  7. Object Oriented Perl • In order to use an Object and its associated methods, you must include a 'use' statement use Bio::Perl; go to biotest1.pl

  8. Object Oriented Perl • Bio::Perl can read sequence files in multiple different formats and interchange them easily • For instance: take a GenBank file and convert it to a fasta file go to biotest2.pl

  9. Object Oriented Perl go to biotest2_1.pl

  10. Object Oriented Perl perldoc Bio::Perl

  11. Object Oriented Perl • Advantages to reading a library of fasta files with Bio::Perl • Don't have to write subs to open files and parse individual entries • Don't have to write subs to extract sequence, accession or features

  12. Object Oriented Perl

  13. Object Oriented Perl • Methods are called by invoking the method through the object using the -> operator object->method(argument); $acc = $seq_object->accession_number(); • accession_number is a method defined in the class Bio::Perl and invoked with the -> operator

  14. Object Oriented Perl

  15. Object Oriented Perl • Note the difference between substring and subseq • substr is a perl function that can be called on any string • subseq is a Bio::Perl method that can only be called on a Bio::Perl object • substr index starts at 0 << typical computer science • subseq index starts at 1 << typical for DNA sequences

  16. Object Oriented Perl • Accessor methods: give the user access to data in an object • Get information (call method with no argument) $acc = $seq_object->accession_number(); • Set information (call method with argument) $seq_object->accession_number("New_number");

  17. Object Oriented Perl • Bio::Perl uses LWP to access databases and programs over the web • You can get sequences from standard databases like GenBank, EMBL, Swissprot, etc • You can run blast searches using Bio::Perl

  18. Object Oriented Perl go to biotest3.pl

  19. Object Oriented Perl • Bio::Perl Methods Read one or more sequences from a file $seq_object = read_sequence($filename); @seq_object_array = read_all_sequences($filename,'fasta'); Get Information about a sequence $id = $seq_object->display_id(); $acc = $seq_object->accession_number(); $seq = $seq_object->subseq(1,5); $seq = $seq_object->seq();

  20. Object Oriented Perl • Bio::Perl Methods Write a Sequence to a file write_sequence(">$filename",'genbank',$seq_object); write_sequence(">$filename",'genbank',@seq_object_array); Get a Sequence from a Database $seq_object = get_sequence('swissprot',"ROA1_HUMAN"); $seq_object = get_sequence('embl',"AI129902"); $seq_object = get_sequence('genbank',"AI129902");

  21. Object Oriented Perl • Bio::Perl Methods BLAST a sequence $blast_report = blast_sequence($seq_object); write_blast(">blast.out",$blast_report); Sequence mainpulations $seqobj = translate($seq_or_string_scalar); $seqstring = translate_as_string($seq_or_string_scalar); $seqobj = reverse_complement($seq_or_string_scalar); $string = reverse_complement_as_string($seq_or_string_scalar);

  22. Object Oriented Perl • The Bio::Perl package is written for "people who don't know objects" • Syntax and usage are not typical for OO programs • Easy to use without much knowledge • But limited. • Better to learn some OO syntax and use the more sophisticated objects

  23. Object Oriented Perl • Bio::Seq and Bio::SeqIO are Classes of sequence objects that have many excellent methods • To use these classes you also need to include a "use" statement • You also need to "instantiate" an object (create an instance of an object)

  24. Object Oriented Perl • Most objects contain a method called the "constructor". • The constructor is used to create new instances of an object • Usually the method name for the constructor is "new"

  25. Object Oriented Perl • Create a sequence object from a file go to biotest4.pl

  26. Object Oriented Perl • Create a sequence object from a file

  27. Object Oriented Perl • The Bio::SeqIO package lets you set up a stream of sequence objects using library files go to biotest5.pl

More Related