Package org.bioinfo.ngs.qc.qualimap.process

Examples of org.bioinfo.ngs.qc.qualimap.process.BamStatsAnalysis


        for (TestConfig test : tests) {

            System.err.println("\nRunning test " + test.getPath() + "\n");


            BamStatsAnalysis bamQc = new BamStatsAnalysis(test.getPathToBamFile()) ;

            String pathToRegionFile = test.getPathToRegionFile();
            if (pathToRegionFile != null && !pathToRegionFile.isEmpty()) {
                bamQc.setSelectedRegions(pathToRegionFile);
                bamQc.setComputeOutsideStats(test.getComputeOutsideStats());
            }

            BamQCRegionReporter bamQcReporter = new BamQCRegionReporter(false, true);


            try {
                bamQc.run();
                bamQcReporter.loadReportData(bamQc.getBamStats());
                bamQcReporter.computeChartsBuffers(bamQc.getBamStats(), bamQc.getLocator(), bamQc.isPairedData());
            } catch (Exception e) {
                assertTrue("Error calculating stats. " + e.getMessage(), false);
                e.printStackTrace();
                return;
            }

            Properties calculatedProps = bamQcReporter.generateBamQcProperties();

            // For generating correct tests
            try {
                calculatedProps.store(new FileOutputStream(test.getResultsPath() + ".new"), null);
            } catch (IOException e) {
                e.printStackTrace();
            }

            compareProperties(calculatedProps, test.getResultsPath());

            if (test.getComputeOutsideStats() && test.getOutsideResultsPath() != null) {
                BamQCRegionReporter outsideReporter = new BamQCRegionReporter(true, false);
                outsideReporter.loadReportData(bamQc.getOutsideBamStats());
                /*outsideReporter.computeChartsBuffers(bamQc.getOutsideBamStats(),
                        bamQc.getLocator(), bamQc.isPairedData());*/
                Properties outsideProps = outsideReporter.generateBamQcProperties();

                /*try {
View Full Code Here


    // check outdir
    initOutputDir();

    // init bamqc
    BamStatsAnalysis bamQC = new BamStatsAnalysis(bamFile);

        if(selectedRegionsAvailable){
      bamQC.setSelectedRegions(gffFile);
      bamQC.setComputeOutsideStats(computeOutsideStats);
    }

    // reporting
    bamQC.activeReporting(outdir);
        if (coverageReportFile.length() > 0) {
            bamQC.setPathToCoverageReport(coverageReportFile);
        }

    logger.println("Starting bam qc....");

    // number of windows
    bamQC.setNumberOfWindows(numberOfWindows);
        bamQC.setNumberOfThreads(numThreads);
        bamQC.setNumberOfReadsInBunch(bunchSize);
        bamQC.setProtocol(protocol);
        bamQC.setMinHomopolymerSize(minHomopolymerSize);

    // run evaluation
    bamQC.run();

    logger.println("end of bam qc");

    logger.println("Computing report...");

    BamQCRegionReporter reporter = new BamQCRegionReporter(selectedRegionsAvailable, true);
    reporter.setPaintChromosomeLimits(paintChromosomeLimits);
        if (!genomeToCompare.isEmpty()) {
            reporter.setGenomeGCContentName(genomeToCompare);
        }

        bamQC.prepareInputDescription(reporter, paintChromosomeLimits);

    // save stats

        reporter.writeReport(bamQC.getBamStats(),outdir);

        AnalysisResultManager resultManager = new AnalysisResultManager(AnalysisType.BAM_QC);

        reporter.loadReportData(bamQC.getBamStats());
        reporter.computeChartsBuffers(bamQC.getBamStats(), bamQC.getLocator(), bamQC.isPairedData());
        resultManager.addReporter(reporter);

        if(selectedRegionsAvailable && computeOutsideStats){

            BamQCRegionReporter outsideReporter = new BamQCRegionReporter(selectedRegionsAvailable, false);
            outsideReporter.setPaintChromosomeLimits(paintChromosomeLimits);
            if (!genomeToCompare.isEmpty()) {
                outsideReporter.setGenomeGCContentName(genomeToCompare);
            }
            bamQC.prepareInputDescription(outsideReporter, paintChromosomeLimits);
            outsideReporter.writeReport(bamQC.getOutsideBamStats(),outdir);

            outsideReporter.loadReportData(bamQC.getOutsideBamStats());
            outsideReporter.computeChartsBuffers(bamQC.getOutsideBamStats(), bamQC.getLocator(), bamQC.isPairedData());

            resultManager.addReporter(outsideReporter);
        }

View Full Code Here

  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);
            }
View Full Code Here

TOP

Related Classes of org.bioinfo.ngs.qc.qualimap.process.BamStatsAnalysis

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.