Bio::Biblio::IO.3pm

Langue: en

Version: 2010-04-29 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

Bio::Biblio::IO - Handling the bibliographic references

SYNOPSIS

     use Bio::Biblio::IO;
 
     # getting citations from a file
     $in = Bio::Biblio::IO->new ('-file' => 'myfile.xml' ,
                                 '-format' => 'medlinexml');
   # --- OR ---
 
     # getting citations from a string
     $in = Bio::Biblio::IO->new ('-data' => '<MedlineCitation>...</MedlineCitation>' ,
                                 '-format' => 'medlinexml');
   #--- OR ---
 
     # getting citations from a string if IO::String is installed
     use IO::String;
     $in = Bio::Biblio::IO->new ('-fh' => IO::String->new ($citation),
                                 '-format' => 'medlinexml');
 
     $in = Bio::Biblio::IO->new(-fh => $io_handle , '-format' => 'medlinexml');
 
   #--- OR ---
 
     # getting citations from any IO handler
     $in = Bio::Biblio::IO->new('-fh' => $io_handle ,
                                '-format' => 'medlinexml');
 
 
     # now, having $in, we can read all citations
     while ( my $citation = $in->next_bibref() ) {
         &do_something_with_citation ($citation);
     }
 
   #--- OR ---
 
     # again reading all citation but now a callback defined in your
     # code is used (note that the reading starts already when new()
     # is called)
     $io = Bio::Biblio::IO->new('-format'   => 'medlinexml',
                                '-file'     => $testfile,
                                '-callback' => \&callback);
     sub callback {
         my $citation = shift;
         print $citation->{'_identifier'} . "\n";
     }
 
   #Now, to actually get a citation in an XML format,
   #use I<Bio::Biblio> module which returns an XML string:
 
     use Bio::Biblio;
     use Bio::Biblio::IO;
     my $xml = Bio::Biblio->new->get_by_id ('12368254');
     my $reader = Bio::Biblio::IO->new ('-data' => $xml,
                                        '-format' => 'medlinexml');
 
     while (my $citation = $reader->next_bibref()) {
        #... do something here with $citation
        }
 
   #And, finally, the resulting citation can be received in different
   #output formats:
 
     $io = Bio::Biblio::IO->new('-format' => 'medlinexml',
                                '-result' => 'raw');
   #--- OR ---
 
     $io = Bio::Biblio::IO->new('-format' => 'medlinexml',
                                '-result' => 'medline2ref');
 
   #--- OR ---
 
     $io = Bio::Biblio::IO->new('-format' => 'pubmedxml',
                                '-result' => 'pubmed2ref');
 
 

DESCRIPTION

Bio::Biblio::IO is a handler module for accessing bibliographic citations. The citations can be in different formats - assuming that there is a corresponding module knowing that format in Bio::Biblio::IO directory (e.g. Bio::Biblio::IO::medlinexml). The format (and the module name) is given by the argument -format.

Once an instance of "Bio::Biblio::IO" class is available, the citations can be read by calling repeatedly method next_bibref:

     while (my $citation = $reader->next_bibref()) {
        ... do something here with $citation
        }
 
 

However, this may imply that all citations were already read into the memory. If you expect a huge amount of citations to be read, you may choose a callback option. Your subroutine is specified in the "new()" method and is called everytime a new citation is available (see an example above in SYNOPSIS).

The citations returned by next_bibref or given to your callback routine can be of different formats depending on the argument -result. One result type is raw and it is represented by a simple, not blessed hash table:

     $io = Bio::Biblio::IO->new('-result' => 'raw');
 
 

What other result formats are available depends on the module who reads the citations in the first place. At the moment, the following ones are available:

     $io = Bio::Biblio::IO->new('-result' => 'medline2ref');
 
 

This is a default result format for reading citations by the medlinexml module. The "medlinexml" module is again the default one. Which means that you can almost omit arguments (you still need to say where the citations come from):

     $io = Bio::Biblio::IO->new('-file' => 'data/medline_data.xml');
 
 

Another result format available is for PUBMED citations (which is a super-set of the MEDLINE citations having few more tags):

     $io = Bio::Biblio::IO->new('-format' => 'pubmedxml',
                                '-result' => 'pubmed2ref',
                                '-data'   => $citation);
 
 

Or, because "pubmed2ref" is a default one for PUBMED citations, you can say just:

     $io = Bio::Biblio::IO->new('-format' => 'pubmedxml',
                                '-data'   => $citation);
 
 

Both "medline2ref" and "pubmed2ref" results are objects defined in the directory "Bio::Biblio".

SEE ALSO

*
An example script examples/biblio.pl. It has many options and its own help. The relevant options to this IO module are -f (specifying what file to read) and -O (specifying what result format to achieve).
*
OpenBQS home page: http://www.ebi.ac.uk/~senger/openbqs
*
Comments to the Perl client: http://www.ebi.ac.uk/~senger/openbqs/Client_perl.html

FEEDBACK

Mailing Lists

User feedback is an integral part of the evolution of this and other Bioperl modules. Send your comments and suggestions preferably
 to one of the Bioperl mailing lists. Your participation is much appreciated.
   bioperl-l@bioperl.org                  - General discussion
   http://bioperl.org/wiki/Mailing_lists  - About the mailing lists
 
 

Support

Please direct usage questions or support issues to the mailing list:

bioperl-l@bioperl.org

rather than to the module maintainer directly. Many experienced and reponsive experts will be able look at the problem and quickly address it. Please include a thorough description of the problem with code and data examples if at all possible.

Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track the bugs and their resolution. Bug reports can be submitted via the web:
   http://bugzilla.open-bio.org/
 
 

AUTHOR

Martin Senger (senger@ebi.ac.uk) Copyright (c) 2002 European Bioinformatics Institute. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

DISCLAIMER

This software is provided ``as is'' without warranty of any kind.

APPENDIX

The rest of the documentation details each of the object methods. Internal methods are preceded with a _

next_bibref

  Usage   : $citation = stream->next_bibref
  Function: Reads the next citation object from the stream and returns it.
  Returns : a Bio::Biblio::Ref citation object, or something else
            (depending on the '-result' argument given in the 'new()'
             method).
  Args    : none
 
 

_load_format_module

  Usage   : $class->_load_format_module ($format)
  Returns : 1 on success, undef on failure
  Args    : 'format' should contain the last part of the
            name of a module who does the real implementation
 
 

It does (in run-time) a similar thing as

    require Bio::Biblio::IO::$format
 
 

It throws an exception if it fails to find and load the module (for example, because of the compilation errors in the module).

_guess_format

  Usage   : $class->_guess_format ($filename)
  Returns : string with a guessed format of the input data (e.g. 'medlinexml')
  Args    : a file name whose extension can help to guess its format
 
 

It makes an expert guess what kind of data are in the given file (but be prepare that $filename may be empty).