@Test public void testParseNeanderthalProportion() { InputStream inputStream = getClass().getResourceAsStream("neanderthal.json"); double neanderthalProportion = converter.parseNeanderthalProportion(inputStream); assertEquals(0.0310d, neanderthalProportion, 0.1d); }
@Override public double parseNeanderthalProportion(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); double proportion = -1d; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("neanderthal".equals(field)) { while (parser.nextToken() != JsonToken.END_OBJECT) { String neanderthalField = parser.getCurrentName(); parser.nextToken(); if ("proportion".equals(neanderthalField)) { proportion = Double.parseDouble(parser.getText()); } } } } return proportion; } catch (IOException e) { logger.warn("could not parse neanderthal proportion", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return -1d; }
JacksonPersonalGenomeConverter implements PersonalGenomeConverter { @Override public double parseNeanderthalProportion(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); double proportion = -1d; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("neanderthal".equals(field)) { while (parser.nextToken() != JsonToken.END_OBJECT) { String neanderthalField = parser.getCurrentName(); parser.nextToken(); if ("proportion".equals(neanderthalField)) { proportion = Double.parseDouble(parser.getText()); } } } } return proportion; } catch (IOException e) { logger.warn("could not parse neanderthal proportion", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return -1d; } }
JacksonPersonalGenomeConverter implements PersonalGenomeConverter { @Override public double parseNeanderthalProportion(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); double proportion = -1d; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("neanderthal".equals(field)) { while (parser.nextToken() != JsonToken.END_OBJECT) { String neanderthalField = parser.getCurrentName(); parser.nextToken(); if ("proportion".equals(neanderthalField)) { proportion = Double.parseDouble(parser.getText()); } } } } return proportion; } catch (IOException e) { logger.warn("could not parse neanderthal proportion", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return -1d; } JacksonPersonalGenomeConverter(final JsonFactory jsonFactory); }
JacksonPersonalGenomeConverter implements PersonalGenomeConverter { @Override public double parseNeanderthalProportion(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); double proportion = -1d; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("neanderthal".equals(field)) { while (parser.nextToken() != JsonToken.END_OBJECT) { String neanderthalField = parser.getCurrentName(); parser.nextToken(); if ("proportion".equals(neanderthalField)) { proportion = Double.parseDouble(parser.getText()); } } } } return proportion; } catch (IOException e) { logger.warn("could not parse neanderthal proportion", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return -1d; } JacksonPersonalGenomeConverter(final JsonFactory jsonFactory); @Override PersonalGenomeClientException parseException(final InputStream inputStream); @Override User parseUser(final InputStream inputStream); @Override UserName parseNames(final InputStream inputStream); @Override Haplogroup parseHaplogroups(final InputStream inputStream); @Override Genotype parseGenotypes(final InputStream inputStream); @Override Genome parseGenomes(final InputStream inputStream); @Override Ancestry parseAncestry(final InputStream inputStream); @Override double parseNeanderthalProportion(final InputStream inputStream); @Override List<Relative> parseRelatives(final InputStream inputStream); @Override List<Risk> parseRisks(final InputStream inputStream); @Override List<Carrier> parseCarriers(final InputStream inputStream); @Override List<DrugResponse> parseDrugResponses(final InputStream inputStream); @Override List<Trait> parseTraits(final InputStream inputStream); }
JacksonPersonalGenomeConverter implements PersonalGenomeConverter { @Override public double parseNeanderthalProportion(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); double proportion = -1d; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("neanderthal".equals(field)) { while (parser.nextToken() != JsonToken.END_OBJECT) { String neanderthalField = parser.getCurrentName(); parser.nextToken(); if ("proportion".equals(neanderthalField)) { proportion = Double.parseDouble(parser.getText()); } } } } return proportion; } catch (IOException e) { logger.warn("could not parse neanderthal proportion", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return -1d; } JacksonPersonalGenomeConverter(final JsonFactory jsonFactory); @Override PersonalGenomeClientException parseException(final InputStream inputStream); @Override User parseUser(final InputStream inputStream); @Override UserName parseNames(final InputStream inputStream); @Override Haplogroup parseHaplogroups(final InputStream inputStream); @Override Genotype parseGenotypes(final InputStream inputStream); @Override Genome parseGenomes(final InputStream inputStream); @Override Ancestry parseAncestry(final InputStream inputStream); @Override double parseNeanderthalProportion(final InputStream inputStream); @Override List<Relative> parseRelatives(final InputStream inputStream); @Override List<Risk> parseRisks(final InputStream inputStream); @Override List<Carrier> parseCarriers(final InputStream inputStream); @Override List<DrugResponse> parseDrugResponses(final InputStream inputStream); @Override List<Trait> parseTraits(final InputStream inputStream);  }