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;
}
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);
}
}
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);
}
Aggregations