@Test public void testParseGenomes() { InputStream inputStream = getClass().getResourceAsStream("genomes.json"); Genome genome = converter.parseGenomes(inputStream); assertNotNull(genome); assertEquals("c4480ba411939067", genome.getProfileId()); assertEquals("ACTAGTAG__TTGADDAAIICCTTDDTT", genome.getValues()); }
@Override public Genome parseGenomes(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); String id = null; String values = null; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("id".equals(field)) { id = parser.getText(); } else if ("genome".equals(field)) { values = parser.getText(); } } return new Genome(id, values); } catch (IOException e) { logger.warn("could not parse genomes", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return null; }
JacksonPersonalGenomeConverter implements PersonalGenomeConverter { @Override public Genome parseGenomes(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); String id = null; String values = null; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("id".equals(field)) { id = parser.getText(); } else if ("genome".equals(field)) { values = parser.getText(); } } return new Genome(id, values); } catch (IOException e) { logger.warn("could not parse genomes", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return null; } }
JacksonPersonalGenomeConverter implements PersonalGenomeConverter { @Override public Genome parseGenomes(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); String id = null; String values = null; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("id".equals(field)) { id = parser.getText(); } else if ("genome".equals(field)) { values = parser.getText(); } } return new Genome(id, values); } catch (IOException e) { logger.warn("could not parse genomes", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return null; } JacksonPersonalGenomeConverter(final JsonFactory jsonFactory); }
JacksonPersonalGenomeConverter implements PersonalGenomeConverter { @Override public Genome parseGenomes(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); String id = null; String values = null; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("id".equals(field)) { id = parser.getText(); } else if ("genome".equals(field)) { values = parser.getText(); } } return new Genome(id, values); } catch (IOException e) { logger.warn("could not parse genomes", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return null; } 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 Genome parseGenomes(final InputStream inputStream) { checkNotNull(inputStream); JsonParser parser = null; try { parser = jsonFactory.createParser(inputStream); parser.nextToken(); String id = null; String values = null; while (parser.nextToken() != JsonToken.END_OBJECT) { String field = parser.getCurrentName(); parser.nextToken(); if ("id".equals(field)) { id = parser.getText(); } else if ("genome".equals(field)) { values = parser.getText(); } } return new Genome(id, values); } catch (IOException e) { logger.warn("could not parse genomes", e); } finally { try { inputStream.close(); } catch (Exception e) { } try { parser.close(); } catch (Exception e) { } } return null; } 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);  }