Search in sources :

Example 36 with BibliographicReference

use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.

the class PubMedXMLParserTest method testParseRetracted.

/*
     * PMID 7914452 is an example of a retracted article.
     */
@Test
public void testParseRetracted() {
    try {
        testStream = PubMedXMLParserTest.class.getResourceAsStream("/data/pubmed-retracted.xml");
        Collection<BibliographicReference> brl = testParser.parse(testStream);
        BibliographicReference br = brl.iterator().next();
        assertNotNull(br.getAbstractText());
        assertEquals("Retracted [In: Garey CE, Schwarzman AL, Rise ML, Seyfried TN. Nat Genet. 1995 Sep;11(1):104 PMID=7550304]", br.getDescription());
        boolean ok = false;
        for (PublicationType pt : br.getPublicationTypes()) {
            if ("Retracted Publication".equals(pt.getType())) {
                ok = true;
            }
        }
        assertTrue(ok);
    } catch (RuntimeException e) {
        this.logOrThrowException(e);
    }
}
Also used : PublicationType(ubic.gemma.model.common.description.PublicationType) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Test(org.junit.Test)

Example 37 with BibliographicReference

use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.

the class PubMedXMLParserTest method testParseMulti.

/*
     * This uses a medline-format file, instead of the pubmed xml files we get from the eutils.
     */
