Search in sources :

Example 21 with BibliographicReference

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);
    }
}
Also used : PubMedXMLFetcher(ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) AlreadyExistsInSystemException(ubic.gemma.core.loader.util.AlreadyExistsInSystemException)

Example 22 with BibliographicReference

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);
}
Also used : BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

Example 23 with BibliographicReference

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;
}
Also used : BibliographicReferenceValueObject(ubic.gemma.model.common.description.BibliographicReferenceValueObject) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) ExpressionExperiment(ubic.gemma.model.expression.experiment.ExpressionExperiment)

Example 24 with BibliographicReference

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;
}
Also used : IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException)

Example 25 with BibliographicReference

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);
    }
}
Also used : IOException(java.io.IOException) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) URL(java.net.URL)

Aggregations

BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)45 Test (org.junit.Test)18 BibliographicReferenceValueObject (ubic.gemma.model.common.description.BibliographicReferenceValueObject)9 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)8 PubMedXMLFetcher (ubic.gemma.core.loader.entrez.pubmed.PubMedXMLFetcher)6 IOException (java.io.IOException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 BaseSpringContextTest (ubic.gemma.core.testing.BaseSpringContextTest)5 SearchSettings (ubic.gemma.model.common.search.SearchSettings)4 ArrayList (java.util.ArrayList)3 IndexerTaskCommand (ubic.gemma.core.tasks.maintenance.IndexerTaskCommand)3 DatabaseEntry (ubic.gemma.model.common.description.DatabaseEntry)3 MedicalSubjectHeading (ubic.gemma.model.common.description.MedicalSubjectHeading)3 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)3 URL (java.net.URL)2 Date (java.util.Date)2 StopWatch (org.apache.commons.lang3.time.StopWatch)2 ExternalDatabase (ubic.gemma.model.common.description.ExternalDatabase)2