@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> }
@Override public AlignmentDBAdaptor getDBAdaptor(String dbName) { SequenceDBAdaptor adaptor; if (dbName == null || dbName.isEmpty()) { dbName = configuration .getStorageEngine(STORAGE_ENGINE_ID) .getAlignment() .getOptions() .getString(Options.DB_NAME.key(), Options.DB_NAME.defaultValue()); logger.info( "Using default dbName '{}' in MongoDBAlignmentStorageManager.getDBAdaptor()", dbName); } logger.debug("Using {} : '{}'", Options.DB_NAME.key(), dbName); Path path = Paths.get( configuration .getStorageEngine(STORAGE_ENGINE_ID) .getAlignment() .getOptions() .getString(OPENCGA_STORAGE_SEQUENCE_DBADAPTOR, "")); if (path == null || path.toString() == null || path.toString().isEmpty() || !path.toFile().exists()) { adaptor = new CellBaseSequenceDBAdaptor(); } else { if (path.toString().endsWith("sqlite.db")) { adaptor = new SqliteSequenceDBAdaptor(path); } else { adaptor = new CellBaseSequenceDBAdaptor(path); } } return new IndexedAlignmentDBAdaptor(adaptor, getMongoCredentials(dbName)); }