@Override public CoverageMongoDBWriter getDBWriter(String dbName) { String fileId = configuration .getStorageEngine(STORAGE_ENGINE_ID) .getAlignment() .getOptions() .getString(Options.FILE_ID.key()); return new CoverageMongoDBWriter(getMongoCredentials(dbName), fileId); }
@Override public URI load(URI inputUri) throws IOException { checkUri(inputUri, "input uri"); Path input = Paths.get(inputUri.getPath()); // ObjectMapper objectMapper = new ObjectMapper(); // System.out.println("configuration = " + // objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(configuration)); ObjectMap options = configuration.getStorageEngine(STORAGE_ENGINE_ID).getAlignment().getOptions(); String fileId = options.getString(Options.FILE_ID.key(), input.getFileName().toString().split("\\.")[0]); String dbName = options.getString(Options.DB_NAME.key(), Options.DB_NAME.defaultValue()); // Reader AlignmentCoverageJsonDataReader alignmentDataReader = getAlignmentCoverageJsonDataReader(input); alignmentDataReader.setReadRegionCoverage(false); // Only load mean coverage // Writer CoverageMongoDBWriter dbWriter = this.getDBWriter(dbName); // Runner Runner<AlignmentRegion> runner = new Runner<>( alignmentDataReader, Arrays.asList(dbWriter), new LinkedList<Task<AlignmentRegion>>(), 1); logger.info("Loading coverage..."); long start = System.currentTimeMillis(); runner.run(); long end = System.currentTimeMillis(); logger.info("end - start = " + (end - start) / 1000.0 + "s"); logger.info("Alignments loaded!"); return inputUri; // TODO: Return something like this: mongo://<host>/<dbName>/<collectionName> }