Search in sources :

Example 6 with RunContext

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());
}
Also used : MultiValueResult(com.hartwig.hmftools.healthchecker.result.MultiValueResult) RunContext(com.hartwig.hmftools.common.context.RunContext) Test(org.junit.Test)

Example 7 with RunContext

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);
        }
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) DatabaseAccess(com.hartwig.hmftools.patientdb.dao.DatabaseAccess) RunContext(com.hartwig.hmftools.common.context.RunContext) File(java.io.File)

Example 8 with RunContext

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);
        }
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) DatabaseAccess(com.hartwig.hmftools.patientdb.dao.DatabaseAccess) RunContext(com.hartwig.hmftools.common.context.RunContext) File(java.io.File) ImmutableFormStatusModel(com.hartwig.hmftools.common.ecrf.formstatus.ImmutableFormStatusModel) CpctEcrfModel(com.hartwig.hmftools.common.ecrf.CpctEcrfModel)

Example 9 with RunContext

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);
        }
    }
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) WGSMetrics(com.hartwig.hmftools.common.metrics.WGSMetrics) DatabaseAccess(com.hartwig.hmftools.patientdb.dao.DatabaseAccess) RunContext(com.hartwig.hmftools.common.context.RunContext) IOException(java.io.IOException) File(java.io.File) WGSMetricsFile(com.hartwig.hmftools.common.metrics.WGSMetricsFile)

Example 10 with RunContext

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;
}
Also used : RunContext(com.hartwig.hmftools.common.context.RunContext) IOException(java.io.IOException) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RunContext (com.hartwig.hmftools.common.context.RunContext)16 Test (org.junit.Test)9 File (java.io.File)5 CommandLine (org.apache.commons.cli.CommandLine)5 HelpFormatter (org.apache.commons.cli.HelpFormatter)5 Options (org.apache.commons.cli.Options)5 BaseResult (com.hartwig.hmftools.healthchecker.result.BaseResult)4 DatabaseAccess (com.hartwig.hmftools.patientdb.dao.DatabaseAccess)4 MultiValueResult (com.hartwig.hmftools.healthchecker.result.MultiValueResult)3 IOException (java.io.IOException)3 NotNull (org.jetbrains.annotations.NotNull)3 CpctEcrfModel (com.hartwig.hmftools.common.ecrf.CpctEcrfModel)2 Lims (com.hartwig.hmftools.common.lims.Lims)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 EcrfPatient (com.hartwig.hmftools.common.ecrf.datamodel.EcrfPatient)1 ValidationFinding (com.hartwig.hmftools.common.ecrf.datamodel.ValidationFinding)1 TumorLocationDoidMapping (com.hartwig.hmftools.common.ecrf.doid.TumorLocationDoidMapping)1 FormStatusModel (com.hartwig.hmftools.common.ecrf.formstatus.FormStatusModel)1 FormStatusReader (com.hartwig.hmftools.common.ecrf.formstatus.FormStatusReader)1