use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class SearchServiceTest method testSearchByBibRefId.
@Test
public void testSearchByBibRefId() {
try {
this.setup();
} catch (Exception e) {
e.printStackTrace();
}
String id;
if (ee.getPrimaryPublication() == null) {
PubMedXMLFetcher fetcher = new PubMedXMLFetcher();
BibliographicReference bibref = fetcher.retrieveByHTTP(21878914);
bibref = (BibliographicReference) persisterHelper.persist(bibref);
ee.setPrimaryPublication(bibref);
eeService.update(ee);
id = "21878914";
} else {
id = ee.getPrimaryPublication().getPubAccession().getAccession();
}
log.info("indexing ...");
IndexerTaskCommand c = new IndexerTaskCommand();
c.setIndexBibRef(true);
indexerTask.setTaskCommand(c);
indexerTask.execute();
SearchSettings settings = SearchSettings.Factory.newInstance();
settings.noSearches();
settings.setQuery(id);
settings.setSearchExperiments(true);
settings.setUseCharacteristics(false);
Map<Class<?>, List<SearchResult>> found = this.searchService.search(settings);
assertTrue(!found.isEmpty());
for (SearchResult sr : found.get(ExpressionExperiment.class)) {
if (sr.getResultObject().equals(ee)) {
this.tearDown();
return;
}
}
this.tearDown();
fail("Didn't get expected result from search");
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class PubMedXMLFetcherTest method testRetrieveByHTTP.
@Test
public final void testRetrieveByHTTP() {
try {
BibliographicReference br = pmf.retrieveByHTTP(15173114);
assertNotNull(br);
assertEquals("Lee, Homin K; Hsu, Amy K; Sajdak, Jon; Qin, Jie; Pavlidis, Paul", br.getAuthorList());
assertEquals("Genome Res", br.getPublication());
assertEquals("Coexpression analysis of human genes across many microarray data sets.", br.getTitle());
SimpleDateFormat f = new SimpleDateFormat("mm/HH/MM/dd/yyyy");
assertEquals("00/00/06/01/2004", f.format(br.getPublicationDate()));
} catch (RuntimeException e) {
this.checkCause(e);
}
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class PubMedXMLFetcherTest method testRetrieveByHTTP2.
@Test
public final void testRetrieveByHTTP2() {
try {
BibliographicReference br = pmf.retrieveByHTTP(24850731);
assertNotNull(br);
assertEquals("Iwata-Yoshikawa, Naoko; Uda, Akihiko; Suzuki, Tadaki; Tsunetsugu-Yokota, Yasuko; Sato, Yuko; " + "Morikawa, Shigeru; Tashiro, Masato; Sata, Tetsutaro; Hasegawa, Hideki; Nagata, Noriyo", br.getAuthorList());
assertEquals("J Virol", br.getPublication());
} catch (RuntimeException e) {
this.checkCause(e);
}
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibRefUpdaterCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception ex = super.processCommandLine(args);
if (ex != null)
return ex;
BibliographicReferenceService bibliographicReferenceService = this.getBean(BibliographicReferenceService.class);
Collection<Long> bibrefIds = new ArrayList<>();
if (this.hasOption("pmids")) {
for (String s : StringUtils.split(this.getOptionValue("pmids"), ",")) {
BibliographicReference found = bibliographicReferenceService.findByExternalId(s);
if (found == null) {
log.warn("Did not find " + s);
continue;
}
bibrefIds.add(found.getId());
}
} else {
log.info("Updating all bibrefs in the system ...");
bibrefIds = bibliographicReferenceService.listAll();
}
log.info("There are " + bibrefIds.size() + " to update");
for (Long id : bibrefIds) {
BibliographicReference bibref = bibliographicReferenceService.load(id);
if (bibref == null) {
log.info("No reference with id=" + id);
continue;
}
bibref = bibliographicReferenceService.thaw(bibref);
try {
BibliographicReference updated = bibliographicReferenceService.refresh(bibref.getPubAccession().getAccession());
log.info(updated);
} catch (Exception e) {
log.info("Failed to update: " + bibref + " (" + e.getMessage() + ")");
}
try {
Thread.sleep(RandomUtils.nextInt(1000));
} catch (InterruptedException e) {
return e;
}
}
return null;
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceServiceTest method testfind.
@Test
public final void testfind() {
BibliographicReference result = this.bibliographicReferenceService.find(testBibRef);
assertNotNull(result);
}
Aggregations