Search in sources :

Example 21 with AnnotationIsoformSpecificity

use of org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity in project nextprot-api by calipho-sib.

the class StatementEntryAnnotationBuilder method setIsoformTargeting.

@Override
void setIsoformTargeting(Annotation annotation, Statement statement) {
    List<AnnotationIsoformSpecificity> targetingIsoforms = new ArrayList<AnnotationIsoformSpecificity>();
    Set<TargetIsoformStatementPosition> tispSet = TargetIsoformSet.deSerializeFromJsonString(statement.getValue(StatementField.TARGET_ISOFORMS));
    for (TargetIsoformStatementPosition tisp : tispSet) {
        AnnotationIsoformSpecificity ais = new AnnotationIsoformSpecificity();
        String isoAc = tisp.getIsoformAccession();
        ais.setIsoformAccession(isoAc);
        ais.setFirstPosition(tisp.getBegin());
        ais.setLastPosition(tisp.getEnd());
        ais.setSpecificity(tisp.getSpecificity());
        ais.setName(tisp.getName());
        targetingIsoforms.add(ais);
    }
    annotation.addTargetingIsoforms(targetingIsoforms);
}
Also used : ArrayList(java.util.ArrayList) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) TargetIsoformStatementPosition(org.nextprot.commons.statements.TargetIsoformStatementPosition)

Example 22 with AnnotationIsoformSpecificity

use of org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity in project nextprot-api by calipho-sib.

the class DbXrefServiceImpl method newAnnotationIsoformSpecificityList.

