use of org.nextprot.api.core.domain.EntryReport in project nextprot-api by calipho-sib.
the class HPPChromosomeReportTSVWriter method write.
@Override
public void write(ChromosomeReport report) throws IOException {
writer.write(extractHeaders().stream().collect(Collectors.joining("\t")));
writer.write("\n");
Map<String, EntryReport> groupedByAccession = report.getEntryReports().stream().collect(Collectors.toMap(EntryReport::getAccession, er -> er, // 1. keep one entry report for each entry accession
(er1, er2) -> er1));
List<String> sortedAccessions = new ArrayList<>(groupedByAccession.keySet()).stream().sorted().collect(Collectors.toList());
for (String accession : sortedAccessions) {
EntryReport er = groupedByAccession.get(accession);
writer.write(extractValues(er, overviewService.findOverviewByEntry(er.getAccession())).stream().collect(Collectors.joining("\t")));
writer.write("\n");
}
writer.close();
}
use of org.nextprot.api.core.domain.EntryReport in project nextprot-api by calipho-sib.
the class ChromosomeReportServiceImpl method reportChromosome.
@Cacheable("chromosome-reports")
@Override
public ChromosomeReport reportChromosome(String chromosome) {
// TODO: if chromosome is not found throw an http error 404
if (!Chromosome.exists(chromosome)) {
throw new ChromosomeNotFoundException(chromosome);
}
ChromosomeReport report = new ChromosomeReport();
report.setDataRelease(releaseInfoService.findReleaseVersions().getDatabaseRelease());
List<String> allEntriesOnChromosome = masterIdentifierService.findUniqueNamesOfChromosome(chromosome);
List<EntryReport> entryReports = allEntriesOnChromosome.stream().map(entryAccession -> entryGeneReportService.reportEntry(entryAccession)).flatMap(Collection::stream).filter(er -> er.getChromosome().equals(chromosome)).sorted(EntryReport.newByChromosomalPositionComparator()).collect(Collectors.toList());
report.setEntryReports(entryReports);
ChromosomeReport.Summary summary = newSummary(chromosome, entryReports);
setByProteinEvidenceEntryCount(allEntriesOnChromosome, summary);
report.setSummary(summary);
return report;
}
use of org.nextprot.api.core.domain.EntryReport in project nextprot-api by calipho-sib.
the class ChromosomeReportTXTReader method read.
@Override
public ChromosomeReport read(Reader reader) throws ParseException {
ChromosomeReport report = new ChromosomeReport();
ChromosomeReport.Summary summary = new ChromosomeReport.Summary();
List<EntryReport> entryReports = new ArrayList<>();
try {
MatchConsumer matchConsumer = new MatchConsumer(reader);
matchConsumer.consumeNextMatchOfThrowException("chromosome name", CHROMOSOME_NAME_PATTERN, (matcher -> summary.setChromosome(matcher.group(1))));
matchConsumer.consumeNextMatchOfThrowException("release date", RELEASE_DATE_PATTERN, (matcher -> report.setDataRelease(matcher.group(1))));
matchConsumer.consumeNextMatchOfThrowException("entry count", ENTRY_COUNT_PATTERN, (matcher -> summary.setEntryCount(Integer.parseInt(matcher.group(1)))));
matchConsumer.consumeNextMatchOfThrowException("gene count", GENE_COUNT_PATTERN, (matcher -> summary.setEntryReportCount(Integer.parseInt(matcher.group(1)))));
EntryReportConsumer entryReportConsumer = new EntryReportConsumer(summary, entryReports);
boolean moreLinesToRead;
do {
moreLinesToRead = matchConsumer.consumeNextMatch(ENTRY_VALUES_PATTERN, entryReportConsumer);
} while (moreLinesToRead);
report.setSummary(summary);
report.setEntryReports(entryReports);
return report;
} catch (IOException e) {
throw new ParseException(e.getMessage(), -1);
}
}
use of org.nextprot.api.core.domain.EntryReport in project nextprot-api by calipho-sib.
the class HPPChromosomeReportTXTWriter method write.
@Override
public void write(ChromosomeReport chromosomeReport) throws IOException {
writer.write(String.format(buildHeaderFormat(), Arrays.asList("neXtProt AC", "Gene name(s)", "Protein existence", "Proteomics", "Antibody").toArray()));
Map<String, EntryReport> groupedByAccession = chromosomeReport.getEntryReports().stream().collect(Collectors.toMap(EntryReport::getAccession, er -> er, // 1. keep one entry report for each entry accession
(er1, er2) -> er1));
List<String> sortedAccessions = new ArrayList<>(groupedByAccession.keySet()).stream().sorted().collect(Collectors.toList());
for (String accession : sortedAccessions) {
EntryReport er = groupedByAccession.get(accession);
write(er, overviewService.findOverviewByEntry(er.getAccession()));
}
writer.close();
}
use of org.nextprot.api.core.domain.EntryReport in project nextprot-api by calipho-sib.
the class EntryReport method duplicateThenSetChromosomalLocation.
public EntryReport duplicateThenSetChromosomalLocation(ChromosomalLocation chromosomalLocation) {
EntryReport copy = new EntryReport();
copy.setAccession(accession);
copy.setDescription(description);
copy.setProteinExistence(proteinExistence);
copy.propertyTests = new HashMap<>(propertyTests);
copy.propertyCounts = new HashMap<>(propertyCounts);
copy.setChromosomalLocation(chromosomalLocation);
return copy;
}
Aggregations