Search in sources :

Example 1 with Compound

use of ubic.gemma.model.expression.biomaterial.Compound in project Gemma by PavlidisLab.

the class PubMedXMLParser method extractChemicals.

private Collection<Compound> extractChemicals(Node chemNodes) {
    Collection<Compound> compounds = new HashSet<>();
    NodeList childNodes = chemNodes.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node chemNode = childNodes.item(i);
        NodeList termNodes = chemNode.getChildNodes();
        if (termNodes.getLength() == 0)
            continue;
        Compound c = Compound.Factory.newInstance();
        for (int j = 0; j < termNodes.getLength(); j++) {
            Node item = termNodes.item(j);
            if (!(item instanceof Element)) {
                continue;
            }
            Element el = (Element) item;
            if (el.getNodeName().equals("RegistryNumber")) {
                String regString = XMLUtils.getTextValue(el);
                c.setRegistryNumber(regString);
            } else {
                String txt = XMLUtils.getTextValue(el);
                c.setName(txt);
            }
        }
        PubMedXMLParser.log.debug(c.getName());
        compounds.add(c);
    }
    return compounds;
}
Also used : Compound(ubic.gemma.model.expression.biomaterial.Compound) HashSet(java.util.HashSet)

Example 2 with Compound

use of ubic.gemma.model.expression.biomaterial.Compound 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 3 with Compound

use of ubic.gemma.model.expression.biomaterial.Compound in project Gemma by PavlidisLab.

the class ExpressionPersister method persist.

@Override
public Object persist(Object entity) {
    if (entity == null)
        return null;
    if (entity instanceof ExpressionExperiment) {
        AbstractPersister.log.warn("Consider doing the 'setup' step in a separate transaction");
        this.getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO);
        ArrayDesignsForExperimentCache c = expressionExperimentPrePersistService.prepare((ExpressionExperiment) entity);
        return this.persist((ExpressionExperiment) entity, c);
    } else if (entity instanceof BioAssayDimension) {
        return this.persistBioAssayDimension((BioAssayDimension) entity, null);
    } else if (entity instanceof BioMaterial) {
        return this.persistBioMaterial((BioMaterial) entity);
    } else if (entity instanceof BioAssay) {
        return this.persistBioAssay((BioAssay) entity, null);
    } else if (entity instanceof Compound) {
        return this.persistCompound((Compound) entity);
    } else if (entity instanceof ExpressionExperimentSubSet) {
        return this.persistExpressionExperimentSubSet((ExpressionExperimentSubSet) entity);
    }
    return super.persist(entity);
}
Also used : BioMaterial(ubic.gemma.model.expression.biomaterial.BioMaterial) BioAssayDimension(ubic.gemma.model.expression.bioAssayData.BioAssayDimension) Compound(ubic.gemma.model.expression.biomaterial.Compound) ArrayDesignsForExperimentCache(ubic.gemma.persistence.util.ArrayDesignsForExperimentCache) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay)

Aggregations

Compound (ubic.gemma.model.expression.biomaterial.Compound)3 HashSet (java.util.HashSet)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 Test (org.junit.Test)1 BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)1 Keyword (ubic.gemma.model.common.description.Keyword)1 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)1 BioAssayDimension (ubic.gemma.model.expression.bioAssayData.BioAssayDimension)1 BioMaterial (ubic.gemma.model.expression.biomaterial.BioMaterial)1 ArrayDesignsForExperimentCache (ubic.gemma.persistence.util.ArrayDesignsForExperimentCache)1