Search in sources :

Example 16 with Isoform

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

the class StatementTransformationUtil method computeTargetIsoformsForProteoformAnnotation.

public static TargetIsoformSet computeTargetIsoformsForProteoformAnnotation(Statement proteoformStatement, IsoformMappingService isoformMappingService, List<Statement> subjectsForThisProteoform, boolean isIsoSpecific, String isoSpecificAccession, List<String> isoformAccessions) {
    List<String> isoformsToBeConsidered = new ArrayList<>();
    if (isIsoSpecific) {
        isoformsToBeConsidered.add(isoSpecificAccession);
    } else {
        isoformsToBeConsidered.addAll(isoformAccessions);
    }
    Set<TargetIsoformStatementPosition> result = new TreeSet<>();
    for (String isoformAccession : isoformsToBeConsidered) {
        String name = null;
        boolean allOk = true;
        for (Statement s : subjectsForThisProteoform) {
            TargetIsoformSet targetIsoforms = TargetIsoformSet.deSerializeFromJsonString(s.getValue(StatementField.TARGET_ISOFORMS));
            List<TargetIsoformStatementPosition> targetIsoformsFiltered = targetIsoforms.stream().filter(ti -> ti.getIsoformAccession().equals(isoformAccession)).collect(Collectors.toList());
            if (targetIsoformsFiltered.isEmpty()) {
                LOGGER.debug("(skip) Could not map to isoform " + isoformAccession);
                allOk = false;
                break;
            } else if (targetIsoformsFiltered.size() > 1) {
                throw new NextProtException("Something got wrong. Found more than one target isoform for same accession" + isoformAccession);
            }
            TargetIsoformStatementPosition tisp = targetIsoformsFiltered.iterator().next();
            if (name == null) {
                name = tisp.getName();
            } else {
                name += (" + " + tisp.getName());
            }
        }
        if (name != null && allOk) {
            if (isIsoSpecific) {
                result.add(new TargetIsoformStatementPosition(isoformAccession, IsoTargetSpecificity.SPECIFIC.name(), name));
            } else {
                result.add(new TargetIsoformStatementPosition(isoformAccession, IsoTargetSpecificity.UNKNOWN.name(), name));
            }
        }
    }
    return new TargetIsoformSet(result);
}
Also used : NPreconditions(org.nextprot.api.commons.exception.NPreconditions) java.util(java.util) FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) IsoTargetSpecificity(org.nextprot.commons.constants.IsoTargetSpecificity) org.nextprot.commons.statements(org.nextprot.commons.statements) NextProtException(org.nextprot.api.commons.exception.NextProtException) IsoformFeatureResult(org.nextprot.api.isoform.mapper.domain.impl.SingleFeatureQuerySuccessImpl.IsoformFeatureResult) IsoformMappingService(org.nextprot.api.isoform.mapper.service.IsoformMappingService) Collectors(java.util.stream.Collectors) FeatureQuerySuccess(org.nextprot.api.isoform.mapper.domain.FeatureQuerySuccess) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) Logger(org.apache.log4j.Logger) AnnotationType(org.nextprot.commons.statements.constants.AnnotationType) IsoformService(org.nextprot.api.core.service.IsoformService) FeatureQueryFailure(org.nextprot.api.isoform.mapper.domain.FeatureQueryFailure) Isoform(org.nextprot.api.core.domain.Isoform) NextProtException(org.nextprot.api.commons.exception.NextProtException)

Example 17 with Isoform

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

the class SequenceVariantTest method mockIsoform.

public static Isoform mockIsoform(String accession, String name, boolean canonical, String sequence) {
    Isoform isoform = mockIsoform(accession, name, canonical);
    when(isoform.getSequence()).thenReturn(sequence);
    return isoform;
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform)

Example 18 with Isoform

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

the class SequenceVariantTest method testFormatIsoformSpecifiqueFeatureTypeIso.

@Test
public void testFormatIsoformSpecifiqueFeatureTypeIso() throws Exception {
    SequenceVariant variant = new SequenceVariant("SCN11A-p.Leu1158Pro");
    Isoform iso = mockIsoform("whatever", "Iso 1", true);
    Assert.assertEquals("iso1", variant.formatIsoformFeatureName(iso));
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) Test(org.junit.Test)

Example 19 with Isoform

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

the class SequenceVariantTest method testIsospecFeature.

@Test
public void testIsospecFeature() throws Exception {
    SequenceVariant variant = new SequenceVariant("WT1-p.Phe154Ser");
    Isoform isoform = mockIsoform("NX_P19544", "Iso 1", true);
    Assert.assertEquals("WT1-iso1-p.Phe154Ser", variant.formatIsoSpecificFeature(isoform, 154, 154));
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) Test(org.junit.Test)

Example 20 with Isoform

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

the class SequenceVariantTest method testFormatIsoformSpecifiqueFeatureTypeNonIso.

@Test
public void testFormatIsoformSpecifiqueFeatureTypeNonIso() throws Exception {
    SequenceVariant variant = new SequenceVariant("ABL1-p.Ser439Gly");
    Isoform iso = mockIsoform("whatever", "IA", true);
    Assert.assertEquals("isoIA", variant.formatIsoformFeatureName(iso));
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) Test(org.junit.Test)

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