Skip to content

Commit

Permalink
add Medline importer test
Browse files Browse the repository at this point in the history
  • Loading branch information
tschechlovdev committed Mar 8, 2016
1 parent 904111c commit b095947
Show file tree
Hide file tree
Showing 9 changed files with 546 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ else if ("LastName".equals(localName)) {
else if ("Suffix".equals(localName)) {
inSuffix = false;
}
else if ("ForeName".equals(localName) || "FirstName".equals(localName)) {
else if ("ForeName".equals(localName) || "FirstName".equals(localName) || "CollectiveName".equals(localName)) {
inForename = false;
}
else if ("Issue".equals(localName)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package net.sf.jabref.importer.fileformat;

import static org.junit.Assert.*;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;

import net.sf.jabref.Globals;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.bibtex.BibtexEntryAssert;
import net.sf.jabref.importer.OutputPrinterToNull;
import net.sf.jabref.model.entry.BibEntry;

import org.junit.Before;
import org.junit.Test;
import org.junit.Assert;

/**
* Articles in the medline format can be downloaded from http://www.ncbi.nlm.nih.gov/pubmed/.
* 1. Search for a term and make sure you have selected the PubMed database
* 2. Select the results you want to export by checking their checkboxes
* 3. Press on the 'Send to' drop down menu on top of the search results
* 4. Select 'File' as Destination and 'XML' as Format
* 5. Press 'Create File' to download your search results in a medline xml file
*
* @author Daniel Mair/Bruehl
*
*/
public class MedlineImporterTest {

private final InputStream emptyFileStream = new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8));
private MedlineImporter medlineImporter;


@Before
public void setUp() throws Exception {
Globals.prefs = JabRefPreferences.getInstance();
this.medlineImporter = new MedlineImporter();
}

@Test
public void testIsRecognizedFormatAccept() throws Throwable {
List<String> list = Arrays.asList("MedlineImporterMinimalEntryTest.xml", "MedlineImporterSingleEntryTest.xml",
"MedlineImporterArticleIDTest.xml");
for (String str : list) {
try (InputStream is = MedlineImporterTest.class.getResourceAsStream(str);) {
Assert.assertTrue(medlineImporter.isRecognizedFormat(is));
}
}
}

@Test
public void testIsRecognizedFormatReject() throws Throwable {
List<String> list = Arrays.asList("CopacImporterTest1.txt", "CopacImporterTest2.txt", "IEEEImport1.txt",
"IsiImporterTestWOS.isi", "oai2.xml", "oai22.xml", "RisImporterTest1.ris");
for (String str : list) {
try (InputStream is = MedlineImporterTest.class.getResourceAsStream(str);) {
Assert.assertFalse(medlineImporter.isRecognizedFormat(is));
}
}
}

@Test
public void testIsRecognizedFormatEmptyFile() throws IOException {
Assert.assertFalse(medlineImporter.isRecognizedFormat(emptyFileStream));
}

@Test
public void testImportMalformedEntry() throws IOException {
try (InputStream is = MedlineImporter.class.getResourceAsStream("MedlineImporterMalformedEntryTest.xml")) {
medlineImporter.importEntries(is, new OutputPrinterToNull());
}
}

@Test
public void testImportEntryWithArticleID() throws IOException {
checkImportEntriesAgainstBibFileEntries("MedlineImporterArticleIDTest.xml",
"MedlineImporterArticleIDTestBib.bib");
try (InputStream shouldBeIs = MedlineImporter.class.getResourceAsStream("MedlineImporterArticleIDTest.xml");
InputStream bibIn = MedlineImporter.class.getResourceAsStream("MedlineImporterArticleIDTestBib.bib")) {
List<BibEntry> entries = medlineImporter.importEntries(shouldBeIs, new OutputPrinterToNull());
Assert.assertEquals(1, entries.size());
BibEntry entry = entries.get(0);
BibtexEntryAssert.assertEquals(bibIn, entry);
}
}

@Test
public void testImportSingleEntry() throws IOException {
checkImportEntriesAgainstBibFileEntries("MedlineImporterSingleEntryTest.xml",
"MedlineImporterSingleEntryTestBib.bib");
}

@Test
public void testEntriesWithMinimalFields() throws IOException {
checkImportEntriesAgainstBibFileEntries("MedlineImporterMinimalEntryTest.xml",
"MedlineImporterMinimalEntryTestBib.bib");
}

private void checkImportEntriesAgainstBibFileEntries(String medlineFile, String bibTexFile) throws IOException {
try (InputStream is = MedlineImporter.class.getResourceAsStream(medlineFile);
InputStream nis = MedlineImporter.class.getResourceAsStream(bibTexFile)) {
List<BibEntry> entries = medlineImporter.importEntries(is, new OutputPrinterToNull());
Assert.assertNotNull(entries);
Assert.assertEquals(1, entries.size());
BibtexEntryAssert.assertEquals(nis, entries.get(0));
}
}

@Test
public void testGetFormatName() {
assertEquals("Medline", medlineImporter.getFormatName());
}

@Test
public void testGetCLIId() {
assertEquals("medline", medlineImporter.getCLIId());
}

@Test
public void testFetchMedline() {
List<BibEntry> validMedLine = medlineImporter.fetchMedline("1", new OutputPrinterToNull());
List<BibEntry> emptyMedLine = medlineImporter.fetchMedline("zzzzzz", new OutputPrinterToNull());
assertNotNull(validMedLine);
assertEquals(0, emptyMedLine.size());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
<?xml version="1.0"?>
<!DOCTYPE PubmedArticleSet PUBLIC "-//NLM//DTD PubMedArticle, 1st January 2016//EN" "http://www.ncbi.nlm.nih.gov/corehtml/query/DTD/pubmed_160101.dtd">
<PubmedArticleSet>

<PubmedArticle>
<MedlineCitation Status="Publisher" Owner="NLM">
<PMID Version="1">26711635</PMID>
<DateCreated>
<Year>2015</Year>
<Month>12</Month>
<Day>29</Day>
</DateCreated>
<DateRevised>
<Year>2015</Year>
<Month>12</Month>
<Day>30</Day>
</DateRevised>
<Article PubModel="Print-Electronic">
<Journal>
<ISSN IssnType="Electronic">1879-0070</ISSN>
<JournalIssue CitedMedium="Internet">
<PubDate>
<Year>2015</Year>
<Month>Dec</Month>
<Day>1</Day>
</PubDate>
</JournalIssue>
<Title>Diagnostic microbiology and infectious disease</Title>
<ISOAbbreviation>Diagn. Microbiol. Infect. Dis.</ISOAbbreviation>
</Journal>
<ArticleTitle>Diagnostic performance of a multiplex PCR assay for meningitis in an HIV-infected population in Uganda.</ArticleTitle>
<Pagination>
<MedlinePgn/>
</Pagination>
<ELocationID EIdType="pii">S0732-8893(15)00432-0</ELocationID>
<ELocationID EIdType="doi">10.1016/j.diagmicrobio.2015.11.017</ELocationID>
<Abstract>
<AbstractText NlmCategory="UNASSIGNED">Meningitis remains a worldwide problem, and rapid diagnosis is essential to optimize survival. We evaluated the utility of a multiplex PCR test in differentiating possible etiologies of meningitis. Cerebrospinal fluid (CSF) from 69 HIV-infected Ugandan adults with meningitis was collected at diagnosis (n=51) and among persons with cryptococcal meningitis during therapeutic lumbar punctures (n=68). Cryopreserved CSF specimens were analyzed with BioFire FilmArray® Meningitis/Encephalitis panel, which targets 17 pathogens. The panel detected Cryptococcus in the CSF of patients diagnosed with a first episode of cryptococcal meningitis by fungal culture with 100% sensitivity and specificity and differentiated between fungal relapse and paradoxical immune reconstitution inflammatory syndrome in recurrent episodes. A negative FilmArray result was predictive of CSF sterility on follow-up lumbar punctures for cryptococcal meningitis. EBV was frequently detected in this immunosuppressed population (n=45). Other pathogens detected included: cytomegalovirus (n=2), varicella zoster virus (n=2), human herpes virus 6 (n=1), and Streptococcus pneumoniae (n=1). The FilmArray Meningitis/Encephalitis panel offers a promising platform for rapid meningitis diagnosis.</AbstractText>
<CopyrightInformation>Copyright © 2015 Elsevier Inc. All rights reserved.</CopyrightInformation>
</Abstract>
<AuthorList>
<Author>
<LastName>Rhein</LastName>
<ForeName>Joshua</ForeName>
<Initials>J</Initials>
<AffiliationInfo>
<Affiliation>Division of Infectious Disease and International Health, Department of Medicine, University of Minnesota, Minneapolis, MN, USA; Infectious Disease Institute, Makerere University, Kampala, Uganda. Electronic address: joshua.rhein@gmail.com.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Bahr</LastName>
<ForeName>Nathan C</ForeName>
<Initials>NC</Initials>
<AffiliationInfo>
<Affiliation>Division of Infectious Disease and International Health, Department of Medicine, University of Minnesota, Minneapolis, MN, USA.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Hemmert</LastName>
<ForeName>Andrew C</ForeName>
<Initials>AC</Initials>
<AffiliationInfo>
<Affiliation>BioFire Diagnostics, LLC, Salt Lake City, UT, USA.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Cloud</LastName>
<ForeName>Joann L</ForeName>
<Initials>JL</Initials>
<AffiliationInfo>
<Affiliation>BioFire Diagnostics, LLC, Salt Lake City, UT, USA.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Bellamkonda</LastName>
<ForeName>Satya</ForeName>
<Initials>S</Initials>
<AffiliationInfo>
<Affiliation>BioFire Diagnostics, LLC, Salt Lake City, UT, USA.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Oswald</LastName>
<ForeName>Cody</ForeName>
<Initials>C</Initials>
<AffiliationInfo>
<Affiliation>BioFire Diagnostics, LLC, Salt Lake City, UT, USA.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Lo</LastName>
<ForeName>Eric</ForeName>
<Initials>E</Initials>
<AffiliationInfo>
<Affiliation>BioFire Diagnostics, LLC, Salt Lake City, UT, USA.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Nabeta</LastName>
<ForeName>Henry</ForeName>
<Initials>H</Initials>
<AffiliationInfo>
<Affiliation>Infectious Disease Institute, Makerere University, Kampala, Uganda.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Kiggundu</LastName>
<ForeName>Reuben</ForeName>
<Initials>R</Initials>
<AffiliationInfo>
<Affiliation>Infectious Disease Institute, Makerere University, Kampala, Uganda.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Akampurira</LastName>
<ForeName>Andrew</ForeName>
<Initials>A</Initials>
<AffiliationInfo>
<Affiliation>Infectious Disease Institute, Makerere University, Kampala, Uganda.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Musubire</LastName>
<ForeName>Abdu</ForeName>
<Initials>A</Initials>
<AffiliationInfo>
<Affiliation>Division of Infectious Disease and International Health, Department of Medicine, University of Minnesota, Minneapolis, MN, USA; Infectious Disease Institute, Makerere University, Kampala, Uganda.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Williams</LastName>
<ForeName>Darlisha A</ForeName>
<Initials>DA</Initials>
<AffiliationInfo>
<Affiliation>Division of Infectious Disease and International Health, Department of Medicine, University of Minnesota, Minneapolis, MN, USA; Infectious Disease Institute, Makerere University, Kampala, Uganda.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Meya</LastName>
<ForeName>David B</ForeName>
<Initials>DB</Initials>
<AffiliationInfo>
<Affiliation>Division of Infectious Disease and International Health, Department of Medicine, University of Minnesota, Minneapolis, MN, USA; Infectious Disease Institute, Makerere University, Kampala, Uganda.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<LastName>Boulware</LastName>
<ForeName>David R</ForeName>
<Initials>DR</Initials>
<AffiliationInfo>
<Affiliation>Division of Infectious Disease and International Health, Department of Medicine, University of Minnesota, Minneapolis, MN, USA.</Affiliation>
</AffiliationInfo>
</Author>
<Author>
<CollectiveName>ASTRO-CM Team</CollectiveName>
</Author>
</AuthorList>
<Language>ENG</Language>
<PublicationTypeList>
<PublicationType UI="">JOURNAL ARTICLE</PublicationType>
</PublicationTypeList>
<ArticleDate DateType="Electronic">
<Year>2015</Year>
<Month>12</Month>
<Day>1</Day>
</ArticleDate>
</Article>
<MedlineJournalInfo>
<MedlineTA>Diagn Microbiol Infect Dis</MedlineTA>
<NlmUniqueID>8305899</NlmUniqueID>
<ISSNLinking>0732-8893</ISSNLinking>
</MedlineJournalInfo>
<KeywordList Owner="NOTNLM">
<Keyword MajorTopicYN="N">Cryptococcal meningitis</Keyword>
<Keyword MajorTopicYN="N">Diagnostics</Keyword>
<Keyword MajorTopicYN="N">HIV</Keyword>
<Keyword MajorTopicYN="N">Immunocompromised</Keyword>
<Keyword MajorTopicYN="N">Meningitis</Keyword>
<Keyword MajorTopicYN="N">PCR</Keyword>
</KeywordList>
</MedlineCitation>
<PubmedData>
<History>
<PubMedPubDate PubStatus="received">
<Year>2015</Year>
<Month>7</Month>
<Day>21</Day>
</PubMedPubDate>
<PubMedPubDate PubStatus="revised">
<Year>2015</Year>
<Month>11</Month>
<Day>17</Day>
</PubMedPubDate>
<PubMedPubDate PubStatus="accepted">
<Year>2015</Year>
<Month>11</Month>
<Day>18</Day>
</PubMedPubDate>
<PubMedPubDate PubStatus="entrez">
<Year>2015</Year>
<Month>12</Month>
<Day>30</Day>
<Hour>6</Hour>
<Minute>0</Minute>
</PubMedPubDate>
<PubMedPubDate PubStatus="pubmed">
<Year>2015</Year>
<Month>12</Month>
<Day>30</Day>
<Hour>6</Hour>
<Minute>0</Minute>
</PubMedPubDate>
<PubMedPubDate PubStatus="medline">
<Year>2015</Year>
<Month>12</Month>
<Day>30</Day>
<Hour>6</Hour>
<Minute>0</Minute>
</PubMedPubDate>
</History>
<PublicationStatus>aheadofprint</PublicationStatus>
<ArticleIdList>
<ArticleId IdType="pii">S0732-8893(15)00432-0</ArticleId>
<ArticleId IdType="doi">10.1016/j.diagmicrobio.2015.11.017</ArticleId>
<ArticleId IdType="pubmed">26711635</ArticleId>
</ArticleIdList>
</PubmedData>
</PubmedArticle>


</PubmedArticleSet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@Article{,
Title = {Diagnostic performance of a multiplex PCR assay for meningitis in an HIV-infected population in Uganda.},
Author = {Rhein, Joshua and Bahr, Nathan C. and Hemmert, Andrew C. and Cloud, Joann L. and Bellamkonda, Satya and Oswald, Cody and Lo, Eric and Nabeta, Henry and Kiggundu, Reuben and Akampurira, Andrew and Musubire, Abdu and Williams, Darlisha A. and Meya, David B. and Boulware, David R. and , A. S. T. R. O-C. M Team},
Journal = {Diagn Microbiol Infect Dis},
Year = {2015},
Month = {Dec},
Abstract = {Meningitis remains a worldwide problem, and rapid diagnosis is essential to optimize survival. We evaluated the utility of a multiplex PCR test in differentiating possible etiologies of meningitis. Cerebrospinal fluid (CSF) from 69 HIV-infected Ugandan adults with meningitis was collected at diagnosis (n=51) and among persons with cryptococcal meningitis during therapeutic lumbar punctures (n=68). Cryopreserved CSF specimens were analyzed with BioFire FilmArray® Meningitis/Encephalitis panel, which targets 17 pathogens. The panel detected Cryptococcus in the CSF of patients diagnosed with a first episode of cryptococcal meningitis by fungal culture with 100\% sensitivity and specificity and differentiated between fungal relapse and paradoxical immune reconstitution inflammatory syndrome in recurrent episodes. A negative FilmArray result was predictive of CSF sterility on follow-up lumbar punctures for cryptococcal meningitis. EBV was frequently detected in this immunosuppressed population (n=45). Other pathogens detected included: cytomegalovirus (n=2), varicella zoster virus (n=2), human herpes virus 6 (n=1), and Streptococcus pneumoniae (n=1). The FilmArray Meningitis/Encephalitis panel offers a promising platform for rapid meningitis diagnosis.},
DOI = {10.1016/j.diagmicrobio.2015.11.017},
Institution = {Division of Infectious Disease and International Health, Department of Medicine, University of Minnesota, Minneapolis, MN, USA.},
Language = {eng},
Medline-pst = {aheadofprint},
Pii = {S0732-8893(15)00432-0},
Pmid = {26711635},
Url = {http://dx.doi.org/10.1016/j.diagmicrobio.2015.11.017}
}
Loading

0 comments on commit b095947

Please sign in to comment.