Search in sources :

Example 36 with Isoform

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

the class MasterIsoformMappingServiceImpl method findMasterIsoformMappingByEntryName.

@Override
@Cacheable("master-isoform-mapping")
public List<IsoformSpecificity> findMasterIsoformMappingByEntryName(String entryName) {
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // build a map between isoform unique name and isoform main name
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    List<Isoform> isoforms = isoformService.findIsoformsByEntryName(entryName);
    Map<String, String> unique2mainName = new HashMap<String, String>();
    for (Isoform iso : isoforms) {
        String mainName = iso.getMainEntityName().getValue();
        unique2mainName.put(iso.getUniqueName(), mainName);
    }
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // group partial mappings obtained from DAO by isoform and set isoform name
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Map<String, IsoformSpecificity> map = new HashMap<String, IsoformSpecificity>();
    List<IsoformSpecificity> specs = masterIsoformMappingDao.findIsoformMappingByMaster(entryName);
    for (IsoformSpecificity tmpSpec : specs) {
        String ac = tmpSpec.getIsoformAc();
        if (!map.containsKey(ac))
            map.put(ac, new IsoformSpecificity(null, ac));
        IsoformSpecificity spec = map.get(ac);
        // replace unique name with main name
        spec.setIsoformMainName(unique2mainName.get(ac));
        spec.addPosition(tmpSpec.getPositions().get(0));
    }
    List<IsoformSpecificity> list = new ArrayList<IsoformSpecificity>(map.values());
    Collections.sort(list);
    // returns a immutable list when the result is cacheable (this prevents modifying the cache, since the cache returns a reference) copy on read and copy on write is too much time consuming
    return new ImmutableList.Builder<IsoformSpecificity>().addAll(list).build();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Isoform(org.nextprot.api.core.domain.Isoform) IsoformSpecificity(org.nextprot.api.core.domain.IsoformSpecificity) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 37 with Isoform

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

the class OverviewServiceImpl method convertIsoNamestoOverviewName.

private static List<EntityName> convertIsoNamestoOverviewName(List<Isoform> isoforms) {
    List<EntityName> isoNames = new ArrayList<>();
    for (Isoform isoform : isoforms) {
        EntityName name = new EntityName();
        name.setMain(true);
        name.setName(isoform.getMainEntityName().getValue());
        name.setType(isoform.getMainEntityName().getType());
        name.setQualifier(isoform.getMainEntityName().getQualifier());
        for (EntityName syn : isoform.getSynonyms()) {
            EntityName s = new EntityName();
            s.setMain(false);
            s.setName(syn.getValue());
            name.setType(syn.getType());
            name.setQualifier(syn.getQualifier());
            name.getSynonyms().add(s);
        }
        name.getSynonyms().sort(Comparator.comparing(EntityName::getName));
        isoNames.add(name);
    }
    return isoNames;
}
Also used : EntityName(org.nextprot.api.core.domain.EntityName) ArrayList(java.util.ArrayList) Isoform(org.nextprot.api.core.domain.Isoform)

Example 38 with Isoform

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

the class BinaryInteraction2Annotation method transform.

public static Annotation transform(Interaction inter, String entryName, List<Isoform> isoforms, MainNamesService mainNamesService) {
    // - - - - - - - - - - - - - - - - - - - -
    // annotation core object
    // - - - - - - - - - - - - - - - - - - - -
    Long annotId = inter.getId();
    Annotation annot = new Annotation();
    annot.setAnnotationId(annotId);
    annot.setCategory(AnnotationCategory.BINARY_INTERACTION.getDbAnnotationTypeName());
    annot.setCvTermAccessionCode(null);
    annot.setCvTermName(null);
    annot.setDescription(null);
    annot.setParentXref(null);
    annot.setQualityQualifier(inter.getQuality());
    annot.setSynonym(null);
    annot.setUniqueName("AN" + entryName.substring(3) + "_BI_" + annotId);
    annot.setVariant(null);
    // - - - - - - - - - - - - - - - - - - - -
    // annotation evidences
    // - - - - - - - - - - - - - - - - - - - -
    List<AnnotationEvidence> evidences = new ArrayList<>();
    AnnotationEvidence evi = new AnnotationEvidence();
    evi.setAnnotationId(annot.getAnnotationId());
    evi.setAssignedBy(inter.getEvidenceDatasource());
    // N/A: values = curated|computed: applicable to evidences having publications as resource
    evi.setAssignmentMethod(null);
    // TODO: uncomment next 2 lines as soon as partnership_resource_assoc has link to eco codes and not more to
    // evi.setEvidenceCodeAC(inter.getEvidenceCodeAC());
    // evi.setEvidenceCodeName(inter.getEvidenceCodeName());
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    // see https://issues.isb-sib.ch/browse/NEXTPROT-921
    evi.setEvidenceCodeAC("ECO:0000353");
    evi.setEvidenceCodeOntology("EvidenceCodeOntologyCv");
    evi.setEvidenceCodeName("Physical interaction evidence used in manual assertion");
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    evi.setEvidenceId(inter.getEvidenceId());
    evi.setNegativeEvidence(false);
    evi.setExperimentalContextId(null);
    // see https://issues.isb-sib.ch/browse/NEXTPROT-921
    evi.setQualifierType("IPI");
    evi.setQualityQualifier(inter.getEvidenceQuality());
    evi.setResourceAccession(inter.getEvidenceXrefAC());
    evi.setResourceAssociationType("evidence");
    evi.setResourceDb(inter.getEvidenceXrefDB());
    evi.setResourceDescription(null);
    evi.setResourceId(inter.getEvidenceResourceId());
    evi.setResourceType("database");
    // - - - - - - - - - - - - - - - - - - - -
    // evidence property: number of experiments
    // - - - - - - - - - - - - - - - - - - - -
    AnnotationEvidenceProperty evp = new AnnotationEvidenceProperty();
    evp.setEvidenceId(evp.getEvidenceId());
    evp.setPropertyName("numberOfExperiments");
    evp.setPropertyValue("" + inter.getNumberOfExperiments());
    List<AnnotationEvidenceProperty> evProps = new ArrayList<>();
    evProps.add(evp);
    evi.setProperties(evProps);
    evidences.add(evi);
    annot.setEvidences(evidences);
    // - - - - - - - - - - - - - - - - - - - -
    // annotation properties
    // - - - - - - - - - - - - - - - - - - - -
    // annotation property: interactant
    // - - - - - - - - - - - - - - - - - - - -
    List<AnnotationProperty> anProps = new ArrayList<>();
    annot.setBioObject(newBioObject(BinaryInteraction2Annotation.getInteractant(inter), mainNamesService));
    // - - - - - - - - - - - - - - - - - - - -
    // annotation property: self interaction
    // - - - - - - - - - - - - - - - - - - - -
    AnnotationProperty p3 = new AnnotationProperty();
    p3.setAnnotationId(annotId);
    p3.setName("selfInteraction");
    p3.setValue("" + inter.isSelfInteraction());
    anProps.add(p3);
    annot.addProperties(anProps);
    // - - - - - - - - - - - - - - - - - - - -
    // annotation isoform specificity
    // - - - - - - - - - - - - - - - - - - - -
    List<AnnotationIsoformSpecificity> isospecs = new ArrayList<>();
    for (Isoform iso : isoforms) {
        AnnotationIsoformSpecificity spec = new AnnotationIsoformSpecificity();
        spec.setAnnotationId(annotId);
        spec.setIsoformAccession(iso.getIsoformAccession());
        boolean isSpecific = inter.isInteractionSpecificForIsoform(iso.getIsoformAccession());
        spec.setSpecificity(isSpecific ? "SPECIFIC" : "UNKNOWN");
        isospecs.add(spec);
    }
    annot.addTargetingIsoforms(isospecs);
    return annot;
}
Also used : ArrayList(java.util.ArrayList) Isoform(org.nextprot.api.core.domain.Isoform)

Example 39 with Isoform

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

the class EntryPEFFStreamWriter method writeEntry.

@Override
protected void writeEntry(String entryName) throws IOException {
    Map<String, String> isoformToPEFF = entryReportStatsService.reportIsoformPeffHeaders(entryName);
    StringBuilder sb = new StringBuilder();
    for (Isoform isoform : cachedEntries.get(entryName).getIsoforms()) {
        sb.append(">").append(isoformToPEFF.get(isoform.getIsoformAccession())).append(StringUtils.CR_LF).append(StringUtils.wrapText(isoform.getSequence(), 60)).append(StringUtils.CR_LF);
    }
    getStream().write(sb.toString().getBytes());
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform)

Example 40 with Isoform

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

the class PepXServiceTest method shouldThrowAnExceptionWhenPepXGivesAVariantNotSpecificToTheIsoform.

@Test(expected = NextProtException.class)
public void shouldThrowAnExceptionWhenPepXGivesAVariantNotSpecificToTheIsoform() throws Exception {
    try {
        // Taking example NX_Q9H6T3
        String peptide = "GANAP";
        boolean modeIsoleucine = true;
        String isoName = "NX_Q9H6T3-3";
        Isoform iso1 = mock(Isoform.class);
        when(iso1.getIsoformAccession()).thenReturn("another-iso-name");
        when(iso1.getSequence()).thenReturn("MDADPYNPVLPTNRASAYFRLKKFAVAESDCNLAVALNRSYTKAYSRRGAARFALQKLEEAKKDYERVLELEPNNFEATNELRKISQALASKENSYPKEADIVIKSTEGERKQIEAQQNKQQAISEKDRGNGFFKEGKYERAIECYTRGIAADGANALLPANRAMAYLKIQKYEEAEKDCTQAILLDGSYSKAFARRGTARTFLGKLNEAKQDFETVLLLEPGNKQAVTELSKIKKELIEKGHWDDVFLDSTQRQNVVKPIDNPPHPGSTKPLKKVIIEETGNLIQTIDVPDSTTAAAPENNPINLANVIAATGTTSKKNSSQDDLFPTSDTPRAKVLKIEEVSDTSSLQPQASLKQDVCQSYSEKMPIEIEQKPAQFATTVLPPIPANSFQLESDFRQLKSSPDMLYQYLKQIEPSLYPKLFQKNLDPDVFNQIVKILHDFYIEKEKPLLIFEILQRLSELKRFDMAVMFMSETEKKIARALFNHIDKSGLKDSSVEELKKRYGG");
        PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch(isoName, 154);
        List<Annotation> annots = Arrays.asList(getMockedAnnotation("L", "P", 158, isoName, true));
        List<Isoform> isoforms = Arrays.asList(iso1);
        // empty
        PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annots, isoforms);
    // or
    // null
    // annotations
    } catch (NextProtException e) {
        if (e.getMessage().contains("is not specific for this isoform")) {
            // success tests
            throw e;
        } else
            fail();
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) 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