def parse_reports(self):
    """ Find Qualimap BamQC reports and parse their data """

    # General stats - genome_results.txt
    self.qualimap_bamqc_genome_results = dict()
    for f in self.find_log_files('qualimap/bamqc/genome_results'):
        parse_genome_results(self, f)
    self.qualimap_bamqc_genome_results = self.ignore_samples(self.qualimap_bamqc_genome_results)

    # Coverage - coverage_histogram.txt
    self.qualimap_bamqc_coverage_hist = dict()
    for f in self.find_log_files('qualimap/bamqc/coverage', filehandles=True):
        parse_coverage(self, f)
    self.qualimap_bamqc_coverage_hist = self.ignore_samples(self.qualimap_bamqc_coverage_hist)

    # Insert size - insert_size_histogram.txt
    self.qualimap_bamqc_insert_size_hist = dict()
    for f in self.find_log_files('qualimap/bamqc/insert_size', filehandles=True):
        parse_insert_size(self, f)
    self.qualimap_bamqc_insert_size_hist = self.ignore_samples(self.qualimap_bamqc_insert_size_hist)

    # GC distribution - mapped_reads_gc-content_distribution.txt
    self.qualimap_bamqc_gc_content_dist = dict()
    self.qualimap_bamqc_gc_by_species = dict()  # {'HUMAN': data_dict, 'MOUSE': data_dict}
    for f in self.find_log_files('qualimap/bamqc/gc_dist', filehandles=True):
        parse_gc_dist(self, f)
    self.qualimap_bamqc_gc_by_species = self.ignore_samples(self.qualimap_bamqc_gc_by_species)

    num_parsed = max(
        len(self.qualimap_bamqc_genome_results),
        len(self.qualimap_bamqc_coverage_hist),
        len(self.qualimap_bamqc_insert_size_hist),
        len(self.qualimap_bamqc_gc_content_dist)
    )
    # Go no further if nothing found
    if num_parsed == 0:
        return 0

    try:
        covs = config.qualimap_config['general_stats_coverage']
        assert type(covs) == list
        assert len(covs) > 0
        covs = [str(i) for i in covs]
        log.debug("Custom Qualimap thresholds: {}".format(", ".join([i for i in covs])))
    except (AttributeError, TypeError, AssertionError):
        covs = [1, 5, 10, 30, 50]
        covs = [str(i) for i in covs]
        log.debug("Using default Qualimap thresholds: {}".format(", ".join([i for i in covs])))
    self.covs = covs

    # Make the plots for the report
    report_sections(self)

    # Set up the general stats table
    general_stats_headers(self)

    # Return the number of reports we found
    return num_parsed
def parse_reports ( self ) : self . qualimap_bamqc_genome_results = dict ( ) for f in self . find_log_files ( 'qualimap/bamqc/genome_results' ) : parse_genome_results ( self , f ) self . qualimap_bamqc_genome_results = self . ignore_samples ( self . qualimap_bamqc_genome_results ) self . qualimap_bamqc_coverage_hist = dict ( ) for f in self . find_log_files ( 'qualimap/bamqc/coverage' , filehandles = True ) : parse_coverage ( self , f ) self . qualimap_bamqc_coverage_hist = self . ignore_samples ( self . qualimap_bamqc_coverage_hist ) self . qualimap_bamqc_insert_size_hist = dict ( ) for f in self . find_log_files ( 'qualimap/bamqc/insert_size' , filehandles = True ) : parse_insert_size ( self , f ) self . qualimap_bamqc_insert_size_hist = self . ignore_samples ( self . qualimap_bamqc_insert_size_hist ) self . qualimap_bamqc_gc_content_dist = dict ( ) self . qualimap_bamqc_gc_by_species = dict ( ) for f in self . find_log_files ( 'qualimap/bamqc/gc_dist' , filehandles = True ) : parse_gc_dist ( self , f ) self . qualimap_bamqc_gc_by_species = self . ignore_samples ( self . qualimap_bamqc_gc_by_species ) num_parsed = max ( len ( self . qualimap_bamqc_genome_results ) , len ( self . qualimap_bamqc_coverage_hist ) , len ( self . qualimap_bamqc_insert_size_hist ) , len ( self . qualimap_bamqc_gc_content_dist ) ) if num_parsed == 0 : return 0 try : covs = config . qualimap_config [ 'general_stats_coverage' ] assert type ( covs ) == list assert len ( covs ) > 0 covs = [ str ( i ) for i in covs ] log . debug ( "Custom Qualimap thresholds: {}" . format ( ", " . join ( [ i for i in covs ] ) ) ) except ( AttributeError , TypeError , AssertionError ) : covs = [ 1 , 5 , 10 , 30 , 50 ] covs = [ str ( i ) for i in covs ] log . debug ( "Using default Qualimap thresholds: {}" . format ( ", " . join ( [ i for i in covs ] ) ) ) self . covs = covs report_sections ( self ) general_stats_headers ( self ) return num_parsed
Find Qualimap BamQC reports and parse their data