A script to automagically generate DocBook formatted references. (was : Re: [Bioperl-l] Re: Bio::Biblio)

Charles Plessy charles at gizmotronics.dyndns.org
Sun Oct 12 12:05:13 EDT 2003


>    Here I am ataching an example doing hopefully what you wish (and few 
> explanations labelled by '(digit)' pattern:

Thank you very much! Your script is very useful to me!

I now search for the articles'pmid on pubmed, run the script with the
pmid as an argument, and cut-paste the output in my docbook
bibliography file.

Here are my modifications. I plan some cosmetic changes, and to make
this script able to process a list of pmids.

-- 
Charles Plessy



#!/usr/bin/perl -w

#$Revision: 1.1 $

# This script was originally written by Martin Senger.
# I adapted the output fo facilitate the writing of my biology thesis.
# Charles Plessy

use Bio::Biblio;       # to read data via SOAP
use Bio::Biblio::IO;   # to convert resulting XML to Biblio objects

# (1)
# --- taking citations from MEDLINE at EBI using SOAP

my $pmID = shift;
my $biblio = new Bio::Biblio;
my $citation = $biblio->get_by_id ("$pmID");

# (2)
# --- make an instance of a converter
my $io = new Bio::Biblio::IO ('-data' => $citation);

# (3)
# --- and make the conversion (use the citation)

while (my $bibref = $io->next_bibref) {

$bibref->{_date} =~ /(\d*)/;
my $year=$1 ;

print << "DOCBOOK_START";
<biblioentry id="$bibref->{_authors}->[0]->{_lastname}-$year">
  <abbrev>$bibref->{_authors}->[0]->{_lastname} <emphasis>et al</emphasis>, $year</abbrev>
  <biblioset relation="journal">
    <titleabbrev>$bibref->{_journal}->{_medline_ta}</titleabbrev>
  </biblioset>
  <biblioset relation="article" id="pmid-$bibref->{_pmid}">
    <authorgroup>
DOCBOOK_START

# To fix : no 'et al' if 1, 2 or 3 authors
#          if multiple pmids, check unicity of biblioentry ids
#          manage languages

    foreach (@ {$$bibref{'_authors'}} ) {
        print << "DOCBOOK_AUTHORS";
      <author>
        <surname>$$_{_lastname}</surname>
        <firstname>$$_{_forename}</firstname>
      </author>
DOCBOOK_AUTHORS
    }

print << "DOCBOOK_END";
    </authorgroup>
    <title>$bibref->{_title}</title>
    <date>$bibref->{_date}</date>
    <volumenum>$bibref->{_volume}</volumenum>
    <issuenum>$bibref->{_issue}</issuenum>
    <pagenums>$bibref->{_medline_page}</pagenums>
  </biblioset>
</biblioentry>


DOCBOOK_END

# To fix    : put a nice &ndash: in <pagenums>

}


__END__



More information about the Bioperl-l mailing list