Below is an example that shows how to add a literature reference based on a pubmed id to a pathway using the PathVisio library.
Pathway pathway = new Pathway();
//Add the references to the info object (apply to whole pathway)
PathwayElement info = pathway.getMappInfo();
//The pubmed id to add
String pmid = "1234";
//Create a new biopax element containing the reference
PublicationXref xref = new PublicationXref();
xref.setPubmedId(pmid);
//Query article info from PubMed
PubMedQuery pmq = new PubMedQuery(pmid);
pmq.execute();
PubMedResult pmr = pmq.getResult();
xref.setTitle(pmr.getTitle());
for(String a : pmr.getAuthors()) xref.addAuthor(a);
xref.setYear(pmr.getYear());
xref.setSource(pmr.getSource());
//Attach the xref to the info object
info.getBiopaxReferenceManager().addElementReference(xref);
//Save the pathway to GPML
pathway.writeToXml(new File("test.gpml"), true);
The resulting GPML will look like this:
<?xml version="1.0" encoding="UTF-8"?>
<Pathway xmlns="http://genmapp.org/GPML/2010a" Name="untitled">
<BiopaxRef>b19</BiopaxRef>
<Graphics BoardWidth="0.0" BoardHeight="0.0" />
<InfoBox CenterX="0.0" CenterY="0.0" />
<Biopax>
<bp:PublicationXref xmlns:bp="http://www.biopax.org/release/biopax-level3.owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:id="b19">
<bp:ID rdf:datatype="http://www.w3.org/2001/XMLSchema#string">1234</bp:ID>
<bp:DB rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PubMed</bp:DB>
<bp:TITLE rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Change in the kinetics of sulphacetamide tissue distribution in Walker tumor-bearing rats.</bp:TITLE>
<bp:AUTHORS rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Nadeau D</bp:AUTHORS>
<bp:AUTHORS rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Marchand C</bp:AUTHORS>
<bp:YEAR rdf:datatype="http://www.w3.org/2001/XMLSchema#string">1975</bp:YEAR>
<bp:SOURCE rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Drug Metab Dispos</bp:SOURCE>
</bp:PublicationXref>
</Biopax>
</Pathway>
