Search in sources :

Example 41 with Isoform

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

the class IsoformMappingServiceImpl method propagate.

// TODO: refactor this method, it is too complex (probably a propagator object with strategy pattern for the mapping)
private void propagate(SingleFeatureQuerySuccessImpl successResults) throws ParseException {
    SingleFeatureQuery query = successResults.getQuery();
    query.setPropagableFeature(true);
    SequenceFeature isoFeature = successResults.getIsoformSequenceFeature();
    Isoform featureIsoform = isoFeature.getIsoform(successResults.getEntry());
    SequenceVariation variation = isoFeature.getProteinVariation();
    OriginalAminoAcids originalAminoAcids = getOriginalAminoAcids(featureIsoform.getSequence(), variation);
    GeneMasterCodonPosition originalFirstMasterCodonPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(originalAminoAcids.getFirstAAPos(), featureIsoform);
    GeneMasterCodonPosition originalLastMasterCodonPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(originalAminoAcids.getLastAAPos(), featureIsoform);
    // try to propagate the feature to other isoforms
    for (Isoform otherIsoform : IsoformUtils.getOtherIsoforms(successResults.getEntry(), featureIsoform.getIsoformAccession())) {
        Integer firstIsoPos = IsoformSequencePositionMapper.getProjectedPosition(featureIsoform, originalAminoAcids.getFirstAAPos(), otherIsoform);
        Integer lastIsoPos = IsoformSequencePositionMapper.getProjectedPosition(featureIsoform, originalAminoAcids.getLastAAPos(), otherIsoform);
        boolean propagable = false;
        if (firstIsoPos != null && lastIsoPos != null) {
            if (variation.getVaryingSequence().isMultipleAminoAcids()) {
                int originalSequenceLength = lastIsoPos - firstIsoPos + 1;
                int isoformSequenceLength = originalAminoAcids.getAas().length();
                if (originalSequenceLength == isoformSequenceLength) {
                    String isoformSequence = otherIsoform.getSequence().substring(firstIsoPos - 1, lastIsoPos);
                    if (isoformSequence.equals(originalAminoAcids.getAas())) {
                        GeneMasterCodonPosition firstMasterCodonPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(firstIsoPos, otherIsoform);
                        GeneMasterCodonPosition lastMasterCodonPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(lastIsoPos, otherIsoform);
                        propagable = firstMasterCodonPos.getNucleotidePosition(0).intValue() == originalFirstMasterCodonPos.getNucleotidePosition(0) && lastMasterCodonPos.getNucleotidePosition(2).intValue() == originalLastMasterCodonPos.getNucleotidePosition(2);
                    }
                }
            } else // check a single amino-acid
            {
                propagable = IsoformSequencePositionMapper.checkAminoAcidsFromPosition(otherIsoform, firstIsoPos, originalAminoAcids.getAas());
            }
        }
        if (propagable) {
            addPropagation(otherIsoform, firstIsoPos, lastIsoPos, originalAminoAcids.isExtensionTerminal(), successResults);
        } else {
            successResults.addUnmappedFeature(otherIsoform);
        }
    }
}
Also used : SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) GeneMasterCodonPosition(org.nextprot.api.core.utils.seqmap.GeneMasterCodonPosition) SequenceVariation(org.nextprot.api.commons.bio.variation.prot.SequenceVariation) SequenceFeature(org.nextprot.api.isoform.mapper.domain.SequenceFeature) Isoform(org.nextprot.api.core.domain.Isoform)

Example 42 with Isoform

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

the class SequenceVariantTest method testIsospecFeatureFromIsoFeature.

@Test
public void testIsospecFeatureFromIsoFeature() throws Exception {
    SequenceVariant variant = new SequenceVariant("WT1-iso4-p.Phe154Ser");
    Isoform isoform = mockIsoform("NX_P19544", "Iso 3", false);
    Assert.assertEquals("WT1-iso3-p.Phe120Ser", variant.formatIsoSpecificFeature(isoform, 120, 120));
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) Test(org.junit.Test)

Example 43 with Isoform

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

the class FeatureQuerySuccessTest method testOnSuccess.

