use of org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty in project nextprot-api by calipho-sib.
the class AnnotationTest method buildEvidence.
private AnnotationEvidence buildEvidence(String level) {
AnnotationEvidenceProperty p = new AnnotationEvidenceProperty();
p.setPropertyName("expressionLevel");
p.setPropertyValue(level);
List<AnnotationEvidenceProperty> props = new ArrayList<>();
props.add(p);
AnnotationEvidence ev = new AnnotationEvidence();
ev.setProperties(props);
return ev;
}
use of org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty in project nextprot-api by calipho-sib.
the class StatementAnnotationBuilder method addPropertyIfPresent.
private static AnnotationEvidenceProperty addPropertyIfPresent(String propertyValue, String propertyName) {
if (propertyValue != null) {
AnnotationEvidenceProperty prop = new AnnotationEvidenceProperty();
prop.setPropertyName(propertyName);
prop.setPropertyValue(propertyValue);
return prop;
}
return null;
}
use of org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty in project nextprot-api by calipho-sib.
the class StatementAnnotationBuilder method buildAnnotationEvidences.
protected List<AnnotationEvidence> buildAnnotationEvidences(List<Statement> Statements) {
// Ensures there is no repeated evidence!
Set<AnnotationEvidence> evidencesSet = Statements.stream().map(s -> {
AnnotationEvidence evidence = new AnnotationEvidence();
// TODO to be checked with Amos and Lydie
evidence.setResourceType("database");
evidence.setResourceAssociationType("evidence");
evidence.setQualityQualifier(s.getValue(StatementField.EVIDENCE_QUALITY));
evidence.setResourceId(findPublicationId(s));
AnnotationEvidenceProperty evidenceProperty = addPropertyIfPresent(s.getValue(StatementField.EVIDENCE_INTENSITY), "intensity");
AnnotationEvidenceProperty expContextSubjectProteinOrigin = addPropertyIfPresent(s.getValue(StatementField.ANNOTATION_SUBJECT_SPECIES), "subject-protein-origin");
AnnotationEvidenceProperty expContextObjectProteinOrigin = addPropertyIfPresent(s.getValue(StatementField.ANNOTATION_OBJECT_SPECIES), "object-protein-origin");
// Set properties which are not null
evidence.setProperties(Arrays.asList(evidenceProperty, expContextSubjectProteinOrigin, expContextObjectProteinOrigin).stream().filter(p -> p != null).collect(Collectors.toList()));
String statementEvidenceCode = s.getValue(StatementField.EVIDENCE_CODE);
evidence.setEvidenceCodeAC(statementEvidenceCode);
evidence.setAssignedBy(s.getValue(StatementField.ASSIGNED_BY));
evidence.setAssignmentMethod(s.getValue(StatementField.ASSIGMENT_METHOD));
evidence.setResourceType(s.getValue(StatementField.RESOURCE_TYPE));
evidence.setEvidenceCodeOntology("evidence-code-ontology-cv");
evidence.setNegativeEvidence("true".equalsIgnoreCase(s.getValue(StatementField.IS_NEGATIVE)));
if (statementEvidenceCode != null) {
CvTerm term = terminologyService.findCvTermByAccession(statementEvidenceCode);
if (term != null) {
evidence.setEvidenceCodeName(term.getName());
} else {
throw new NextProtException("Not found " + statementEvidenceCode + " in the database");
}
}
evidence.setNote(s.getValue(StatementField.EVIDENCE_NOTE));
return evidence;
}).collect(Collectors.toSet());
// Ensures there is no repeated evidence!
evidencesSet.forEach(e -> {
long generatedEvidenceId = IdentifierOffset.EVIDENCE_ID_COUNTER_FOR_STATEMENTS.incrementAndGet();
e.setEvidenceId(generatedEvidenceId);
});
List<AnnotationEvidence> evidencesFiltered = evidencesSet.stream().filter(e -> e.getResourceId() != -2).collect(Collectors.toList());
if (evidencesFiltered.size() < evidencesSet.size()) {
int total = evidencesSet.size();
int removed = total - evidencesFiltered.size();
LOGGER.debug("Removed " + removed + " evidence because no resource id from a total of " + total);
}
return new ArrayList<>(evidencesFiltered);
}
Aggregations