Search in sources :

Example 26 with Isoform

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

the class IsoformUtilsTest method testGetOtherIsoforms.

@Test
public void testGetOtherIsoforms() throws Exception {
    Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_P01308").withTargetIsoforms());
    Isoform isoform = entry.getIsoforms().get(0);
    Assert.assertTrue(IsoformUtils.getOtherIsoforms(entry, isoform.getUniqueName()).isEmpty());
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Isoform(org.nextprot.api.core.domain.Isoform) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 27 with Isoform

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

the class BlastServiceImpl method blastIsoformSequence.

@Override
public BlastProgramOutput blastIsoformSequence(BlastIsoformInput params) {
    String isoformAccession = params.getIsoformAccession();
    String entryAccession = isoformAccession.split("-")[0];
    try {
        Isoform isoform = getIsoform(isoformAccession, entryAccession);
        params.setSequence(isoform.getSequence());
        params.validateSequencePositions();
        params.setSequence(params.getSequence().substring(params.getBeginPos() - 1, params.getEndPos()));
        params.setTitle(buildTitle(params, isoform, entryAccession));
        params.setEntryAccession(entryAccession);
        Description queryDescription = new Description();
        blastResultUpdaterService.updateDescription(queryDescription, isoformAccession, entryAccession);
        params.setDescription(queryDescription);
        return blastProteinSequence(params);
    } catch (ExceptionWithReason exceptionWithReason) {
        return new BlastProgramFailure(params, exceptionWithReason);
    }
}
Also used : Description(org.nextprot.api.blast.domain.gen.Description) Isoform(org.nextprot.api.core.domain.Isoform) ExceptionWithReason(org.nextprot.api.commons.utils.ExceptionWithReason)

Example 28 with Isoform

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

the class IsoformSequencePositionMapperIntegrationTest method getErrorsDuringPropagationOnVariantsOfSingleEntry.

public int getErrorsDuringPropagationOnVariantsOfSingleEntry(String entry_ac) throws Exception {
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entry_ac).withTargetIsoforms().withAnnotations());
    int delCount = 0;
    int subCount = 0;
    int insCount = 0;
    int otherCount = 0;
    int errorCount = 0;
    for (Annotation a : entry.getAnnotations()) {
        if (a.getAPICategory().equals(AnnotationCategory.VARIANT)) {
            // for each variant annotation
            String ori = a.getVariant().getOriginal();
            String mut = a.getVariant().getVariant();
            if (ori.length() == 1 && mut.length() == 1) {
                subCount++;
            } else if (ori.length() == 1 && mut.length() == 0) {
                delCount++;
            } else if (ori.length() == 0 && mut.length() == 1) {
                insCount++;
            } else if (sout) {
                System.out.println("Other variant:" + a.getUniqueName());
                otherCount++;
            }
            Map<String, Integer> isoExpectedPos = getExpectedPosForEachIsoform(entry, a);
            printExpectedPosForEachIsoform(isoExpectedPos, a);
            boolean errorOnVariant = false;
            for (String iso1name : isoExpectedPos.keySet()) {
                Integer iso1ExpectedPos = isoExpectedPos.get(iso1name);
                Isoform iso1 = IsoformUtils.getIsoformByName(entry, iso1name);
                if (iso1ExpectedPos != null) {
                    GeneMasterCodonPosition nuPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(iso1ExpectedPos, iso1);
                    if (!nuPos.isValid()) {
                        errorOnVariant = true;
                        if (sout)
                            System.out.println("ERROR1: codon positions not found for " + iso1name + " for variant at position: " + iso1ExpectedPos);
                        continue;
                    }
                    printIsoLengthAndRangesNuCount(iso1.getUniqueName(), iso1.getSequence(), iso1.getMasterMapping());
                    if (sout) {
                        System.out.println("Starting variant propagation from isoform " + iso1name + " at position " + iso1ExpectedPos);
                        System.out.println(getSequenceWithHighlighedPos(iso1.getSequence(), iso1ExpectedPos));
                    }
                    for (Isoform iso2 : entry.getIsoforms()) {
                        String iso2name = iso2.getUniqueName();
                        if (iso2name.equals(iso1name))
                            continue;
                        CodonNucleotideIndices nuIdx = IsoformSequencePositionMapper.getCodonNucleotideIndices(nuPos, iso2);
                        Integer iso2ActualPos = nuIdx.getAminoAcidPosition();
                        Integer iso2ExpectedPos = isoExpectedPos.get(iso2name);
                        if (sout)
                            System.out.println("Variant " + a.getUniqueName() + " position on isoform " + iso2name + " is " + iso2ActualPos);
                        printIsoLengthAndRangesNuCount(iso2.getUniqueName(), iso2.getSequence(), iso2.getMasterMapping());
                        if (iso2ExpectedPos != null)
                            if (sout)
                                System.out.println("Expected:" + getSequenceWithHighlighedPos(iso2.getSequence(), iso2ExpectedPos));
                        if (iso2ActualPos != null)
                            if (sout)
                                System.out.println("Actual  :" + getSequenceWithHighlighedPos(iso2.getSequence(), iso2ActualPos));
                        if (iso2ActualPos == null && iso2ExpectedPos == null) {
                        // OK
                        } else if (iso2ActualPos == null || iso2ExpectedPos == null) {
                            errorOnVariant = true;
                            if (sout)
                                System.out.println("ERROR2: variant position on isoform " + iso2name + " is " + iso2ActualPos + ", expected " + iso2ExpectedPos);
                        } else if (!iso2ActualPos.equals(iso2ExpectedPos)) {
                            errorOnVariant = true;
                            if (sout)
                                System.out.println("ERROR3: variant position on isoform " + iso2name + " is " + iso2ActualPos + ", expected " + iso2ExpectedPos);
                        }
                    }
                }
            }
            if (errorOnVariant)
                errorCount++;
            if (errorOnVariant)
                break;
        }
    }
    if (sout) {
        System.out.println("Summary " + entry.getUniqueName());
        System.out.println("insCount:" + insCount);
        System.out.println("delCount:" + delCount);
        System.out.println("subCount:" + subCount);
        System.out.println("otherCount:" + otherCount);
        System.out.println("errorCount:" + errorCount);
    }
    return errorCount;
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 29 with Isoform

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

