Search in sources :

Example 6 with Isoform

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

the class IsoformSequencePositionMapperIntegrationTest method getExpectedPosForEachIsoform.

private Map<String, Integer> getExpectedPosForEachIsoform(Entry entry, Annotation a) {
    Map<String, Integer> isoExpectedPos = new HashMap<String, Integer>();
    for (Isoform isoform : entry.getIsoforms()) {
        String isoname = isoform.getUniqueName();
        AnnotationIsoformSpecificity spec = a.getTargetingIsoformsMap().get(isoname);
        // store variant pos on isoform (default is null)
        isoExpectedPos.put(isoname, null);
        // if variant maps on isoform
        if (spec != null) {
            int p1 = spec.getFirstPosition();
            // store variant position on isoform
            isoExpectedPos.put(isoname, new Integer(p1));
        }
    }
    return isoExpectedPos;
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity)

Example 7 with Isoform

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

the class IsoformSequencePositionMapperIntegrationTest method testSingleVariantWithInvalidNucleotideIndice.

@Test
public void testSingleVariantWithInvalidNucleotideIndice() throws Exception {
    String entry_ac = "NX_O00115";
    String iso_ac = "NX_O00115-1";
    String variant_ac = "AN_O00115_000472";
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entry_ac).withTargetIsoforms().withAnnotations());
    for (Annotation a : entry.getAnnotations()) {
        if (a.getUniqueName().equals(variant_ac)) {
            int pos = a.getTargetingIsoformsMap().get(iso_ac).getFirstPosition();
            Isoform iso = IsoformUtils.getIsoformByName(entry, iso_ac);
            GeneMasterCodonPosition nuPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(pos, iso);
            for (Isoform iso2 : entry.getIsoforms()) {
                if (!iso2.equals(iso)) {
                    CodonNucleotideIndices nuIdx = IsoformSequencePositionMapper.getCodonNucleotideIndices(nuPos, iso2);
                    // cannot be projected to iso2
                    Assert.assertEquals(false, nuIdx.has3Nucleotides());
                    Assert.assertEquals(false, nuIdx.areConsecutive());
                    Assert.assertEquals(false, nuIdx.areInFrame());
                    Assert.assertNull(nuIdx.getAminoAcidPosition());
                }
            }
            return;
        }
    }
    Assert.assertTrue(false);
}
Also used : Entry(org.nextprot.api.core.domain.Entry) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 8 with Isoform

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

the class PepXServiceImpl method computePeptideUnicityStatus.

/**
 * Computes a unicity value for each peptide: UNIQUE, PSEUDO_UNIQUE, NON_UNIQUE
 * based on the response returned by pepx (a list of peptide - isoform matches)
 * by using the PeptideUnicityService
 * @param entries
 * @param withVariants
 * @return a map with key = peptide sequence, value = unicity value
 */
private Map<String, PeptideUnicity> computePeptideUnicityStatus(List<Entry> entries, boolean withVariants) {
    Map<String, Set<String>> pepIsoSetMap = new HashMap<>();
    entries.forEach(e -> {
        e.getAnnotationsByCategory(AnnotationCategory.PEPX_VIRTUAL_ANNOTATION).stream().filter(a -> a.getVariant() == null || withVariants).forEach(a -> {
            String pep = a.getCvTermName();
            if (!pepIsoSetMap.containsKey(pep))
                pepIsoSetMap.put(pep, new TreeSet<String>());
            a.getTargetingIsoformsMap().values().forEach(i -> {
                pepIsoSetMap.get(pep).add(i.getIsoformAccession());
            });
        });
    });
    Map<String, PeptideUnicity> pepUnicityMap = new HashMap<>();
    pepIsoSetMap.entrySet().forEach(e -> {
        String pep = e.getKey();
        PeptideUnicity pu = peptideUnicityService.getPeptideUnicityFromMappingIsoforms(e.getValue());
        pepUnicityMap.put(pep, pu);
    });
    return pepUnicityMap;
}
Also used : java.util(java.util) PepXResponse(org.nextprot.api.web.domain.PepXResponse) PepXEntryMatch(org.nextprot.api.web.domain.PepXResponse.PepXEntryMatch) URL(java.net.URL) Annotation(org.nextprot.api.core.domain.annotation.Annotation) NextProtException(org.nextprot.api.commons.exception.NextProtException) Autowired(org.springframework.beans.factory.annotation.Autowired) PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity) EntryBuilderService(org.nextprot.api.core.service.EntryBuilderService) Value(org.springframework.beans.factory.annotation.Value) AnnotationIsoformSpecificity(org.nextprot.api.core.domain.annotation.AnnotationIsoformSpecificity) AnnotationCategory(org.nextprot.api.commons.constants.AnnotationCategory) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) Service(org.springframework.stereotype.Service) URLConnection(java.net.URLConnection) IsoformUtils(org.nextprot.api.core.utils.IsoformUtils) AnnotationVariant(org.nextprot.api.core.domain.annotation.AnnotationVariant) AnnotationProperty(org.nextprot.api.core.domain.annotation.AnnotationProperty) PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) PeptideUnicityService(org.nextprot.api.core.service.PeptideUnicityService) Entry(org.nextprot.api.core.domain.Entry) PeptideUtils(org.nextprot.api.core.utils.PeptideUtils) IOException(java.io.IOException) PropertyApiModel(org.nextprot.api.commons.constants.PropertyApiModel) InputStreamReader(java.io.InputStreamReader) AnnotationUtils(org.nextprot.api.core.service.annotation.AnnotationUtils) PepXService(org.nextprot.api.web.service.PepXService) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) PepxUtils(org.nextprot.api.web.domain.PepxUtils) BufferedReader(java.io.BufferedReader) Isoform(org.nextprot.api.core.domain.Isoform) PeptideUnicity(org.nextprot.api.core.domain.PeptideUnicity)

Example 9 with Isoform

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

the class IsoformConverter method marshal.

public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    Isoform isoform = (Isoform) value;
    writer.startNode("sequence");
    writer.addAttribute("value", isoform.getSequence());
    writer.endNode();
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform)

Example 10 with Isoform

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

the class PepXServiceTest method shouldBuildAnEntryWithVirtualAnnotations.

@Test
public void shouldBuildAnEntryWithVirtualAnnotations() throws Exception {
    String peptide = "GANAP";
    boolean modeIsoleucine = true;
    PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch();
    pepXIsoformMatch.setIsoformAccession(ISO_ACCESSION);
    @SuppressWarnings("unchecked") List<Annotation> annotations = mock(List.class);
    Isoform isoform = mock(Isoform.class);
    when(isoform.getIsoformAccession()).thenReturn(ISO_ACCESSION);
    when(isoform.getSequence()).thenReturn("AGANAPA");
    List<Isoform> isoforms = Arrays.asList(isoform);
    List<Annotation> virtualAnnotations = PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annotations, isoforms);
    Annotation annot = virtualAnnotations.get(0);
    assertTrue(annot.getCategory().equals("pepx-virtual-annotation"));
    assertTrue(annot.getVariant() == null);
    assertTrue(annot.getTargetingIsoformsMap().keySet().contains(ISO_ACCESSION));
}
Also used : PepXIsoformMatch(org.nextprot.api.web.domain.PepXResponse.PepXIsoformMatch) Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) 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