Search in sources :

Example 1 with PepXResponse

use of org.nextprot.api.web.domain.PepXResponse in project nextprot-api by calipho-sib.

the class PepXServiceImpl method findEntriesWithPeptides.

@Override
public List<Entry> findEntriesWithPeptides(String peptides, boolean modeIsoleucine) {
    List<Entry> entries = new ArrayList<>();
    PepXResponse pepXResponse = getPepXResponse(peptides, modeIsoleucine);
    Set<String> entriesNames = pepXResponse.getEntriesNames();
    for (String entryName : entriesNames) {
        EntryConfig targetIsoconf = EntryConfig.newConfig(entryName).withTargetIsoforms().with("variant").withOverview().withoutAdditionalReferences().withoutProperties();
        Entry entry = entryBuilderService.build(targetIsoconf);
        List<Annotation> virtualAnnotations = new ArrayList<>();
        Set<String> peptidesForEntry = pepXResponse.getPeptidesForEntry(entryName);
        for (String peptide : peptidesForEntry) {
            PepXEntryMatch pepxEntryMatch = pepXResponse.getPeptideMatch(peptide).getPepxMatchesForEntry(entryName);
            if (pepxEntryMatch != null && pepxEntryMatch.getIsoforms() != null && pepxEntryMatch.getIsoforms().size() > 0) {
                virtualAnnotations.addAll(buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, pepxEntryMatch.getIsoforms(), entry.getAnnotations(), entry.getIsoforms()));
            }
        }
        if ((virtualAnnotations != null) && (!virtualAnnotations.isEmpty())) {
            Entry resultEntry = new Entry(entry.getUniqueName());
            // Adds the overview as well
            resultEntry.setOverview(entry.getOverview());
            resultEntry.setAnnotations(virtualAnnotations);
            entries.add(resultEntry);
        }
    }
    // add peptide unicity extra info required to unicity checker and peptide viewer
    updateAnnotationsWithPeptideProperties(entries);
    return entries;
}
Also used : Entry(org.nextprot.api.core.domain.Entry) EntryConfig(org.nextprot.api.core.service.fluent.EntryConfig) PepXResponse(org.nextprot.api.web.domain.PepXResponse) PepXEntryMatch(org.nextprot.api.web.domain.PepXResponse.PepXEntryMatch) Annotation(org.nextprot.api.core.domain.annotation.Annotation)

Example 2 with PepXResponse

use of org.nextprot.api.web.domain.PepXResponse in project nextprot-api by calipho-sib.

the class PepXServiceTest method shouldParsePep.

@Test
public void shouldParsePep() throws Exception {
    ClassLoader classLoader = getClass().getClassLoader();
    File file = new File(classLoader.getResource("org/nextprot/api/pepx/pepxResponse.json").getFile());
    Scanner scanner = new Scanner(file, "UTF-8");
    String content = scanner.useDelimiter("\\A").next();
    scanner.close();
    PepXResponse pepXResponse = PepxUtils.parsePepxResponse(content);
    // System.out.println(pepXResponse.getEntriesNames().size());
    // assertTrue(pepXResponse.getEntriesNames().size() == 20);
    assertTrue(((Integer) pepXResponse.getParams().get("modeIL")) == 1);
    assertTrue((pepXResponse.getParams().get("peplist")).equals("TKMGLYYSYFK,TKMGL"));
    assertTrue((pepXResponse.getPeptideMatch("TKMGLYYSYFK").getEntryMatches().size() == 3));
    assertTrue((pepXResponse.getPeptideMatch("TKMGL").getEntryMatches().size() == 17));
    PepXMatch pepXMatch = pepXResponse.getPeptideMatch("TKMGL");
    // Test entry names
    List<String> names = pepXMatch.getEntryNamesMatches();
    assertTrue(names.size() == 17);
    assertTrue(names.contains("Q6NUT2"));
    assertTrue(names.contains("Q2PZI1"));
    assertTrue(names.contains("Q9UKT4"));
    assertTrue(names.contains("Q6NXN4"));
    {
        PepXEntryMatch pepXEntryMatch = pepXMatch.getPepxMatchesForEntry("Q6NUT2");
        assertTrue(pepXEntryMatch.getIsoforms().get(0).getPosition().equals(148));
    }
    {
        PepXEntryMatch pepXEntryMatch2 = pepXMatch.getPepxMatchesForEntry("O00327");
        assertTrue(pepXEntryMatch2.getIsoforms().get(1).getPosition() == null);
    }
}
Also used : PepXMatch(org.nextprot.api.web.domain.PepXResponse.PepXMatch) Scanner(java.util.Scanner) PepXResponse(org.nextprot.api.web.domain.PepXResponse) File(java.io.File) PepXEntryMatch(org.nextprot.api.web.domain.PepXResponse.PepXEntryMatch) WebUnitBaseTest(org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest) Test(org.junit.Test)

Aggregations

PepXResponse (org.nextprot.api.web.domain.PepXResponse)2 PepXEntryMatch (org.nextprot.api.web.domain.PepXResponse.PepXEntryMatch)2 File (java.io.File)1 Scanner (java.util.Scanner)1 Test (org.junit.Test)1 Entry (org.nextprot.api.core.domain.Entry)1 Annotation (org.nextprot.api.core.domain.annotation.Annotation)1 EntryConfig (org.nextprot.api.core.service.fluent.EntryConfig)1 WebUnitBaseTest (org.nextprot.api.web.dbunit.base.mvc.WebUnitBaseTest)1 PepXMatch (org.nextprot.api.web.domain.PepXResponse.PepXMatch)1