the class IsoformPEFFHeaderBuilderTest method newIsoformPEFFHeaderBuilder.

private IsoformPEFFHeaderBuilder newIsoformPEFFHeaderBuilder(String isoName) {
    String entryAccession = isoformService.findEntryAccessionFromIsoformAccession(isoName);
    Isoform isoform = isoformService.findIsoform(isoName);
    List<Annotation> isoformAnnotations = annotationService.findAnnotations(entryAccession).stream().filter(annotation -> annotation.isSpecificForIsoform(isoName)).collect(Collectors.toList());
    Overview overview = overviewService.findOverviewByEntry(entryAccession);
    return new IsoformPEFFHeaderBuilder(isoform, isoformAnnotations, overview, terminologyService::findPsiModAccession, terminologyService::findPsiModName);
}
Also used : CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) OverviewService(org.nextprot.api.core.service.OverviewService) ActiveProfiles(org.springframework.test.context.ActiveProfiles) AnnotationService(org.nextprot.api.core.service.AnnotationService) Collectors(java.util.stream.Collectors) TerminologyService(org.nextprot.api.core.service.TerminologyService) Overview(org.nextprot.api.core.domain.Overview) List(java.util.List) IsoformPEFFHeader(org.nextprot.api.core.domain.IsoformPEFFHeader) IsoformService(org.nextprot.api.core.service.IsoformService) Assert(org.junit.Assert) Isoform(org.nextprot.api.core.domain.Isoform) Isoform(org.nextprot.api.core.domain.Isoform) Overview(org.nextprot.api.core.domain.Overview) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 30 with Isoform

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

the class IsoformUtilsTest method testGetOtherIsoforms2.

@Test
public void testGetOtherIsoforms2() throws Exception {
    Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_Q9UI33").withTargetIsoforms());
    List<Isoform> others = IsoformUtils.getOtherIsoforms(entry, "NX_Q9UI33-1");
    Assert.assertEquals(2, others.size());
    for (Isoform isoform : others) {
        Assert.assertTrue(isoform.getUniqueName().equals("NX_Q9UI33-2") || isoform.getUniqueName().equals("NX_Q9UI33-3"));
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Isoform(org.nextprot.api.core.domain.Isoform) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) 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