def markerPlot(self, options): """Marker gene position plot command""" self.logger.info( '[CheckM - marker_plot] Creating marker gene position plot.') checkDirExists(options.bin_dir) makeSurePathExists(options.output_dir) # generate plot for each bin binFiles = self.binFiles(options.bin_dir, options.extension) resultsParser = ResultsParser(None) markerGeneStats = resultsParser.parseMarkerGeneStats( options.results_dir) binStats = resultsParser.parseBinStatsExt(options.results_dir) plot = MarkerGenePosPlot(options) filesProcessed = 1 for f in binFiles: binId = binIdFromFilename(f) self.logger.info( 'Plotting marker gene position plot for %s (%d of %d)' % (binId, filesProcessed, len(binFiles))) filesProcessed += 1 if binId not in markerGeneStats or binId not in binStats: continue # bin has no marker genes bPlotted = plot.plot(f, markerGeneStats[binId], binStats[binId]) if bPlotted: outputFile = os.path.join( options.output_dir, binId) + '.marker_pos_plot.' + options.image_type plot.savePlot(outputFile, dpi=options.dpi) self.logger.info('Plot written to: ' + outputFile) else: self.logger.info('No marker genes found in bin.') self.timeKeeper.printTimeStamp()
def binQAPlot(self, options): """Bin QA plot command""" self.logger.info( '[CheckM - bin_qa_plot] Creating bar plot of bin quality.') checkDirExists(options.bin_dir) makeSurePathExists(options.output_dir) binFiles = self.binFiles(options.bin_dir, options.extension) # read model info # hmmModelInfoFile = os.path.join(options.analyze_dir, 'storage', DefaultValues.CHECKM_HMM_MODEL_INFO) # binIdToModels = markerSetParser.loadBinModels(hmmModelInfoFile) # read sequence stats file resultsParser = ResultsParser(None) binStatsExt = resultsParser.parseBinStatsExt(options.results_dir) # create plot for each bin plot = BinQAPlot(options) bMakePlot = True if not options.bIgnoreHetero: aai = AminoAcidIdentity() aai.run(options.aai_strain, options.results_dir, None) bMakePlot = plot.plot(binFiles, binStatsExt, options.bIgnoreHetero, aai.aaiHetero) else: bMakePlot = plot.plot(binFiles, binStatsExt, options.bIgnoreHetero, None) if bMakePlot: outputFile = os.path.join(options.output_dir, 'bin_qa_plot.' + options.image_type) plot.savePlot(outputFile, dpi=options.dpi) self.logger.info('Plot written to: ' + outputFile) self.timeKeeper.printTimeStamp()