use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.
the class StrelkaCheckerTest method canAnalyseMinimalVCF.
@Test
public void canAnalyseMinimalVCF() throws IOException {
final RunContext runContext = TestRunContextFactory.forSomaticTest(MINIMAL_RUN_DIRECTORY, MINIMAL_REF_SAMPLE, MINIMAL_TUMOR_SAMPLE);
final MultiValueResult result = (MultiValueResult) checker.run(runContext);
assertEquals(EXPECTED_NUM_CHECKS, result.checks().size());
}
use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.
the class LoadClinicalData method main.
public static void main(@NotNull final String[] args) throws ParseException, IOException, XMLStreamException, SQLException {
LOGGER.info("Running patient-db v{}", VERSION);
final Options basicOptions = createBasicOptions();
final Options clinicalOptions = createLimsOptions();
final Options ecrfOptions = createEcrfOptions();
final Options options = mergeOptions(basicOptions, clinicalOptions, ecrfOptions);
final CommandLine cmd = createCommandLine(args, options);
final String runsFolderPath = cmd.getOptionValue(RUNS_DIR);
final String userName = cmd.getOptionValue(DB_USER);
final String password = cmd.getOptionValue(DB_PASS);
final String databaseUrl = cmd.getOptionValue(DB_URL);
final boolean loadRawEcrf = cmd.hasOption(DO_LOAD_RAW_ECRF);
if (Utils.anyNull(runsFolderPath, userName, password, databaseUrl)) {
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("patient-db", options);
} else {
final File runDirectory = new File(runsFolderPath);
if (runDirectory.isDirectory()) {
LOGGER.info("Running clinical data import.");
final List<RunContext> runContexts = RunsFolderReader.getRunContexts(runDirectory);
final String jdbcUrl = "jdbc:" + databaseUrl;
final DatabaseAccess dbWriter = new DatabaseAccess(userName, password, jdbcUrl);
if (loadRawEcrf) {
writeRawEcrf(ecrfOptions, cmd, runContexts, dbWriter);
}
writeClinicalData(clinicalOptions, cmd, runContexts, dbWriter);
} else {
if (!runDirectory.exists()) {
LOGGER.warn("dir " + runDirectory + " does not exist.");
}
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("patient-db", basicOptions);
}
}
}
use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.
the class LoadDrupEcrfData method main.
public static void main(@NotNull final String[] args) throws ParseException, IOException, XMLStreamException, SQLException {
final Options options = createOptions();
final CommandLine cmd = createCommandLine(args, options);
final String userName = cmd.getOptionValue(DB_USER);
final String password = cmd.getOptionValue(DB_PASS);
final String databaseUrl = cmd.getOptionValue(DB_URL);
final String ecrfFile = cmd.getOptionValue(ECRF_FILE);
final String runsFolderPath = cmd.getOptionValue(RUNS_DIR);
if (Utils.anyNull(userName, password, databaseUrl, ecrfFile, runsFolderPath)) {
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("patient-db - load DRUP ecrf", options);
} else {
final File runsDirectory = new File(runsFolderPath);
if (runsDirectory.isDirectory()) {
final String jdbcUrl = "jdbc:" + databaseUrl;
final DatabaseAccess dbWriter = new DatabaseAccess(userName, password, jdbcUrl);
dbWriter.clearDrupEcrf();
LOGGER.info("Importing DRUP ecrf data from: {}", ecrfFile);
final CpctEcrfModel model = CpctEcrfModel.loadFromXML(ecrfFile, new ImmutableFormStatusModel(Maps.newHashMap()));
final List<RunContext> runContexts = RunsFolderReader.getRunContexts(runsDirectory);
final Set<String> sequencedPatients = Utils.sequencedPatientIds(runContexts);
LOGGER.info("Writing raw ecrf data for " + model.patientCount() + " patients.");
dbWriter.writeDrupEcrf(model, sequencedPatients);
LOGGER.info("Done writing raw ecrf data for " + model.patientCount() + " patients!");
} else {
if (!runsDirectory.exists()) {
LOGGER.warn("dir " + runsDirectory + " does not exist.");
}
final HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("patient-db - load DRUP ecrf", options);
}
}
}
use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.
the class LoadMetricsData method main.
public static void main(@NotNull final String[] args) throws ParseException, SQLException, IOException {
final Options options = createOptions();
final CommandLine cmd = createCommandLine(args, options);
final String userName = cmd.getOptionValue(DB_USER);
final String password = cmd.getOptionValue(DB_PASS);
final String databaseUrl = cmd.getOptionValue(DB_URL);
final String runDirectoryPath = cmd.getOptionValue(RUN_DIR);
if (Utils.anyNull(userName, password, databaseUrl, runDirectoryPath)) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("patient-db - load metrics data", options);
} else {
final File runDirectory = new File(runDirectoryPath);
if (runDirectory.isDirectory()) {
final String jdbcUrl = "jdbc:" + databaseUrl;
final DatabaseAccess dbWriter = new DatabaseAccess(userName, password, jdbcUrl);
RunContext runContext = ProductionRunContextFactory.fromRunDirectory(runDirectory.toPath().toString());
LOGGER.info(String.format("Extracting and writing metrics for %s", runContext.runDirectory()));
try {
WGSMetrics metrics = generateMetricsForRun(runContext);
dbWriter.writeMetrics(runContext.tumorSample(), metrics);
} catch (IOException e) {
LOGGER.warn(String.format("Cannot extract metrics for %s.", runContext.runDirectory()));
}
} else {
if (!runDirectory.exists()) {
LOGGER.warn("dir " + runDirectory + " does not exist.");
}
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("patient-db - load metrics data", options);
}
}
}
use of com.hartwig.hmftools.common.context.RunContext in project hmftools by hartwigmedical.
the class RunsFolderReader method getRunContexts.
@NotNull
public static List<RunContext> getRunContexts(@NotNull final File dir) throws IOException {
final List<RunContext> runContexts = Lists.newArrayList();
final File[] folders = dir.listFiles(File::isDirectory);
if (folders == null) {
throw new IOException("List files in " + dir.getName() + " returned null.");
}
for (final File folder : folders) {
try {
final String runDirectory = FolderChecker.build().checkFolder(folder.getPath());
final RunContext runContext = ProductionRunContextFactory.fromRunDirectory(runDirectory);
runContexts.add(runContext);
} catch (IOException e) {
LOGGER.error(e.getMessage());
}
}
return runContexts;
}
Aggregations