Search in sources :

Example 1 with Publication

use of org.intermine.model.bio.Publication in project intermine by intermine.

the class EntrezPublicationsRetriever method getPublications.

/**
 * Retrieve the publications to be updated
 * @param os The ObjectStore to read from
 * @return a List of publications
 */
protected List<Publication> getPublications(ObjectStore os) {
    Query q = new Query();
    QueryClass qc = new QueryClass(Publication.class);
    q.addFrom(qc);
    q.addToSelect(qc);
    ConstraintSet cs = new ConstraintSet(ConstraintOp.OR);
    SimpleConstraint scTitle = new SimpleConstraint(new QueryField(qc, "title"), ConstraintOp.IS_NULL);
    cs.addConstraint(scTitle);
    SimpleConstraint scYear = new SimpleConstraint(new QueryField(qc, "year"), ConstraintOp.IS_NULL);
    cs.addConstraint(scYear);
    SimpleConstraint scFirstAuthor = new SimpleConstraint(new QueryField(qc, "firstAuthor"), ConstraintOp.IS_NULL);
    cs.addConstraint(scFirstAuthor);
    q.setConstraint(cs);
    List<Publication> retval = ((List) os.executeSingleton(q));
    return retval;
}
Also used : Query(org.intermine.objectstore.query.Query) QueryField(org.intermine.objectstore.query.QueryField) Publication(org.intermine.model.bio.Publication) ConstraintSet(org.intermine.objectstore.query.ConstraintSet) QueryClass(org.intermine.objectstore.query.QueryClass) SimpleConstraint(org.intermine.objectstore.query.SimpleConstraint)

Example 2 with Publication

use of org.intermine.model.bio.Publication in project intermine by intermine.

the class GoPostprocess method mergeEvidence.

// we've seen this term, merge instead of storing new object
private void mergeEvidence(Set<OntologyEvidence> evidence, GOAnnotation alreadySeenAnnotation) {
    for (OntologyEvidence g : evidence) {
        OntologyAnnotationEvidenceCode c = g.getCode();
        Set<Publication> pubs = g.getPublications();
        boolean foundMatch = false;
        for (OntologyEvidence alreadySeenEvidence : alreadySeenAnnotation.getEvidence()) {
            OntologyAnnotationEvidenceCode alreadySeenCode = alreadySeenEvidence.getCode();
            Set<Publication> alreadySeenPubs = alreadySeenEvidence.getPublications();
            // we've already seen this evidence code, just merge pubs
            if (c.equals(alreadySeenCode)) {
                foundMatch = true;
                alreadySeenPubs = mergePubs(alreadySeenPubs, pubs);
            }
        }
        if (!foundMatch) {
            // we don't have this evidence code
            alreadySeenAnnotation.addEvidence(g);
        }
    }
}
Also used : OntologyAnnotationEvidenceCode(org.intermine.model.bio.OntologyAnnotationEvidenceCode) Publication(org.intermine.model.bio.Publication) OntologyEvidence(org.intermine.model.bio.OntologyEvidence)

Example 3 with Publication

use of org.intermine.model.bio.Publication in project intermine by intermine.

the class GoPostprocessTest method setUpDuplicateData.

// one gene, two proteins, ONE annotation, different evidence codes - they should merge
private void setUpDuplicateData() throws Exception {
    Gene gene = (Gene) DynamicUtil.createObject(Collections.singleton(Gene.class));
    Protein protein1 = (Protein) DynamicUtil.createObject(Collections.singleton(Protein.class));
    protein1.addGenes(gene);
    Protein protein2 = (Protein) DynamicUtil.createObject(Collections.singleton(Protein.class));
    protein2.addGenes(gene);
    GOAnnotation go1 = (GOAnnotation) DynamicUtil.createObject(Collections.singleton(GOAnnotation.class));
    go1.setSubject(protein1);
    OntologyTerm ontologyTerm = (OntologyTerm) DynamicUtil.createObject(Collections.singleton(OntologyTerm.class));
    go1.setOntologyTerm(ontologyTerm);
    GOEvidence evidence1 = (GOEvidence) DynamicUtil.createObject(Collections.singleton(GOEvidence.class));
    GOEvidenceCode code1 = (GOEvidenceCode) DynamicUtil.createObject(Collections.singleton(GOEvidenceCode.class));
    evidence1.setCode(code1);
    Publication pub1 = (Publication) DynamicUtil.createObject(Collections.singleton(Publication.class));
    evidence1.addPublications(pub1);
    go1.setEvidence(Collections.singleton(evidence1));
    GOAnnotation go2 = (GOAnnotation) DynamicUtil.createObject(Collections.singleton(GOAnnotation.class));
    go2.setSubject(protein2);
    go2.setOntologyTerm(ontologyTerm);
    GOEvidence evidence2 = (GOEvidence) DynamicUtil.createObject(Collections.singleton(GOEvidence.class));
    GOEvidenceCode code2 = (GOEvidenceCode) DynamicUtil.createObject(Collections.singleton(GOEvidenceCode.class));
    evidence2.setCode(code2);
    Publication pub2 = (Publication) DynamicUtil.createObject(Collections.singleton(Publication.class));
    evidence2.addPublications(pub2);
    go2.setEvidence(Collections.singleton(evidence2));
    List toStore = new ArrayList(Arrays.asList(new Object[] { gene, protein1, protein2, go1, ontologyTerm, evidence1, code1, pub1, go2, ontologyTerm, evidence2, code2, pub2 }));
    osw.beginTransaction();
    Iterator i = toStore.iterator();
    while (i.hasNext()) {
        osw.store((InterMineObject) i.next());
    }
    osw.commitTransaction();
}
Also used : Gene(org.intermine.model.bio.Gene) GOEvidence(org.intermine.model.bio.GOEvidence) GOEvidenceCode(org.intermine.model.bio.GOEvidenceCode) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Publication(org.intermine.model.bio.Publication) ArrayList(java.util.ArrayList) List(java.util.List) InterMineObject(org.intermine.model.InterMineObject) OntologyTerm(org.intermine.model.bio.OntologyTerm) Protein(org.intermine.model.bio.Protein) GOAnnotation(org.intermine.model.bio.GOAnnotation)

