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;
}
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);
}
}
Aggregations