def report_info(ap): """Generate a general report Generates an unstructured report on the contents of the analysis directory. Arguments: ap (AutoProcessor): autoprocessor pointing to the analysis directory to be reported on Returns: String with the report text. """ report = [] report.append("Run reference: %s" % ap.run_reference_id) report.append("Directory : %s" % ap.analysis_dir) report.append("Platform : %s" % ap.metadata.platform) report.append("Unaligned dir: %s" % ap.params.unaligned_dir) if ap.readme_file: report.append("README.txt found: %s" % ap.readme_file) if ap.params.unaligned_dir is not None or \ not os.path.exists(ap.params.unaligned_dir): try: illumina_data = ap.load_illumina_data() report.append("\nSummary of data in '%s' dir:\n" % ap.params.unaligned_dir) for project in illumina_data.projects: report.append("- %s" % IlluminaData.describe_project(project)) except IlluminaData.IlluminaDataError as ex: report.append("Failed to load data from %s:" % ap.params.unaligned_dir) report.append("%s" % ex) else: report.append("No information on source fastq data (no unaligned dir " "found)") try: projects = ap.get_analysis_projects() report.append("\n%d analysis project%s:" % (len(projects), "s" if len(projects) != 0 else "")) except Exception as ex: projects = [] report.append("\nNo analysis projects found") for project in projects: info = project.info report.append("\n- %s" % project.name) report.append(" %s" % ('-' * len(project.name), )) report.append(" User : %s" % info.user) report.append(" PI : %s" % info.PI) report.append(" Library : %s" % info.library_type) report.append(" SC Plat.: %s" % info.single_cell_platform) report.append(" Organism: %s" % info.organism) report.append(" Dir : %s" % os.path.basename(project.dirn)) report.append(" #samples: %s" % len(project.samples)) report.append(" #cells : %s" % default_value(info.number_of_cells)) report.append(" Samples : %s" % project.prettyPrintSamples()) report.append(" QC : %s" % ('ok' if verify_qc(project) else 'not verified')) report.append(" Comments: %s" % (project.info.comments)) return '\n'.join(report)
else: n_fastqs = len(sample.fastq) if n_fastqs == 1: print "\t%s" % sample.name else: print "\t%s (%d fastqs)" % (sample.name, n_fastqs) # Print fastq names fastqs = sample.fastq_subset(read_number=1) + \ sample.fastq_subset(read_number=2) for fastq in fastqs: print "\t\t%s" % fastq # Report the names of the samples in each project if options.report: for project in illumina_data.projects: print "%s" % IlluminaData.describe_project(project) # Report statistics for fastq files if options.stats: # Print number of reads for each file, and file size for sample in project.samples: for fastq in sample.fastq: fq = os.path.join(sample.dirn, fastq) nreads = FASTQFile.nreads(fq) fsize = os.path.getsize(fq) print "%s\t%s\t%d" % ( fastq, bcf_utils.format_file_size(fsize), nreads) print "" # Summary: short report suitable for logging file if options.summary: print "%s" % IlluminaData.summarise_projects(illumina_data)
else: n_fastqs = len(sample.fastq) if n_fastqs == 1: print "\t%s" % sample.name else: print "\t%s (%d fastqs)" % (sample.name,n_fastqs) # Print fastq names fastqs = sample.fastq_subset(read_number=1) + \ sample.fastq_subset(read_number=2) for fastq in fastqs: print "\t\t%s" % fastq # Report the names of the samples in each project if options.report: for project in illumina_data.projects: print "%s" % IlluminaData.describe_project(project) # Report statistics for fastq files if options.stats: # Print number of reads for each file, and file size for sample in project.samples: for fastq in sample.fastq: fq = os.path.join(sample.dirn,fastq) nreads = FASTQFile.nreads(fq) fsize = os.path.getsize(fq) print "%s\t%s\t%d" % (fastq, bcf_utils.format_file_size(fsize), nreads) print "" # Summary: short report suitable for logging file if options.summary: