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