use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class PepXServiceTest method shouldGiveAnExceptionIfTheOriginalIsNotPresentOnTheSequence.
/*
* Specification has changed look at:
* shouldReturnAnEmptryListIfTheVariantIsNotConaintedInThePeptide
*
* @Test(expected=NextProtException.class) public void
* shouldGiveAnExceptionIfTheVariantIsNotConaintedInThePeptide() throws
* Exception { try {
*
* //Taking example NX_Q9H6T3 String peptide = "GANAP"; boolean
* modeIsoleucine = true; String isoName = "NX_Q9H6T3-3";
*
* Isoform isoform = mock(Isoform.class);
* when(isoform.getIsoformAccession()).thenReturn(isoName);
* //https://cdn.rawgit.com/calipho-sib/sequence-viewer/master/examples/
* simple.html (check that page to format the sequence) //GANAL is present
* instead of GANAP when(isoform.getSequence()).thenReturn(
* "MDADPYNPVLPTNRASAYFRLKKFAVAESDCNLAVALNRSYTKAYSRRGAARFALQKLEEAKKDYERVLELEPNNFEATNELRKISQALASKENSYPKEADIVIKSTEGERKQIEAQQNKQQAISEKDRGNGFFKEGKYERAIECYTRGIAADGANALLPANRAMAYLKIQKYEEAEKDCTQAILLDGSYSKAFARRGTARTFLGKLNEAKQDFETVLLLEPGNKQAVTELSKIKKELIEKGHWDDVFLDSTQRQNVVKPIDNPPHPGSTKPLKKVIIEETGNLIQTIDVPDSTTAAAPENNPINLANVIAATGTTSKKNSSQDDLFPTSDTPRAKVLKIEEVSDTSSLQPQASLKQDVCQSYSEKMPIEIEQKPAQFATTVLPPIPANSFQLESDFRQLKSSPDMLYQYLKQIEPSLYPKLFQKNLDPDVFNQIVKILHDFYIEKEKPLLIFEILQRLSELKRFDMAVMFMSETEKKIARALFNHIDKSGLKDSSVEELKKRYGG"
* );
*
* List<Pair<String, Integer>> isosAndPositions = Arrays.asList(new
* Pair<String, Integer>(isoName, 154)); //Position of the begin of peptide
* List<Annotation> annots = Arrays.asList(getMockedAnnotation("L", "Z",
* 158, isoName, true)); List<Isoform> isoforms = Arrays.asList(isoform);
*
* PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine,
* isosAndPositions, annots, isoforms); //empty or null annotations
* }catch(NextProtException e){ if(e.getMessage().contains(
* "No valid variants found for isoform ")){ throw e; //success tests }else
* fail(); }
*
* }
*/
// because we have variants in nextprot which do not have original aa is not equal to isoform aa at that variant position (inconsistency)
@Ignore
@Test(expected = NextProtException.class)
public void shouldGiveAnExceptionIfTheOriginalIsNotPresentOnTheSequence() throws Exception {
try {
// Taking example NX_Q9H6T3
String peptide = "GANAP";
boolean modeIsoleucine = true;
String isoName = "NX_Q9H6T3-3";
Isoform isoform = mock(Isoform.class);
when(isoform.getIsoformAccession()).thenReturn(isoName);
// https://cdn.rawgit.com/calipho-sib/sequence-viewer/master/examples/simple.html
// (check that page to format the sequence)
// GANAL is present instead of GANAP
when(isoform.getSequence()).thenReturn("MDADPYNPVLPTNRASAYFRLKKFAVAESDCNLAVALNRSYTKAYSRRGAARFALQKLEEAKKDYERVLELEPNNFEATNELRKISQALASKENSYPKEADIVIKSTEGERKQIEAQQNKQQAISEKDRGNGFFKEGKYERAIECYTRGIAADGANALLPANRAMAYLKIQKYEEAEKDCTQAILLDGSYSKAFARRGTARTFLGKLNEAKQDFETVLLLEPGNKQAVTELSKIKKELIEKGHWDDVFLDSTQRQNVVKPIDNPPHPGSTKPLKKVIIEETGNLIQTIDVPDSTTAAAPENNPINLANVIAATGTTSKKNSSQDDLFPTSDTPRAKVLKIEEVSDTSSLQPQASLKQDVCQSYSEKMPIEIEQKPAQFATTVLPPIPANSFQLESDFRQLKSSPDMLYQYLKQIEPSLYPKLFQKNLDPDVFNQIVKILHDFYIEKEKPLLIFEILQRLSELKRFDMAVMFMSETEKKIARALFNHIDKSGLKDSSVEELKKRYGG");
PepXIsoformMatch pepXIsoformMatch = new PepXIsoformMatch(isoName, 154);
// Original is not contained in the sequence, should be a L L->P
// (GANAL)
List<Annotation> annots = Arrays.asList(getMockedAnnotation("O", "P", 158, isoName, true));
List<Isoform> isoforms = Arrays.asList(isoform);
// empty
PepXServiceImpl.buildEntryWithVirtualAnnotations(peptide, modeIsoleucine, Arrays.asList(pepXIsoformMatch), annots, isoforms);
// or
// null
// annotations
} catch (NextProtException e) {
if (e.getMessage().contains("The amino acid")) {
// success tests
throw e;
} else
fail();
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class GitHubServiceImpl method getNews.
@Override
@Cacheable(value = "github-news")
public List<NextProtNews> getNews() {
List<NextProtNews> news = new ArrayList<>();
try {
GitHub github = getGitHubConnection();
GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
GHTree tree = repo.getTreeRecursive(githubDocBranch, 1);
newsFileNames.clear();
for (GHTreeEntry te : tree.getTree()) {
if (te.getPath().startsWith("news")) {
// Add only file on news
if (te.getType().equalsIgnoreCase("blob")) {
// file
String fileName = te.getPath().replaceAll("news/", "");
NextProtNews n = parseGitHubNewsFilePath(fileName);
if (n != null) {
news.add(n);
String fileEncoded = URLEncoder.encode(fileName.replace(".md", ""), "UTF-8").replace("+", "%20");
newsFileNames.put(n.getUrl(), fileEncoded);
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
throw new NextProtException("News not available, sorry for the inconvenience");
}
Collections.sort(news);
return news;
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class SolrIndexer method addRemaing.
public void addRemaing() {
try {
if (docs.size() > 0) // There are some prepared docs not yet sent to solr server
{
solrServer.add(docs);
docs.clear();
}
} catch (SolrServerException | IOException e) {
throw new NextProtException(e);
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class SolrIndexer method add.
public void add(T t) {
try {
SolrInputDocument doc = this.convertToSolrDocument(t);
if (doc == null)
return;
docs.add(doc);
if (docs.size() % BATCH_SIZE == 0) {
// System.err.println("sent " +docs.size() + " docs to solr so far");
this.solrServer.add(docs);
docs.clear();
}
} catch (SolrServerException | IOException e) {
throw new NextProtException(e);
}
}
use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.
the class SparqlProxyEndpointImpl method sparqlInternal.
private ResponseEntity<String> sparqlInternal(String queryString) {
ResponseEntity<String> responseEntity;
String url = sparqlEndpoint.getUrl() + ((queryString != null) ? ("?" + queryString) : "");
try {
RestTemplate template = new RestTemplate();
responseEntity = template.getForEntity(new URI(url), String.class);
return responseEntity;
} catch (HttpServerErrorException | HttpClientErrorException e) {
throw new NextProtException(e.getResponseBodyAsString(), e);
} catch (RestClientException | URISyntaxException e) {
throw new NextProtException(e);
}
}
Aggregations