The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 = new Bio::Biblio::IO ('-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 = new Bio::Biblio->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 = new Bio::Biblio::IO ('-format' => 'medlinexml',
                               '-result' => 'raw');
  #--- OR ---

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

  #--- OR ---

    $io = new Bio::Biblio::IO ('-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 = new Bio::Biblio::IO ('-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 = new Bio::Biblio::IO ('-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 = new Bio::Biblio::IO ('-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 = new Bio::Biblio::IO ('-format' => 'pubmedxml',
                               '-result' => 'pubmed2ref',
                               '-data'   => $citation);

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

    $io = new Bio::Biblio::IO ('-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

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

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).