use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class GeoServiceImpl method getPubMedInfo.
private void getPubMedInfo(Collection<ExpressionExperiment> result) {
for (ExpressionExperiment experiment : result) {
BibliographicReference pubmed = experiment.getPrimaryPublication();
if (pubmed == null)
continue;
PubMedXMLFetcher fetcher = new PubMedXMLFetcher();
try {
pubmed = fetcher.retrieveByHTTP(Integer.parseInt(pubmed.getPubAccession().getAccession()));
} catch (Exception e) {
AbstractGeoService.log.warn("Filed to get data from pubmed, continuing without it.");
AbstractGeoService.log.error(e, e);
}
if (pubmed == null)
continue;
experiment.setPrimaryPublication(pubmed);
}
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class GeeqServiceImpl method scorePublication.
/*
* Suitability scoring methods
*/
private void scorePublication(ExpressionExperiment ee, Geeq gq) {
double score;
boolean hasBib;
BibliographicReference bib = null;
if (ee.getPrimaryPublication() != null) {
bib = ee.getPrimaryPublication();
} else if (ee.getOtherRelevantPublications() != null && ee.getOtherRelevantPublications().size() > 0) {
bib = ee.getOtherRelevantPublications().iterator().next();
}
hasBib = bib != null;
score = !hasBib ? GeeqServiceImpl.N_10 : GeeqServiceImpl.P_10;
gq.setsScorePublication(score);
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class BibliographicReferenceDaoImpl method getRelatedExperiments.
@Override
public Map<BibliographicReference, Collection<ExpressionExperiment>> getRelatedExperiments(Collection<BibliographicReference> records) {
final String query = "select distinct e, b from ExpressionExperiment " + "e join e.primaryPublication b left join fetch b.pubAccession where b in (:recs)";
Map<BibliographicReference, Collection<ExpressionExperiment>> result = new HashMap<>();
for (Collection<BibliographicReference> batch : BatchIterator.batches(records, 200)) {
// noinspection unchecked
List<Object[]> os = this.getSessionFactory().getCurrentSession().createQuery(query).setParameterList("recs", batch).list();
for (Object[] o : os) {
ExpressionExperiment e = (ExpressionExperiment) o[0];
BibliographicReference b = (BibliographicReference) o[1];
if (!result.containsKey(b)) {
result.put(b, new HashSet<ExpressionExperiment>());
}
result.get(b).add(e);
}
}
return result;
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class PubMedSearcher method doWork.
@Override
protected Exception doWork(String[] args) {
Exception err = this.processCommandLine(args);
if (err != null)
return err;
try {
@SuppressWarnings("unchecked") Collection<BibliographicReference> refs = PubMedSearcher.pms.searchAndRetrieveByHTTP((Collection<String>) this.getArgList());
System.out.println(refs.size() + " references found");
if (this.hasOption("d")) {
this.getPersisterHelper().persist(refs);
}
} catch (IOException | ParserConfigurationException | SAXException e) {
return e;
}
this.resetLogging();
return null;
}
use of ubic.gemma.model.common.description.BibliographicReference in project Gemma by PavlidisLab.
the class PubMedXMLFetcher method retrieveByHTTP.
public BibliographicReference retrieveByHTTP(int pubMedId) {
Collection<BibliographicReference> results = null;
try {
for (int i = 0; i < MAX_TRIES; i++) {
URL toBeGotten = new URL(uri + pubMedId);
log.debug("Fetching " + toBeGotten);
PubMedXMLParser pmxp = new PubMedXMLParser();
results = pmxp.parse(toBeGotten.openStream());
if (results != null && results.size() > 0)
break;
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// noop
}
}
if (results == null || results.size() == 0) {
return null;
}
assert results.size() == 1;
return results.iterator().next();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations