Search in sources :

Example 1 with MedicalSubjectHeading

use of ubic.gemma.model.common.description.MedicalSubjectHeading in project Gemma by PavlidisLab.

the class PubMedXMLParserTest method testParseMesh.

@Test
public void testParseMesh() {
    try {
        testStream = PubMedXMLParserTest.class.getResourceAsStream("/data/pubmed-mesh-test.xml");
        Collection<BibliographicReference> brl = testParser.parse(testStream);
        BibliographicReference br = brl.iterator().next();
        Collection<MedicalSubjectHeading> meshTerms = br.getMeshTerms();
        assertEquals(16, meshTerms.size());
    // for ( MedicalSubjectHeading heading : meshTerms ) {
    // log.info( heading.getTerm() + " " + heading.getIsMajorTopic() );
    // for ( MedicalSubjectHeading q : heading.getQualifiers() ) {
    // log.info( " qualifier: " + q.getTerm() + " " + q.getIsMajorTopic() );
    // }
    // }
    } catch (RuntimeException e) {
        this.logOrThrowException(e);
    }
}
Also used : MedicalSubjectHeading(ubic.gemma.model.common.description.MedicalSubjectHeading) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference) Test(org.junit.Test)

Example 2 with MedicalSubjectHeading

use of ubic.gemma.model.common.description.MedicalSubjectHeading 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");
    }
}
Also used : ArrayList(java.util.ArrayList) MedicalSubjectHeading(ubic.gemma.model.common.description.MedicalSubjectHeading) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

Example 3 with MedicalSubjectHeading

use of ubic.gemma.model.common.description.MedicalSubjectHeading in project Gemma by PavlidisLab.

the class LoadEvidenceForClassifier method findMeshTerms.

// return mesh term of a pubmed format : meshTerm1;meshTerm2;meshTerms3.... etc
private String findMeshTerms(String pubmed) {
    StringBuilder result = new StringBuilder();
    DatabaseEntry de = DatabaseEntry.Factory.newInstance();
    de.setAccession(pubmed);
    BibliographicReference bi = BibliographicReference.Factory.newInstance();
    bi.setPubAccession(de);
    System.out.println(pubmed);
    BibliographicReference b = this.bibliographicReferenceService.find(bi);
    for (MedicalSubjectHeading m : b.getMeshTerms()) {
        result.append(m.getTerm()).append(";");
    }
    return result.toString();
}
Also used : DatabaseEntry(ubic.gemma.model.common.description.DatabaseEntry) MedicalSubjectHeading(ubic.gemma.model.common.description.MedicalSubjectHeading) BibliographicReference(ubic.gemma.model.common.description.BibliographicReference)

Aggregations

BibliographicReference (ubic.gemma.model.common.description.BibliographicReference)3 MedicalSubjectHeading (ubic.gemma.model.common.description.MedicalSubjectHeading)3 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 DatabaseEntry (ubic.gemma.model.common.description.DatabaseEntry)1