JannovarDataSourceLoader { public static JannovarData loadJannovarData(Path transcriptFilePath){ try { return JannovarDataProtoSerialiser.load(transcriptFilePath); } catch (Exception e) { logger.debug("Unable to load Jannovar data - {}", e.getMessage()); logger.debug("Incorrect Jannovar data format? Will try the old version..."); } try { return new JannovarDataSerializer(transcriptFilePath.toString()).load(); } catch (SerializationException e) { throw new JannovarException("Could not load Jannovar data from " + transcriptFilePath, e); } } private  JannovarDataSourceLoader(); static JannovarData loadJannovarData(Path transcriptFilePath);  }
@Test public void loadsOldFormatData() { Path jannovarDataPath = Paths.get("src/test/resources/jannovar/1710_hg19_transcripts_ensembl.ser"); JannovarData jannovarData = JannovarDataSourceLoader.loadJannovarData(jannovarDataPath); assertThat(jannovarData, instanceOf(JannovarData.class) ); }
@Test public void loadsNewFormatData() { Path jannovarDataPath = Paths.get("src/test/resources/jannovar/1710_hg19_transcripts_ensembl_new_format.ser"); JannovarData jannovarData = JannovarDataSourceLoader.loadJannovarData(jannovarDataPath); assertThat(jannovarData, instanceOf(JannovarData.class) ); }
@Test public void cannotLoadData() { Path jannovarDataPath = Paths.get("src/test/resources/data/1710_hg19/wibble.ser"); assertThrows(JannovarException.class, () -> JannovarDataSourceLoader.loadJannovarData(jannovarDataPath)); }