use of org.nextprot.api.core.export.EntryPartWriterTSV in project nextprot-api by calipho-sib.
the class EntryPartWriterTSVTest method getExpressionProfileOutputString.
@Test
public void getExpressionProfileOutputString() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
String subpart = "expression-profile";
Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_P01308").with(subpart));
EntryPartWriterTSV writer = new EntryPartWriterTSV(EntryPartExporterImpl.fromSubPart(subpart), baos);
writer.write(entry);
String output = baos.toString(StandardCharsets.UTF_8.name());
baos.close();
String[] headers = output.split("\n");
Assert.assertTrue(headers.length > 534);
Assert.assertEquals("ENTRY_ACCESSION\tCATEGORY\tTERM_ACCESSION\tTERM_NAME\tQUALITY\tECO_ACCESSION\tECO_NAME\tNEGATIVE\tEXPRESSION_LEVEL\tSTAGE_ACCESSION\tSTAGE_NAME\tSOURCE\tURL", headers[0]);
}
use of org.nextprot.api.core.export.EntryPartWriterTSV in project nextprot-api by calipho-sib.
the class EntryController method getSubPart.
@RequestMapping("/entry/{entry}/{blockOrSubpart}")
public String getSubPart(@PathVariable("entry") String entryName, @PathVariable("blockOrSubpart") String blockOrSubpart, @RequestParam(value = "term-child-of", required = false) String ancestorTerm, @RequestParam(value = "property-name", required = false) String propertyName, @RequestParam(value = "property-value", required = false) String propertyValueOrAccession, HttpServletRequest request, Model model) {
boolean goldOnly = "true".equalsIgnoreCase(request.getParameter("goldOnly"));
boolean bed = null == request.getParameter("bed") ? true : Boolean.valueOf(request.getParameter("bed"));
Entry entry = this.entryBuilderService.build(EntryConfig.newConfig(entryName).with(blockOrSubpart).withGoldOnly(goldOnly).withBed(bed));
if (ancestorTerm != null || propertyName != null) {
filterEntryAnnotations(entry, ancestorTerm, propertyName, propertyValueOrAccession);
}
if (request.getRequestURI().toLowerCase().endsWith(".tsv")) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
EntryPartWriterTSV writer = new EntryPartWriterTSV(EntryPartExporterImpl.fromSubPart(blockOrSubpart), baos);
writer.write(entry);
model.addAttribute("tsv", baos.toString(StandardCharsets.UTF_8.name()));
baos.close();
} catch (IOException e) {
throw new NextProtException("cannot export " + entryName + " " + blockOrSubpart + " in tsv format", e);
}
}
model.addAttribute("entry", entry);
return "entry";
}
Aggregations