use of org.nextprot.api.core.domain.Entry 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;
}
use of org.nextprot.api.core.domain.Entry 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.core.domain.Entry in project nextprot-api by calipho-sib.
the class EntryDataFetcherImpl method get.
@Override
public Entry get(DataFetchingEnvironment environment) {
// TODO THIS IS A POC (Proof of Concept)
// If we decide to go ahead with GraphQL please try to adapt this terrible function using EntryQueryResolver that implements GraphQLQueryResolver
// graphql java tools allows to do newSchemaParser().file(schemaFile).resolvers(...).getSchemaObjects.getGraphqlSchema
String accession = environment.getArgument("accession");
Integer publicationLimit = -1;
Integer annotationLimit = -1;
String category = "";
// Searching for publication limit
Optional<Selection> publicationField = environment.getFields().get(0).getSelectionSet().getSelections().stream().filter(f -> ((Field) f).getName().equals("publications")).findAny();
if (publicationField.isPresent()) {
Optional<Argument> publicationLimitArg = ((Field) publicationField.get()).getArguments().stream().filter(f -> f.getName().equals("limit")).findAny();
if (publicationLimitArg.isPresent()) {
publicationLimit = Integer.valueOf(publicationLimitArg.get().getValue().toString().replace("IntValue{value=", "").replace("}", ""));
}
}
// Searching for annotation field
Optional<Selection> annotationField = environment.getFields().get(0).getSelectionSet().getSelections().stream().filter(f -> ((Field) f).getName().equals("annotations")).findAny();
if (annotationField.isPresent()) {
Optional<Argument> publicationLimitArg = ((Field) annotationField.get()).getArguments().stream().filter(f -> f.getName().equals("category")).findAny();
if (publicationLimitArg.isPresent()) {
category = publicationLimitArg.get().getValue().toString().replace("StringValue{value='", "").replace("'}", "");
}
Optional<Argument> annotationLimitArg = ((Field) annotationField.get()).getArguments().stream().filter(f -> f.getName().equals("limit")).findAny();
if (annotationLimitArg.isPresent()) {
annotationLimit = Integer.valueOf(annotationLimitArg.get().getValue().toString().replace("IntValue{value=", "").replace("}", ""));
}
}
Entry entry = entryBuilderService.build(EntryConfig.newConfig(accession).with(category).withPublications().withOverview().withTargetIsoforms());
if (publicationLimit != -1) {
List<Publication> publications = entry.getPublications();
List<Publication> publicationSubset = publications.subList(0, publicationLimit);
entry.setPublications(publicationSubset);
}
if (annotationLimit != -1) {
String cat = entry.getAnnotationsByCategory().keySet().iterator().next();
entry.setAnnotations(entry.getAnnotationsByCategory(AnnotationCategory.getDecamelizedAnnotationTypeName(cat)).subList(0, annotationLimit));
}
return entry;
}
use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.
the class EntryXLSWriter method writeEntry.
@Override
protected void writeEntry(String entryName) throws IOException {
EntryConfig config = EntryConfig.newConfig(entryName);
for (EntryBlock block : entryDataProvider.getSourceEntryBlocks()) {
config.withBlock(block);
}
Entry entry = entryBuilderService.build(config);
for (Record record : entryDataProvider.getRecords(entry)) {
HSSFRow row = worksheet.createRow(rowIndex);
writeRecord(row, record);
rowIndex++;
}
}
use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.
the class EntryPEFFStreamWriter method cacheBuiltEntries.
private void cacheBuiltEntries(Collection<String> entryAccessions) {
for (String entryAccession : entryAccessions) {
Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryAccession).withTargetIsoforms());
cachedEntries.put(entryAccession, entry);
}
}
Aggregations