@Test
public void testParseMulti() throws Exception {
    try {
        testStream = new GZIPInputStream(PubMedXMLParserTest.class.getResourceAsStream("/data/loader/medline.multi.xml.gz"));
        Collection<BibliographicReference> brl = testParser.parse(testStream);
        assertEquals(147, brl.size());
        int expectedNumberofKeywords = 258;
        int expectedNumberofCompounds = 46;
        int actualNumberofKeywords = 0;
        int actualNumberofCompounds = 0;
        for (BibliographicReference reference : brl) {
            assertNotNull(reference.getPublicationDate());
            Collection<Keyword> keywords = reference.getKeywords();
            for (Keyword keyword : keywords) {
                assertNotNull(keyword.getTerm());
                // log.info( keyword.getTerm() );
                actualNumberofKeywords++;
            }
            for (Compound c : reference.getChemicals()) {
                assertNotNull(c.getName());
                // log.info( c.getName() );
                actualNumberofCompounds++;
            }
            assertTrue(reference.getPublicationTypes().size() > 0);
        }
        assertEquals(expectedNumberofKeywords, actualNumberofKeywords);
        assertEquals(expectedNumberofCompounds, actualNumberofCompounds);
    } catch (RuntimeException e) {
        this.logOrThrowException(e);
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) Keyword(ubic.gemma.model.common.description.Keyword) Compound(ubic.gemma.model.expression.biomaterial.Compound) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Test(org.junit.Test)

Example 38 with BibliographicReference

use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.

the class PubMedXMLParserTest method testParseBook.

@Test
public void testParseBook() {
    try {
        testStream = PubMedXMLParserTest.class.getResourceAsStream("/data/pubmed-fullbook.xml");
        Collection<BibliographicReference> brl = testParser.parse(testStream);
        BibliographicReference br = brl.iterator().next();
        assertNotNull(br);
        assertEquals("21796826", br.getPubAccession().getAccession());
        assertEquals("Field, Marilyn J; Boat, Thomas F", br.getEditor());
        assertEquals("Institute of Medicine (US) Committee on Accelerating Rare Diseases Research and Orphan Product Development", br.getAuthorList());
        assertEquals("Rare Diseases and Orphan Products: Accelerating Research and Development", br.getPublication());
        assertEquals("Rare Diseases and Orphan Products: Accelerating Research and Development", br.getTitle());
        SimpleDateFormat f = new SimpleDateFormat("yyyy");
        Date publicationDate = br.getPublicationDate();
        assertNotNull(publicationDate);
        assertEquals("2010", f.format(publicationDate));
        assertTrue(br.getAbstractText().startsWith("This Institute of Medicine (IOM) study grew out of discussions"));
        assertTrue(br.getAbstractText().endsWith("interested general public."));
    } catch (RuntimeException e) {
        this.logOrThrowException(e);
    }
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 39 with BibliographicReference

use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.

the class SimpleExpressionDataLoaderServiceImpl method convert.

@Override
public ExpressionExperiment convert(SimpleExpressionExperimentMetaData metaData, DoubleMatrix<String, String> matrix) {
    if (matrix == null || metaData == null) {
        throw new IllegalArgumentException("One or all of method arguments was null");
    }
    ExpressionExperiment experiment = ExpressionExperiment.Factory.newInstance();
    Taxon taxon = this.convertTaxon(metaData.getTaxon());
    experiment.setName(metaData.getName());
    experiment.setShortName(metaData.getShortName());
    experiment.setDescription(metaData.getDescription());
    experiment.setSource("Import via matrix flat file." + (StringUtils.isBlank(metaData.getSourceUrl()) ? "" : "Downloaded from " + metaData.getSourceUrl()));
    ExperimentalDesign ed = ExperimentalDesign.Factory.newInstance();
    experiment.setExperimentalDesign(ed);
    if (metaData.getPubMedId() != null) {
        PubMedXMLFetcher pubfetch = new PubMedXMLFetcher();
        BibliographicReference ref = pubfetch.retrieveByHTTP(metaData.getPubMedId());
        experiment.setPrimaryPublication(ref);
    }
    QuantitationType quantitationType = this.convertQuantitationType(metaData);
    /* set the quantitation types on the experiment */
    Collection<QuantitationType> qTypes = new HashSet<>();
    qTypes.add(quantitationType);
    experiment.setQuantitationTypes(qTypes);
    Collection<ArrayDesign> arrayDesigns = this.convertArrayDesigns(metaData, matrix);
    // Divide up multiple array designs into multiple BioAssayDimensions.
    Collection<RawExpressionDataVector> allVectors = new HashSet<>();
    Collection<BioAssay> allBioAssays = new HashSet<>();
    Collection<Object> usedDesignElements = new HashSet<>();
    for (ArrayDesign design : arrayDesigns) {
        SimpleExpressionDataLoaderServiceImpl.log.info("Processing " + design);
        DoubleMatrix<String, String> subMatrix = this.getSubMatrixForArrayDesign(matrix, usedDesignElements, design);
        if (subMatrix == null) {
            throw new IllegalStateException("Got a null matix");
        }
        BioAssayDimension bad = this.convertBioAssayDimension(experiment, design, taxon, subMatrix);
        Collection<RawExpressionDataVector> vectors = this.convertDesignElementDataVectors(experiment, bad, design, quantitationType, subMatrix);
        allVectors.addAll(vectors);
        allBioAssays.addAll(bad.getBioAssays());
    }
    // sanity
    if (usedDesignElements.size() != matrix.rows()) {
        SimpleExpressionDataLoaderServiceImpl.log.warn("Some rows of matrix were not matched to any of the given platforms (" + matrix.rows() + " rows, " + usedDesignElements.size() + " found");
    }
    experiment.setRawExpressionDataVectors(allVectors);
    experiment.setBioAssays(allBioAssays);
    return experiment;
}
Also used : ExperimentalDesign(ubic.gemma.model.expression.experiment.ExperimentalDesign) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) Taxon(ubic.gemma.model.genome.Taxon) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) RawExpressionDataVector(ubic.gemma.model.expression.bioAssayData.RawExpressionDataVector) PubMedXMLFetcher(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Example 40 with BibliographicReference

use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.

the class BibRefControllerTest method setup.

/*
     * Add a bibliographic reference to the database for testing purposes.
     */
@Before
public void setup() throws Exception {
    assert brs != null;
    PubMedXMLParser pmp = new PubMedXMLParser();
    try {
        Collection<BibliographicReference> brl = pmp.parse(this.getClass().getResourceAsStream("/data/pubmed-test.xml"));
        br = brl.iterator().next();
        /* set the bib ref's pubmed accession number to the database entry. */
        br.setPubAccession(this.getTestPersistentDatabaseEntry());
        /* bibref is now set. Call service to persist to database. */
        br = brs.findOrCreate(br);
        assert br.getId() != null;
    } catch (RuntimeException e) {
        if (e.getCause() instanceof java.net.ConnectException) {
            log.warn("Test skipped due to connection exception");
            return;
        } else if (e.getCause() instanceof java.net.UnknownHostException) {
            log.warn("Test skipped due to unknown host exception");
            return;
        } else {
            throw (e);
        }
    }
    ready = true;
}
Also used : PubMedXMLParser(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLParser) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Before(org.junit.Before)

Aggregations

BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)45 Test (org.junit.Test)18 BibliographicReferenceValueObject (ubic.gemma.model.common.description.BibliographicReferenceValueObject)9 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)8 PubMedXMLFetcher (ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher)6 IOException (java.io.IOException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)5 SearchSettings (ubic.gemma.model.common.search.SearchSettings)4 ArrayList (java.util.ArrayList)3 IndexerTaskCommand (ubic.gemma.core.tasks.maintenance.IndexerTaskCommand)3 DatabaseEntry (ubic.gemma.model.common.description.DatabaseEntry)3 MedicalSubjectHeading (ubic.gemma.model.common.description.MedicalSubjectHeading)3 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)3 URL (java.net.URL)2 Date (java.util.Date)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 ExternalDatabase (ubic.gemma.model.common.description.ExternalDatabase)2