@Test
public void testOnSuccess() throws FeatureQueryException, ParseException {
    SingleFeatureQuery query = new SingleFeatureQuery("NX_Q9UI33", "SCN11A-p.Leu1158Pro", AnnotationCategory.VARIANT.getApiTypeName());
    SequenceVariant sequenceVariant = new SequenceVariant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YFTSAWCCLDFIIVIVSVTTLINLMELKSFRTLRALRPLRALSQFEGMKVVVNALIGAIPAILNVLLVCLIFWLVFCILGVYFFSGKFGKCINGTDSVINYTIITNKSQCESGNFSWINQKVNFDNVGNAYLALLQVATFKGWMDIIYAAVDSTEKEQQPEFESNSLGYIYFVVFIIFGSFFTLNLFIGVIIDNFNQQQKKLGGQDIFMTEEQKKYYNAMKKLGSKKPQKPIPRPLNKCQGLVFDIVTSQIFDIIIISLIILNMISMMAESYNQPKAMKSILDHLNWVFVVIFTLECLIKIFALRQYYFTNGWNLFDCVVVLLSIVSTMISTLENQEHIPFPPTLFRIVRLARIGRILRLVRAARGIRTLLFALMMSLPSLFNIGLLLFLIMFIYAILGMNWFSKVNPESGIDDIFNFKTFASSMLCLFQISTSAGWDSLLSPMLRSKESCNSSSENCHLPGIATSYFVSYIIISFLIVVNMYIAVILENFNTATEESEDPLGEDDFDIFYEVWEKFDPEATQFIKYSALSDFADALPEPLRVAKPNKYQFLVMDLPMVSEDRLHCMDILFAFTARVLGGSDGLDSMKAMMEEKFMEANPLKKLYEPIVTTTKRKEEERGAAIIQKAFRKYMMKVTKGDQGDQNDLENGPHSPLQTLCNGDLSSFGVAKGKVHCD";
    Isoform iso1 = SequenceVariantTest.mockIsoform("NX_Q9UI33-1", "Iso 1", true, seqIso1);
    Isoform iso2 = SequenceVariantTest.mockIsoform("NX_Q9UI33-2", "Iso 2", false, seqIso2);
    Isoform iso3 = SequenceVariantTest.mockIsoform("NX_Q9UI33-3", "Iso 3", false, seqIso3);
    Entry entry = SequenceVariantTest.mockEntry("NX_Q9UI33", iso1, iso2, iso3);
    SingleFeatureQuerySuccessImpl result = new SingleFeatureQuerySuccessImpl(entry, query, sequenceVariant);
    result.addMappedFeature(iso1, 1158, 1158);
    result.addMappedFeature(iso2, 1158, 1158);
    result.addMappedFeature(iso3, 1120, 1120);
    result.addUnmappedFeature(SequenceVariantTest.mockIsoform("NX_Q9UI33-23", "Iso 23", false, ""));
    Assert.assertEquals("SCN11A-iso1-p.Leu1158Pro", result.getData().get("NX_Q9UI33-1").getIsoSpecificFeature());
    Assert.assertEquals("SCN11A-iso2-p.Leu1158Pro", result.getData().get("NX_Q9UI33-2").getIsoSpecificFeature());
    Assert.assertEquals("SCN11A-iso3-p.Leu1120Pro", result.getData().get("NX_Q9UI33-3").getIsoSpecificFeature());
    Assert.assertNull(result.getData().get("NX_Q9UI33-23").getIsoSpecificFeature());
}
Also used : Entry(org.nextprot.api.core.domain.Entry) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) Isoform(org.nextprot.api.core.domain.Isoform) Test(org.junit.Test)

Example 44 with Isoform

use of org.nextprot.api.core.domain.Isoform 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

Isoform (org.nextprot.api.core.domain.Isoform)44 Test (org.junit.Test)19 Annotation (org.nextprot.api.core.domain.annotation.Annotation)17 PepXIsoformMatch (org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch)8 Entry (org.nextprot.api.core.domain.Entry)7 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)7 ArrayList (java.util.ArrayList)6 NextProtException (org.nextprot.api.commons.exception.NextProtException)6 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)6 AnnotationIsoformSpecificity (org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)4 Ignore (org.junit.Ignore)3 EntityName (org.nextprot.api.core.domain.EntityName)3 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 SequenceVariation (org.nextprot.api.commons.bio.variation.prot.SequenceVariation)2 Interaction (org.nextprot.api.core.domain.Interaction)2 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)2 IsoformService (org.nextprot.api.core.service.IsoformService)2 BinaryInteraction2Annotation (org.nextprot.api.core.utils.BinaryInteraction2Annotation)2 SingleFeatureQuery (org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery)2