Search in sources :

Example 1 with AnnotationEvidenceProperty

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;
}
Also used : AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) AnnotationEvidenceProperty(org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty) ArrayList(java.util.ArrayList)

Example 2 with AnnotationEvidenceProperty

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;
}
Also used : AnnotationEvidenceProperty(org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty)

Example 3 with AnnotationEvidenceProperty

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);
}
Also used : java.util(java.util) Supplier(com.google.common.base.Supplier) Annotation(org.nextprot.api.core.domain.annotation.Annotation) NextProtException(org.nextprot.api.commons.exception.NextProtException) StringUtils(org.nextprot.api.commons.utils.StringUtils) CvTerm(org.nextprot.api.core.domain.CvTerm) StatementField(org.nextprot.commons.statements.StatementField) Collectors(java.util.stream.Collectors) Statement(org.nextprot.commons.statements.Statement) BioType(org.nextprot.api.core.domain.BioObject.BioType) AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) Logger(org.apache.log4j.Logger) Publication(org.nextprot.api.core.domain.Publication) AnnotationCategory(org.nextprot.api.commons.constants.AnnotationCategory) AnnotationUtils(org.nextprot.api.core.service.annotation.AnnotationUtils) AnnotationEvidenceProperty(org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty) IdentifierOffset(org.nextprot.api.commons.constants.IdentifierOffset) BioObject(org.nextprot.api.core.domain.BioObject) AnnotationVariant(org.nextprot.api.core.domain.annotation.AnnotationVariant) AnnotationEvidence(org.nextprot.api.core.domain.annotation.AnnotationEvidence) NextProtException(org.nextprot.api.commons.exception.NextProtException) CvTerm(org.nextprot.api.core.domain.CvTerm) AnnotationEvidenceProperty(org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty)

Aggregations

AnnotationEvidenceProperty (org.nextprot.api.core.domain.annotation.AnnotationEvidenceProperty)3 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)2 Supplier (com.google.common.base.Supplier)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Collectors (java.util.stream.Collectors)1 Logger (org.apache.log4j.Logger)1 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)1 IdentifierOffset (org.nextprot.api.commons.constants.IdentifierOffset)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 StringUtils (org.nextprot.api.commons.utils.StringUtils)1 BioObject (org.nextprot.api.core.domain.BioObject)1 BioType (org.nextprot.api.core.domain.BioObject.BioType)1 CvTerm (org.nextprot.api.core.domain.CvTerm)1 Publication (org.nextprot.api.core.domain.Publication)1 Annotation (org.nextprot.api.core.domain.annotation.Annotation)1 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)1 AnnotationUtils (org.nextprot.api.core.service.annotation.AnnotationUtils)1 Statement (org.nextprot.commons.statements.Statement)1 StatementField (org.nextprot.commons.statements.StatementField)1