Bio::Biblio::IO(3pm)

🌸 Bio::Biblio::IO πŸ’–

okay bestie, welcome to Bio::Biblio::IO(3pm) β€” a User Contributed Perl Documentation moment. this is the whole vibe, let's go ✨


✨ NAME ✨

Bio::Biblio::IO β€” handling the bibliographic references πŸŽ€

🌈 VERSION 🌈

version 1.70 πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

no cap, here's the whole thing, copy it exactly:

    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 show up in all different formats β€” the whole premise is that there's a corresponding module that knows that format living in the Bio::Biblio::IO directory (like Bio::Biblio::IO::medlinexml, for example 🧚). the format (and like, the module name too) is given by the argument -format.

once you've got an instance of the "Bio::Biblio::IO" class in your hands, you read citations by calling the method next_bibref over and over:

    while (my $citation = $reader->next_bibref()) {
       ... do something here with $citation
       }
⚠️ but lowkey? this might mean all the citations were already read into memory. if you're expecting a huge amount of citations, maybe pick the callback option instead. you specify your subroutine in the "new()" method and it gets called everytime a new citation is available (peep the example up in SYNOPSIS πŸ‘€).

the citations returned by next_bibref, or handed to your callback routine, can be in different formats depending on the argument -result. one result type is raw and it's represented by a simple, <em>not blessed</em> 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 the default result format for reading citations by the medlinexml module. and the "medlinexml" module is again the default one. which means you can almost omit arguments entirely (you still need to say where the citations come from, bestie, that part is not optional 🫢):

    $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, iconic honestly):

    $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". ✨


πŸŽ€ ATTRIBUTES πŸŽ€

fh

just fh. that's the whole bit. it's giving mysterious, and honestly? we love that for it. πŸ’…

πŸ’– METHODS πŸ’–

new

newFh

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

DESTROY

TIEHANDLE

READLINE


πŸ”₯ INTERNAL METHODS πŸ”₯

(these are the backstage ones, the stage crew of this module 🎭)

_initialize

_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, no less ⏱️) a similar thing as

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

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

_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 bestie, be prepared that $filename may be empty. πŸ™ˆ


🌟 SEE ALSO 🌟


πŸ’Œ 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 the Bioperl mailing list. 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 of the bugs and their resolution. bug reports can be submitted via the web:

  https://redmine.open-bio.org/projects/bioperl/

Authors

Martin Senger <senger@ebi.ac.uk> 🌈

this software is Copyright (c) by 2002 European Bioinformatics Institute and released under the license of the same terms as the perl 5 programming language system itself. ⭐


and that's the whole page, bestie!! this was Bio::Biblio::IO(3pm) from the User Contributed Perl Documentation, brought to you by perl v5.36.0 on 2023-02-14 β€” yes, a Valentine's Day release, we're obsessed, main character energy fr fr πŸ’–πŸ’…πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from