use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class PubMedXMLParserTest method testParseMultipartAbstract.
@Test
public void testParseMultipartAbstract() {
try {
testStream = PubMedXMLParserTest.class.getResourceAsStream("/data/pubmed-mpabs.xml");
Collection<BibliographicReference> brl = testParser.parse(testStream);
BibliographicReference br = brl.iterator().next();
assertNotNull(br.getAbstractText());
assertTrue(br.getAbstractText().startsWith("PURPOSE: To dete"));
assertTrue(br.getAbstractText().contains("METHODS: RGCs of Brown Norway rats were retrogradely labeled bilaterally with the " + "fluorescent dye 4-(4-(dihexadecylamino)styryl)-N"));
assertTrue(br.getAbstractText().contains("CONCLUSIONS: The SLO is useful for in vivo imaging of rat RGCs"));
PubMedXMLParserTest.log.info(br.getAbstractText());
} catch (RuntimeException e) {
this.logOrThrowException(e);
}
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceServiceImpl method refresh.
@Override
@Transactional
public BibliographicReference refresh(String pubMedId) {
if (StringUtils.isBlank(pubMedId)) {
throw new IllegalArgumentException("Must provide a pubmed ID");
}
BibliographicReference existingBibRef = this.findByExternalId(pubMedId, BibliographicReferenceServiceImpl.PUB_MED_DATABASE_NAME);
if (existingBibRef == null) {
return null;
}
existingBibRef = this.thaw(existingBibRef);
String oldAccession = existingBibRef.getPubAccession().getAccession();
if (StringUtils.isNotBlank(oldAccession) && !oldAccession.equals(pubMedId)) {
throw new IllegalArgumentException("The pubmed accession is already set and doesn't match the one provided");
}
existingBibRef.getPubAccession().setAccession(pubMedId);
BibliographicReference fresh = this.pubMedXmlFetcher.retrieveByHTTP(Integer.parseInt(pubMedId));
if (fresh == null || fresh.getPublicationDate() == null) {
throw new IllegalStateException("Unable to retrieve record from pubmed for id=" + pubMedId);
}
assert fresh.getPubAccession().getAccession().equals(pubMedId);
existingBibRef.setPublicationDate(fresh.getPublicationDate());
existingBibRef.setAuthorList(fresh.getAuthorList());
existingBibRef.setAbstractText(fresh.getAbstractText());
existingBibRef.setIssue(fresh.getIssue());
existingBibRef.setTitle(fresh.getTitle());
existingBibRef.setFullTextUri(fresh.getFullTextUri());
existingBibRef.setEditor(fresh.getEditor());
existingBibRef.setPublisher(fresh.getPublisher());
existingBibRef.setCitation(fresh.getCitation());
existingBibRef.setPublication(fresh.getPublication());
existingBibRef.setMeshTerms(fresh.getMeshTerms());
existingBibRef.setChemicals(fresh.getChemicals());
existingBibRef.setKeywords(fresh.getKeywords());
existingBibRef.setPages(fresh.getPages());
existingBibRef.setVolume(fresh.getVolume());
this.update(existingBibRef);
return existingBibRef;
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceServiceImpl method search.
@Override
@Transactional(readOnly = true)
public List<BibliographicReferenceValueObject> search(String query) {
// noinspection unchecked
List<BibliographicReference> resultEntities = (List<BibliographicReference>) searchService.search(SearchSettingsImpl.bibliographicReferenceSearch(query), BibliographicReference.class);
List<BibliographicReferenceValueObject> results = new ArrayList<>();
for (BibliographicReference entity : resultEntities) {
BibliographicReferenceValueObject vo = new BibliographicReferenceValueObject(entity);
this.populateBibliographicPhenotypes(vo);
this.populateRelatedExperiments(entity, vo);
results.add(vo);
}
return results;
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceServiceImpl method findVOByExternalId.
/**
* @see BibliographicReferenceService#findVOByExternalId(String)
*/
@Override
@Transactional(readOnly = true)
public BibliographicReferenceValueObject findVOByExternalId(final String id) {
try {
BibliographicReference bibref = this.findByExternalId(id);
if (bibref == null) {
return null;
}
BibliographicReferenceValueObject bibrefVO = new BibliographicReferenceValueObject(bibref);
this.populateBibliographicPhenotypes(bibrefVO);
this.populateRelatedExperiments(bibref, bibrefVO);
return bibrefVO;
} catch (Throwable th) {
throw new RuntimeException("Error performing 'BibliographicReferenceService.findByExternalId(String id)' --> " + th, th);
}
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class MeshTermFetcherCli method processChunk.
private void processChunk(PubMedXMLFetcher fetcher, Collection<Integer> ids) throws IOException {
Collection<BibliographicReference> refs = fetcher.retrieveByHTTP(ids);
for (BibliographicReference r : refs) {
System.out.print(r.getPubAccession().getAccession() + "\t");
Collection<MedicalSubjectHeading> meshTerms = r.getMeshTerms();
List<String> t = new ArrayList<>();
for (MedicalSubjectHeading mesh : meshTerms) {
String term = mesh.getTerm();
if (majorTopicsOnly && !mesh.getIsMajorTopic())
continue;
t.add(term);
}
Collections.sort(t);
System.out.print(StringUtils.join(t, "|"));
System.out.print("\n");
}
}
Aggregations