public void run() {
// Create the outputDir directory
StringBuilder outputDirPath = resultManager.createDirectory();
BamStatsAnalysis bamQC = new BamStatsAnalysis(bamDialog.getInputFile().getAbsolutePath());
// Set the number of windows
bamQC.setNumberOfWindows(bamDialog.getNumberOfWindows());
bamQC.setNumberOfThreads(bamDialog.getNumThreads());
bamQC.setNumberOfReadsInBunch(bamDialog.getBunchSize());
bamQC.setProtocol( bamDialog.getLibraryProtocol() );
bamQC.setMinHomopolymerSize( bamDialog.getMinHomopolymerSize());
// Set the region file
boolean regionsAvailable = false;
if (bamDialog.getRegionFile() != null) {
bamQC.setSelectedRegions(bamDialog.getRegionFile().getAbsolutePath());
bamQC.setComputeOutsideStats(bamDialog.getComputeOutsideRegions());
regionsAvailable = true;
}
// reporting
bamQC.activeReporting(outputDirPath.toString());
// setup logging
AnalysisDialogLoggerThread loggerThread = new AnalysisDialogLoggerThread(bamDialog);
bamQC.setLoggerThread(loggerThread);
bamDialog.setUiEnabled(false);
bamDialog.getProgressStream().setText("Running BAM file analysis...");
try {
bamQC.run();
//timer.cancel();
bamDialog.getProgressStream().setText("End of bam qc");
bamDialog.getProgressBar().setValue(100);
// report
bamDialog.getProgressStream().setText("Computing report...");
BamQCRegionReporter reporter = new BamQCRegionReporter(regionsAvailable, true);
bamQC.prepareInputDescription(reporter, bamDialog.getDrawChromosomeLimits());
// Draw the Chromosome Limits or not
reporter.setPaintChromosomeLimits( bamDialog.getDrawChromosomeLimits() );
if (bamDialog.compareGcContentToPrecalculated()) {
String genomeName = bamDialog.getGenomeName();
reporter.setGenomeGCContentName(genomeName);
}
bamDialog.getProgressStream().setText(" text report...");
reporter.loadReportData(bamQC.getBamStats());
bamDialog.getProgressStream().setText("OK");
bamDialog.getProgressStream().setText(" charts...");
reporter.computeChartsBuffers(bamQC.getBamStats(), bamQC.getLocator(), bamQC.isPairedData());
bamDialog.getProgressStream().setText("OK");
// Set the reporter into the created tab
resultManager.addReporter(reporter);
if (bamDialog.getRegionFile() != null && bamDialog.getComputeOutsideRegions() ) {
BamQCRegionReporter outsideReporter = new BamQCRegionReporter(regionsAvailable, false);
bamQC.prepareInputDescription(outsideReporter, bamDialog.getDrawChromosomeLimits());
// Draw the Chromosome Limits or not
outsideReporter.setPaintChromosomeLimits(bamDialog.getDrawChromosomeLimits());
if (bamDialog.compareGcContentToPrecalculated()) {
String genomeName = bamDialog.getGenomeName();
outsideReporter.setGenomeGCContentName(genomeName);
}
// save stats
bamDialog.getProgressStream().setText(" outside text report...");
outsideReporter.loadReportData(bamQC.getOutsideBamStats());
bamDialog.getProgressStream().setText("OK");
// save charts
bamDialog.getProgressStream().setText(" outside charts...");
outsideReporter.computeChartsBuffers(bamQC.getOutsideBamStats(), bamQC.getLocator(), bamQC.isPairedData());
bamDialog.getProgressStream().setText("OK");
// Set the reporters into the created tab
resultManager.addReporter(outsideReporter);
}