Example 4 with Publication

use of org.intermine.model.bio.Publication in project intermine by intermine.

the class GoPostprocessTest method setUpAnnotations.

private List setUpAnnotations(Protein protein, OntologyTerm ontologyTerm) {
    GOAnnotation go = (GOAnnotation) DynamicUtil.createObject(Collections.singleton(GOAnnotation.class));
    go.setSubject(protein);
    go.setOntologyTerm(ontologyTerm);
    GOEvidence evidence = (GOEvidence) DynamicUtil.createObject(Collections.singleton(GOEvidence.class));
    GOEvidenceCode code = (GOEvidenceCode) DynamicUtil.createObject(Collections.singleton(GOEvidenceCode.class));
    evidence.setCode(code);
    Publication pub = (Publication) DynamicUtil.createObject(Collections.singleton(Publication.class));
    evidence.addPublications(pub);
    go.setEvidence(Collections.singleton(evidence));
    return new ArrayList(Arrays.asList(new Object[] { go, ontologyTerm, evidence, code, pub }));
}
Also used : GOEvidence(org.intermine.model.bio.GOEvidence) GOEvidenceCode(org.intermine.model.bio.GOEvidenceCode) ArrayList(java.util.ArrayList) Publication(org.intermine.model.bio.Publication) InterMineObject(org.intermine.model.InterMineObject) GOAnnotation(org.intermine.model.bio.GOAnnotation)

Example 5 with Publication

use of org.intermine.model.bio.Publication in project intermine by intermine.

the class PublicationCountsDisplayer method display.

@Override
public void display(HttpServletRequest request, ReportObject reportObject) {
    Map<Publication, String> publications = new LinkedHashMap<Publication, String>();
    InterMineObject object = reportObject.getObject();
    String type = DynamicUtil.getSimpleClass(object).getSimpleName();
    HttpSession session = request.getSession();
    final InterMineAPI im = SessionMethods.getInterMineAPI(session);
    Query q = getQuery(im, object, type);
    ObjectStore os = im.getObjectStore();
    Results results = os.execute(q, 2000, true, true, true);
    Iterator<Object> it = results.iterator();
    int i = 0;
    while (it.hasNext()) {
        ResultsRow rr = (ResultsRow) it.next();
        Publication pub = (Publication) rr.get(0);
        Long count = (Long) rr.get(1);
        publications.put(pub, count.toString());
        i++;
    }
    request.setAttribute("totalNumberOfPubs", i);
    request.setAttribute("results", publications);
    request.setAttribute("type", type);
    if (results.isEmpty()) {
        request.setAttribute("noResults", "No publications found");
    }
}
Also used : InterMineObject(org.intermine.model.InterMineObject) ObjectStore(org.intermine.objectstore.ObjectStore) Query(org.intermine.objectstore.query.Query) HttpSession(javax.servlet.http.HttpSession) InterMineAPI(org.intermine.api.InterMineAPI) Publication(org.intermine.model.bio.Publication) ResultsRow(org.intermine.objectstore.query.ResultsRow) ContainsConstraint(org.intermine.objectstore.query.ContainsConstraint) LinkedHashMap(java.util.LinkedHashMap) Results(org.intermine.objectstore.query.Results) ReportObject(org.intermine.web.logic.results.ReportObject) InterMineObject(org.intermine.model.InterMineObject)

Aggregations

Publication (org.intermine.model.bio.Publication)6 InterMineObject (org.intermine.model.InterMineObject)3 ArrayList (java.util.ArrayList)2 GOAnnotation (org.intermine.model.bio.GOAnnotation)2 GOEvidence (org.intermine.model.bio.GOEvidence)2 GOEvidenceCode (org.intermine.model.bio.GOEvidenceCode)2 ObjectStore (org.intermine.objectstore.ObjectStore)2 Query (org.intermine.objectstore.query.Query)2 SimpleConstraint (org.intermine.objectstore.query.SimpleConstraint)2 Database (com.sleepycat.je.Database)1 DatabaseConfig (com.sleepycat.je.DatabaseConfig)1 DatabaseEntry (com.sleepycat.je.DatabaseEntry)1 Environment (com.sleepycat.je.Environment)1 EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)1 Transaction (com.sleepycat.je.Transaction)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 EOFException (java.io.EOFException)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1