Package: jatsgenerator
jats-generatorGenerate JATS XML file from journal article data.Using objects defined inelifearticleas data structure, this library generates JATS XML output for a research article.No article body content is supported yet, though this library can output at least the following:Journal metadata (journal title, publisher name, issn, volume)Article metadata (title, doi, pub date, history dates, abstract, copyright, subject categories, research organisms)Authors, editors, group authors, author affiliations, correspondence, conflicts of interestPermissions (copyright statement, copyright year, copyright holder, license)DatasetsFunding dataEthicsOne way to populate theelifearticleobjects with data, as is used by eLife from CSV files, relies on using theejpcsvparserlibrary by usinggenerate.build_article_from_csv(), resulting in anArticleobject. TheArticlecan then be used as input togenerate.build_xml()orgenerate.build_xml_to_disk()which will produce the JATS XML output.A configparser object can be populated from thejatsgenerator.cfgfile, where a different config section per journal name can be included, and building it using thejatsgenerator.configmodule,Some sample CSV data input and JATS XML 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 jatsgeneratorb) Install locallyClone the git repogit clone https://github.com/elifesciences/jats-generator.gitCreate a python virtual environment and activate it./install.shConfigurationThejatsgenerator.cfgconfiguration file provided in this repository can be changed in order to write slightly different JATS XML output, depending on the journal.Example usageThis library is meant to be integrated into another operational system, where theelifearticleobjects can be populated with sufficient data to produce complete JATS XMl output, however the following is a simple example using interactive Python:>>>fromelifearticle.articleimportArticle,Contributor>>>fromjatsgeneratorimportgenerate>>>fromjatsgenerator.confimportraw_config,parse_raw_config>>>article_object=Article("10.7554/eLife.00666","Article title")>>>article_object.abstract="An abstract.">>>article_object.add_contributor(Contributor("author","Surname","Given"))>>>article_object.add_contributor(Contributor("editor","Orr","Edit"))>>>jats_config=parse_raw_config(raw_config("elife"))>>>article_xml_object=generate.build_xml(None,article_object,jats_config)>>>print(article_xml_object.output_xml())The JATS XML output, pretty formatted, will look something like this:<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.1d3 20150301//EN"  "JATS-archivearticle1.dtd"><articlearticle-type="research-article"dtd-version="1.1d3"xmlns:mml="http://www.w3.org/1998/Math/MathML"xmlns:xlink="http://www.w3.org/1999/xlink"><!--generated by jats-generator at 2021-09-02 14:18:33 from version 6cd2bf35c814117f5e5966ec415e01cedbdcd7de--><front><journal-meta><journal-idjournal-id-type="nlm-ta">elife</journal-id><journal-idjournal-id-type="publisher-id">eLife</journal-id><journal-title-group><journal-title>eLife</journal-title></journal-title-group><issnpublication-format="electronic">2050-084X</issn><publisher><publisher-name>eLifeSciencesPublications,Ltd</publisher-name></publisher></journal-meta><article-meta><article-idpub-id-type="doi">10.7554/eLife.00666</article-id><title-group><article-title>Articletitle</article-title></title-group><contrib-group><contribcontrib-type="author"><name><surname>Surname</surname><given-names>Given</given-names></name></contrib></contrib-group><contrib-groupcontent-type="section"><contribcontrib-type="editor"><name><surname>Orr</surname><given-names>Edit</given-names></name><role>Reviewingeditor</role></contrib></contrib-group><abstract><p>Anabstract.</p></abstract></article-meta></front><back><secid="s1"sec-type="additional-information"><title>Additionalinformation</title></sec></back></article>Run code testsUsepytestfor testing, install it if missing:pip install pytestRun testspytestRun tests with coveragecoverage run -m pytestthen report on code coverageconverage report -mLicenseLicensed underMIT.