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;
}
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);
}
}
}
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();
}
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 }));
}
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");
}
}
Aggregations