[Bioperl-l] Re: Bio::Biblio

Martin Senger senger at ebi.ac.uk
Fri Oct 10 07:16:50 EDT 2003


Hi again,

>        My goal is to write a quick-and-dirty medline2docbook fliter for
> immediate use, using bioperl since it has already a library able to
> query medline.
> ...
> Can anybody point me to the correct object and its construction method?>
>

   As mentioned already, the good source for that is the script provided 
within bioperl. The script is: examples/biblio/biblio.PLS.
   Here I am ataching an example doing hopefully what you wish (and few 
explanations labelled by '(digit)' pattern:

#!/usr/bin/perl -w

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 $biblio = new Bio::Biblio;
my $citation = $biblio->get_by_id ('11112222');

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

# (3)
# --- and make the conversion (use the citation)
print << 'DOCBOOK_START';
<biblioset>
   <authorgroup>
DOCBOOK_START

while (my $bibref = $io->next_bibref) {
    foreach (@ {$$bibref{'_authors'}} ) {
	print << "DOCBOOK";
	 <author>
	    <surname>$$_{_lastname}</surname>
	    <firstname>$$_{_forename}</firstname>
	 </author>
DOCBOOK
    }
}
print << 'DOCBOOK_END';
   </authorgroup>
</biblioset>
DOCBOOK_END

__END__

Notes:

(1) First you need to get a citation (or a collection of citations. You
may get it from MEDLINEW at EBI (as shown in the script above), but you
can also get it from the PubMed web page, or you have it already in your
local file. The script shows how to get a citation by its ID, but you can 
slo get them by using a query, e.g. using:
   my $citation = $biblio->find ('brazma')->get_all;
   Anyway, the citation (or citations) is now in your possesion in an XML
format.

(2) You may specify various arguments in the constructor. By default it 
expects that you wish result as perl biblio objects. If you rather wish a 
raw hashtable use ('-result' => 'raw') in the constructor.
   Also you say where is your citation to be converted. If you have it in 
a file use ('-file' => $citation).
   If you got your citatioin from PubMed which is slightly different XML 
from Medline) use ('-format' => 'pubmedxml').

(3) The created biblio objects do not have any methods, you just use their 
attributes. It is not ideal I know but there is no object representing all 
attributes as get methods.
   The best way hiw to find what attributes are available is to print the 
whole citation:
   print $bibref->print_me;

   I hope this helps you. Please let me know if you need more.
   Regards, Martin

PS. BTW, this is what you should get when running the script above:
<biblioset>
   <authorgroup>
         <author>
            <surname>Oyer</surname>
            <firstname>C E</firstname>
         </author>
         <author>
            <surname>Ongcapin</surname>
            <firstname>E H</firstname>
         </author>
         <author>
            <surname>Ni</surname>
            <firstname>J</firstname>
         </author>
         <author>
            <surname>Bowles</surname>
            <firstname>N E</firstname>
         </author>
         <author>
            <surname>Towbin</surname>
            <firstname>J A</firstname>
         </author>
   </authorgroup>
</biblioset>

-- 
Martin Senger

EMBL Outstation - Hinxton                Senger at EBI.ac.uk     
European Bioinformatics Institute        Phone: (+44) 1223 494636      
Wellcome Trust Genome Campus             (Switchboard:     494444)
Hinxton                                  Fax  : (+44) 1223 494468
Cambridge CB10 1SD
United Kingdom                           http://industry.ebi.ac.uk/~senger



More information about the Bioperl-l mailing list