Search in sources :

Example 21 with Entry

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

the class IsoformUtilsTest method testGetIsoformByAccession.

@Test
public void testGetIsoformByAccession() throws Exception {
    Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_P01308").withTargetIsoforms());
    Assert.assertEquals("NX_P01308-1", IsoformUtils.getIsoformByName(entry, "NX_P01308-1").getUniqueName());
}
Also used : Entry(org.nextprot.api.core.domain.Entry) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 22 with Entry

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

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

the class ExportController method streamEntrySubPart.

@RequestMapping(value = "/export/entry/{entry}/{blockOrSubpart}", method = { RequestMethod.GET })
public void streamEntrySubPart(HttpServletRequest request, HttpServletResponse response, @PathVariable("entry") String entryName, @PathVariable("blockOrSubpart") String blockOrSubpart) {
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryName).with(blockOrSubpart).withBed(true));
    try {
        EntryPartWriter writer = EntryPartWriter.valueOf(NextprotMediaType.valueOf(request), EntryPartExporterImpl.fromSubPart(blockOrSubpart), response.getOutputStream());
        writer.write(entry);
    } catch (IOException e) {
        throw new NextProtException("cannot export " + entryName + " " + blockOrSubpart + " in " + NextprotMediaType.valueOf(request) + " format", e);
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) NextProtException(org.nextprot.api.commons.exception.NextProtException) EntryPartWriter(org.nextprot.api.core.export.EntryPartWriter) IOException(java.io.IOException)

Example 24 with Entry

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

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

Entry (org.nextprot.api.core.domain.Entry)60 Test (org.junit.Test)38 CoreUnitBaseTest (org.nextprot.api.core.test.base.CoreUnitBaseTest)16 Annotation (org.nextprot.api.core.domain.annotation.Annotation)9 Isoform (org.nextprot.api.core.domain.Isoform)8 EntryConfig (org.nextprot.api.core.service.fluent.EntryConfig)8 WebIntegrationBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebIntegrationBaseTest)8 EntryBuilderService (org.nextprot.api.core.service.EntryBuilderService)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Assert (org.junit.Assert)4 Ignore (org.junit.Ignore)4 AnnotationCategory (org.nextprot.api.commons.constants.AnnotationCategory)4 DbXref (org.nextprot.api.core.domain.DbXref)4 ArrayList (java.util.ArrayList)3 PropertyApiModel (org.nextprot.api.commons.constants.PropertyApiModel)3 SolrDiffTest (org.nextprot.api.tasks.solr.indexer.entry.SolrDiffTest)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 java.util (java.util)2