Search in sources :

Example 1 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 2 with Isoform

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

the class AnnotationUtilsTest method exportAnnotationsAsTsvString.

private String exportAnnotationsAsTsvString(Entry entry, List<Annotation> mergedAnnotations) {
    Isoform canonical = IsoformUtils.getCanonicalIsoform(entry);
    StringBuilder sb = new StringBuilder();
    for (Annotation annotation : mergedAnnotations) {
        List<String> row = Arrays.asList(entry.getUniqueName(), annotation.getUniqueName(), annotation.getAPICategory().getApiTypeName(), annotation.getAnnotationName(), annotation.getAnnotationHash(), String.valueOf(computeMasterPos(canonical, annotation.getTargetingIsoformsMap().get(canonical.getIsoformAccession()).getFirstPosition())));
        // write annotation line
        sb.append(row.stream().collect(Collectors.joining("\t"))).append("\n");
    }
    return sb.toString();
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 3 with Isoform

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

the class InteractionServiceImpl method findInteractionsAsAnnotationsByEntry.

@Override
@Cacheable("interactions-as-annot")
public List<Annotation> findInteractionsAsAnnotationsByEntry(String entryName) {
    List<Annotation> annots = new ArrayList<>();
    List<Isoform> isoforms = this.isoService.findIsoformsByEntryName(entryName);
    List<Interaction> interactions = this.interactionDAO.findInteractionsByEntry(entryName);
    for (Interaction inter : interactions) {
        Annotation annot = BinaryInteraction2Annotation.transform(inter, entryName, isoforms, mainNamesService);
        annots.add(annot);
    }
    // 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<Annotation>().addAll(annots).build();
}
Also used : Interaction(org.nextprot.api.core.domain.Interaction) ArrayList(java.util.ArrayList) Isoform(org.nextprot.api.core.domain.Isoform) BinaryInteraction2Annotation(org.nextprot.api.core.utils.BinaryInteraction2Annotation) Annotation(org.nextprot.api.core.domain.annotation.Annotation) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 4 with Isoform

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

the class InteractionServiceIntegrationTest method shouldWork.

@Ignore
@Test
public void shouldWork() {
    String entryName = "NX_P38398";
    List<Annotation> annots = new ArrayList<>();
    List<Isoform> isoforms = this.isoformService.findIsoformsByEntryName(entryName);
    List<Interaction> interactions = this.interactionService.findInteractionsByEntry(entryName);
    System.out.println("Interaction count:" + interactions.size());
    for (Interaction inter : interactions) {
        Annotation annot = BinaryInteraction2Annotation.transform(inter, entryName, isoforms, mainNamesService);
        annots.add(annot);
        BioObject bo = annot.getBioObject();
        if (bo != null && (bo.getAccession().equals("NX_Q92560") || bo.getAccession().equals("Q99PU7"))) {
            System.out.print(inter.getEvidenceXrefAC() + ": ");
            System.out.print(inter.getInteractants().get(0).getAccession());
            if (inter.getInteractants().size() == 2)
                System.out.print(" <==> " + inter.getInteractants().get(1));
            System.out.println("");
            System.out.println(bo);
        }
    }
    System.out.println("Annot count:" + annots.size());
}
Also used : Interaction(org.nextprot.api.core.domain.Interaction) ArrayList(java.util.ArrayList) Isoform(org.nextprot.api.core.domain.Isoform) BinaryInteraction2Annotation(org.nextprot.api.core.utils.BinaryInteraction2Annotation) Annotation(org.nextprot.api.core.domain.annotation.Annotation) BioObject(org.nextprot.api.core.domain.BioObject) Ignore(org.junit.Ignore) CoreUnitBaseTest(org.nextprot.api.core.test.base.CoreUnitBaseTest) Test(org.junit.Test)

Example 5 with Isoform

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

the class ByIsoformPositionComparatorTest method mockIsoform.

private static Isoform mockIsoform(String accession, boolean isCanonical) {
    Isoform isoform = Mockito.mock(Isoform.class);
    when(isoform.isCanonicalIsoform()).thenReturn(isCanonical);
    when(isoform.getIsoformAccession()).thenReturn(accession);
    return isoform;
}
Also used : Isoform(org.nextprot.api.core.domain.Isoform)

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