#!/usr/bin/env python from __future__ import print_function from collections import OrderedDict import re regexes = { 'nf-core/methylseq': ['v_pipeline.txt', r"(\S+)"], 'Nextflow': ['v_nextflow.txt', r"(\S+)"], 'Bismark genomePrep': ['v_bismark_genome_preparation.txt', r"Bismark Genome Preparation Version: v(\S+)"], 'FastQC': ['v_fastqc.txt', r"FastQC v(\S+)"], 'Cutadapt': ['v_cutadapt.txt', r"(\S+)"], 'Trim Galore!': ['v_trim_galore.txt', r"version (\S+)"], 'Bismark': ['v_bismark.txt', r"Bismark Version: v(\S+)"], 'Bismark Deduplication': ['v_deduplicate_bismark.txt', r"Deduplicator Version: v(\S+)"], 'Bismark methXtract': ['v_bismark_methylation_extractor.txt', r"Bismark Extractor Version: v(\S+)"], 'Bismark Report': ['v_bismark2report.txt', r"bismark2report version: v(\S+)"], 'Bismark Summary': ['v_bismark2summary.txt', r"bismark2summary version: (\S+)"], 'HISAT2': ['v_hisat2.txt', r"version (\S+)"], 'Samtools': ['v_samtools.txt', r"samtools (\S+)"], 'BWA': ['v_bwa.txt', r"Version: (\S+)"], 'bwa-meth': ['v_bwameth.txt', r"bwa-meth\.py (\S+)"], 'Picard MarkDuplicates': ['v_picard_markdups.txt', r"([\d\.]+)"], 'MethylDackel': ['v_methyldackel.txt', r"(.+)"], 'Qualimap': ['v_qualimap.txt', r"QualiMap v.(\S+)"], 'Preseq': ['v_preseq.txt', r"Version: (\S+)"], 'MultiQC': ['v_multiqc.txt', r"multiqc, version (\S+)"], } results = OrderedDict() results['nf-core/methylseq'] = 'N/A' results['Nextflow'] = 'N/A' results['Bismark genomePrep'] = 'N/A' results['FastQC'] = 'N/A' results['Cutadapt'] = 'N/A' results['Trim Galore!'] = 'N/A' results['Bismark'] = 'N/A' results['Bismark Deduplication'] = 'N/A' results['Bismark methXtract'] = 'N/A' results['Bismark Report'] = 'N/A' results['Bismark Summary'] = 'N/A' results['Samtools'] = 'N/A' results['BWA'] = 'N/A' results['bwa-meth'] = 'N/A' results['Picard MarkDuplicates'] = 'N/A' results['MethylDackel'] = 'N/A' results['Qualimap'] = 'N/A' results['Preseq'] = 'N/A' results['MultiQC'] = 'N/A' # Search each file using its regex for k, v in regexes.items(): try: with open(v[0]) as x: versions = x.read() match = re.search(v[1], versions) if match: results[k] = "v{}".format(match.group(1)) except IOError: results[k] = False # Remove software set to false in results for k in list(results): if not results[k]: del results[k] # Dump to YAML print( """ id: 'software_versions' section_name: 'nf-core/methylseq Software Versions' section_href: 'https://github.com/nf-core/methylseq' plot_type: 'html' description: 'are collected at run time from the software output.' data: |
""" ) for k, v in results.items(): print("
{}
{}
".format(k, v)) print("
") # Write out regexes as csv file: with open("software_versions.csv", "w") as f: for k, v in results.items(): f.write("{}\t{}\n".format(k, v))