// build isoform specificity from isoforms and annotations and link them to annotations
private List<AnnotationIsoformSpecificity> newAnnotationIsoformSpecificityList(List<Isoform> isoforms, Annotation xrefAnnotation) {
    List<AnnotationIsoformSpecificity> isospecs = new ArrayList<>();
    for (Isoform iso : isoforms) {
        AnnotationIsoformSpecificity isospec = new AnnotationIsoformSpecificity();
        isospec.setAnnotationId(xrefAnnotation.getAnnotationId());
        // According to PAM on Tuesday th 16th in the presence of Pascale and Frederic Nikitin
        isospec.setFirstPosition(null);
        isospec.setLastPosition(null);
        isospec.setIsoformAccession(iso.getIsoformAccession());
        isospec.setSpecificity("UNKNOWN");
        isospecs.add(isospec);
    }
    return isospecs;
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Isoform(org.nextprot.api.core.domain.Isoform)

Example 23 with AnnotationIsoformSpecificity

use of org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity in project nextprot-api by calipho-sib.

the class EntryUtils method getProteoformAnnotationsMap.

/**
 * Returns a dictionary mapping proteoforms to their annotations.
 * The key is the proteoform, the value the list of annotations related to it.
 * Note that the method is "isoform "aware": only annotations having
 * an AnnotationIsoformSpecificity record in getTargetingIsoformsMap
 * for the isoformAc specified in the parameter are taken into account
 * @param entry
 * @param isoformAc
 * @return
 */
public static Map<Proteoform, List<Annotation>> getProteoformAnnotationsMap(Entry entry, String isoformAc) {
    Map<Proteoform, List<Annotation>> result = new HashMap<Proteoform, List<Annotation>>();
    for (Annotation annot : entry.getAnnotations()) {
        if (annot.isProteoformAnnotation()) {
            if (annot.getTargetingIsoformsMap().containsKey(isoformAc)) {
                AnnotationIsoformSpecificity spec = annot.getTargetingIsoformsMap().get(isoformAc);
                Proteoform key = new Proteoform(isoformAc, spec.getName(), annot.getSubjectComponents());
                if (!result.containsKey(key))
                    result.put(key, new ArrayList<Annotation>());
                result.get(key).add(annot);
            }
        }
    }
    return result;
}
Also used : AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 24 with AnnotationIsoformSpecificity

use of org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity in project nextprot-api by calipho-sib.

the class PepXServiceImpl method buildEntryWithVirtualAnnotations.

static List<Annotation> buildEntryWithVirtualAnnotations(String peptide, boolean modeIsoleucine, List<PepXIsoformMatch> pepXisoforms, List<Annotation> varAnnotations, List<Isoform> isoforms) {
    List<Annotation> finalAnnotations = new ArrayList<>();
    for (PepXIsoformMatch isoNameAndOptionalPosition : pepXisoforms) {
        String isoformAc = isoNameAndOptionalPosition.getIsoformAccession();
        Annotation annotation = new Annotation();
        annotation.setAnnotationCategory(AnnotationCategory.PEPX_VIRTUAL_ANNOTATION);
        annotation.setCvTermName(peptide);
        annotation.setDescription("This virtual annotation describes the peptide " + peptide + " found in " + isoformAc);
        AnnotationIsoformSpecificity is = new AnnotationIsoformSpecificity();
        is.setIsoformAccession(isoformAc);
        if (isoNameAndOptionalPosition.getPosition() != null) {
            // It means there is a variant!!!
            int startPeptidePosition = isoNameAndOptionalPosition.getPosition();
            int endPeptidePosition = startPeptidePosition + peptide.length();
            List<Annotation> variantAnnotations = AnnotationUtils.filterAnnotationsBetweenPositions(startPeptidePosition, endPeptidePosition, varAnnotations, isoformAc);
            Isoform iso = IsoformUtils.getIsoformByIsoName(isoforms, isoformAc);
            if (iso == null) {
                throw new NextProtException("The variant at " + startPeptidePosition + " is not specific for this isoform " + isoformAc);
            }
            List<Annotation> validAnnotations = filterValidVariantAnnotations(peptide, modeIsoleucine, variantAnnotations, isoformAc, iso.getSequence());
            if ((validAnnotations == null) || validAnnotations.isEmpty()) {
                LOGGER.warn("No valid variants found for isoform " + isoformAc + " at position " + startPeptidePosition + " for peptide " + peptide + " in mode IL:" + modeIsoleucine);
                continue;
            // We used to throw an exception, but now we just skip
            // throw new NextProtException("No valid variants found for isoform " + isoformName + " at position" + startPeptidePosition + " for peptide " + peptide + " in mode IL:" + modeIsoleucine);
            }
            if (validAnnotations.size() > 1) {
                LOGGER.warn("There is more than 1 valid variant (" + validAnnotations.size() + ") for isoform (returning the 1st) " + isoformAc + " between position " + startPeptidePosition + " and " + endPeptidePosition + " for peptide " + peptide + " in mode IL:" + modeIsoleucine);
                // Takes only the first valid
                int startPos = validAnnotations.get(0).getStartPositionForIsoform(isoformAc);
                int endPos = validAnnotations.get(0).getEndPositionForIsoform(isoformAc);
                is.setFirstPosition(startPos);
                is.setLastPosition(endPos);
                AnnotationVariant var = validAnnotations.get(0).getVariant();
                annotation.setVariant(var);
            } else {
                // one variant on that position
                int startPos = validAnnotations.get(0).getStartPositionForIsoform(isoformAc);
                int endPos = validAnnotations.get(0).getEndPositionForIsoform(isoformAc);
                is.setFirstPosition(startPos);
                is.setLastPosition(endPos);
                AnnotationVariant var = validAnnotations.get(0).getVariant();
                annotation.setVariant(var);
            }
        } else {
            // No variant
            Isoform iso = IsoformUtils.getIsoformByIsoName(isoforms, isoformAc);
            String sequence = (iso != null) ? iso.getSequence() : null;
            boolean isPeptideContained = PeptideUtils.isPeptideContainedInTheSequence(peptide, sequence, modeIsoleucine);
            if (!isPeptideContained) {
                LOGGER.warn("PepX returned a peptide (" + peptide + ") for an isoform (" + isoformAc + ") that is not in the current isoform in neXtProt");
                continue;
            }
        // We used to throw an exception, but this would break the program (the algorithm could be improved to detect the specific case where pepx return a peptide of length 6 and generate a real error on other cases)
        // NPreconditions.checkTrue(isPeptideContained, "PepX returned a peptide (" + peptide + ") for an isoform (" + isoformName + ") that is not in the current isoform in neXtProt");
        }
        annotation.addTargetingIsoforms(Arrays.asList(is));
        finalAnnotations.add(annotation);
    }
    return finalAnnotations;
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) AnnotationVariant(org.nextprot.api.core.domain.annotation.AnnotationVariant) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Aggregations

AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)24 Annotation (org.nextprot.api.core.domain.annotation.Annotation)19 Test (org.junit.Test)12 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)12 AnnotationEvidence (org.nextprot.api.core.domain.annotation.AnnotationEvidence)5 Isoform (org.nextprot.api.core.domain.Isoform)3 ArrayList (java.util.ArrayList)2 AnnotationProperty (org.nextprot.api.core.domain.annotation.AnnotationProperty)2 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 Family (org.nextprot.api.core.domain.Family)1 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)1 TargetIsoformStatementPosition (org.nextprot.commons.statements.TargetIsoformStatementPosition)1