use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class TerminologyServiceImpl method findPsiModName.
// http://psidev.cvs.sourceforge.net/viewvc/psidev/psi/mod/data/PSI-MOD.obo
@Override
public Optional<String> findPsiModName(String cvTermAccession) {
Optional<String> psiModAccessionOpt = findPsiModAccession(cvTermAccession);
if (!psiModAccessionOpt.isPresent()) {
return Optional.empty();
}
String psiModAccession = psiModAccessionOpt.get();
InputStream is = getClass().getResourceAsStream("peff/PSI-MOD.obo");
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
String line;
while ((line = br.readLine()) != null) {
// if the psi term is found...
if (line.startsWith("id: " + psiModAccession)) {
return findTermName(br);
}
}
// no psi term found
return Optional.empty();
} catch (IOException e) {
throw new NextProtException(e.getMessage() + ": cannot find PSI-MOD name for cv term " + cvTermAccession);
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class StreamEntryServiceImpl method streamAllEntries.
@Override
public void streamAllEntries(NextprotMediaType format, HttpServletResponse response) {
try {
setResponseHeader(response, format, "nextprot_all" + "." + format.getExtension());
streamEntries(masterIdentifierService.findUniqueNames(), format, "entry", response.getOutputStream(), "complete release");
} catch (IOException e) {
throw new NextProtException(format.getExtension() + " streaming failed: cannot export all " + masterIdentifierService.findUniqueNames().size() + " entries", e);
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class StreamEntryServiceImpl method streamQueriedEntries.
@Override
public void streamQueriedEntries(QueryRequest queryRequest, NextprotMediaType format, String viewName, HttpServletResponse response) {
List<String> entries = getAccessions(queryRequest);
try {
setResponseHeader(response, format, getFilename(queryRequest, viewName, format));
streamEntries(entries, format, viewName, response.getOutputStream(), getHeaderDescription(queryRequest));
} catch (IOException e) {
throw new NextProtException(format.getExtension() + " streaming failed: cannot export " + entries.size() + " entries (query=" + queryRequest.getQuery() + ")", e);
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class PepXServiceTest method shouldThrowAnExceptionWhenPepXGivesAVariantNotSpecificToTheIsoform.
@Test(expected = NextProtException.class)
public void shouldThrowAnExceptionWhenPepXGivesAVariantNotSpecificToTheIsoform() throws Exception {
try {
// Taking example NX_Q9H6T3
String peptide = "GANAP";
boolean modeIsoleucine = true;
String isoName = "NX_Q9H6T3-3";
Isoform iso1 = mock(Isoform.class);
when(iso1.getIsoformAccession()).thenReturn("another-iso-name");
when(iso1.getSequence()).thenReturn("MDADPYNPVLPTNRASAYFRLKKFAVAESDCNLAVALNRSYTKAYSRRGAARFALQKLEEAKKDYERVLELEPNNFEATNELRKISQALASKENSYPKEADIVIKSTEGERKQIEAQQNKQQAISEKDRGNGFFKEGKYERAIECYTRGIAADGANALLPANRAMAYLKIQKYEEAEKDCTQAILLDGSYSKAFARRGTARTFLGKLNEAKQDFETVLLLEPGNKQAVTELSKIKKELIEKGHWDDVFLDSTQRQNVVKPIDNPPHPGSTKPLKKVIIEETGNLIQTIDVPDSTTAAAPENNPINLANVIAATGTTSKKNSSQDDLFPTSDTPRAKVLKIEEVSDTSSLQPQASLKQDVCQSYSEKMPIEIEQKPAQFATTVLPPIPANSFQLESDFRQLKSSPDMLYQYLKQIEPSLYPKLFQKNLDPDVFNQIVKILHDFYIEKEKPLLIFEILQRLSELKRFDMAVMFMSETEKKIARALFNHIDKSGLKDSSVEELKKRYGG");
PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch(isoName, 154);
List<Annotation> annots = Arrays.asList(getMockedAnnotation("L", "P", 158, isoName, true));
List<Isoform> isoforms = Arrays.asList(iso1);
// empty
PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annots, isoforms);
// or
// null
// annotations
} catch (NextProtException e) {
if (e.getMessage().contains("is not specific for this isoform")) {
// success tests
throw e;
} else
fail();
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class DbXrefController method getRequestedFormat.
private NextprotMediaType getRequestedFormat(HttpServletRequest request) {
NextprotMediaType format;
String uri = request.getRequestURI();
if (uri.toLowerCase().endsWith(".ttl")) {
format = NextprotMediaType.TURTLE;
} else if (uri.toLowerCase().endsWith(".xml")) {
format = NextprotMediaType.XML;
} else if (uri.toLowerCase().endsWith(".json")) {
format = NextprotMediaType.JSON;
} else if (uri.toLowerCase().endsWith(".txt")) {
format = NextprotMediaType.TXT;
} else
throw new NextProtException("Format not recognized");
return format;
}
Aggregations