Package: elifepubmed
elife-pubmed-xml-generationGenerate PubMed deposit of journal articles.Using JATS XML file as input, this library can generate a PubMed deposit XML file. The XML is parsed using the module from a different library,elifearticle, to extract the data from the XML file and to populate the objects defined inelifearticle.It would be possible, with some additional code, to populate theelifearticlewith data from a different data source and still generate a PubMed deposit, if all or a portion of the data is not stored in JATS XML format.The PubMed deposit file will include the following output if the data is available in theelifearticleobjects:Journal (journal title, publisher name, issn, volume, issue, pub date)Article metadata (title, doi, pii, language, pub date, abstract, copyright, keywords)Authors, group authors, author affiliationsFunding dataaheadofprintpublishing statusIt is possible to generate a PubMed deposit XML which includes one article or mulitple articles, depending on how many articles are in the list when generating the output.Some sample input and output files can be found in thetests/test_data/folder, which are the basis for the automated tests.Requirements and installa) Install frompypipackage indexpip install elifepubmedb) Install locallyClone the git repogit clone https://github.com/elifesciences/elife-pubmed-xml-generation.gitCreate a python virtual environment and activate itpython3 -m venv venv
source venv/bin/activateInstall it locallypip install -r requirements.txt
python setup.py installConfigurationThepubmed.cfgconfiguration file provided in this repository can be changed in order to read slightly different JATS XML attributes, depending on the journal.Thepublication_types.yamlfile, referenced in thepubmed.cfgfile, is where a JATS XML article type value can be mapped to a PubMedpublication_typevalue.Example usageThis library is meant to be integrated into another operational system, however the following are examples using interactive Python:Example 1 - Convert a test fixture XML to elifearticle Article() object, then generate PubMed XML>>> from letterparser import generate
>>> articles = generate.build_articles_for_pubmed(["tests/test_data/elife-00666.xml"])
>>> p_xml = generate.pubmed_xml(articles)
>>> print(p_xml)Example 2 - Convert a test fixture XML to elifearticle Article() object, set the articleis_poaproperty, then generate PubMed XML, the output XML will contain<PubDate PubStatus="aheadofprint">>>> from letterparser import generate
>>> articles = generate.build_articles_for_pubmed(["tests/test_data/elife-00666.xml"])
>>> articles[0].is_poa = True
>>> p_xml = generate.pubmed_xml(articles)
>>> print(p_xml)Example 3 - Convert two test fixture XML files to elifearticle Article() objects, then generate PubMed XML to disk, the output will be written in the localtmp/folder>>> from letterparser import generate
>>> articles = generate.build_articles_for_pubmed(["tests/test_data/elife-00666.xml", "tests/test_data/elife-02935-v2.xml"])
>>> generate.pubmed_xml_to_disk(articles)Run code testsUsepytestfor testing, install it if missing:pip install pytestRun testspytestRun tests withcoverage(install it if missing)coverage run -m pytestthen report on code coveragecoverage report -mLicenseLicensed underMIT.