-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update provenance, and indenting * Fix provenance output * Remove versioned_outdir * Remove versioned_outdir
- Loading branch information
Showing
6 changed files
with
305 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import json | ||
import os | ||
|
||
import yaml | ||
|
||
def main(args): | ||
db_metadata_path = os.path.join(args.db, 'metadata.json') | ||
db_metadata = {} | ||
if os.path.exists(db_metadata_path): | ||
with open(db_metadata_path, 'r') as f: | ||
db_metadata = json.load(f) | ||
|
||
if not db_metadata: | ||
exit() | ||
|
||
provenance = {} | ||
if args.provenance: | ||
with open(args.provenance, 'r') as f: | ||
provenance = yaml.safe_load(f) | ||
|
||
database_provenance = {} | ||
database_name = db_metadata.get('dbname', None) | ||
if database_name: | ||
database_provenance['database_name'] = database_name | ||
database_version = db_metadata.get('version', None) | ||
if database_version: | ||
database_provenance['database_version'] = database_version | ||
|
||
for provenance_record in provenance: | ||
if provenance_record.get('process_name') == 'kraken2': | ||
provenance_record['databases'] = [] | ||
provenance_record['databases'].append(database_provenance) | ||
|
||
with open(args.provenance, 'w') as f: | ||
yaml.dump(provenance, f) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Get metadata from Kraken database') | ||
parser.add_argument('--provenance', help='Path to provenance file') | ||
parser.add_argument('--db', help='Path to Kraken database') | ||
args = parser.parse_args() | ||
main(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
process collect_provenance { | ||
|
||
tag { sample_id } | ||
tag { sample_id } | ||
|
||
executor 'local' | ||
executor 'local' | ||
|
||
publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.pipeline_minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_*_provenance.yml", mode: 'copy' | ||
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_*_provenance.yml", mode: 'copy' | ||
|
||
input: | ||
tuple val(sample_id), path(provenance_files) | ||
input: | ||
tuple val(sample_id), path(provenance_files) | ||
|
||
output: | ||
tuple val(sample_id), file("${sample_id}_*_provenance.yml") | ||
output: | ||
tuple val(sample_id), file("${sample_id}_*_provenance.yml") | ||
|
||
script: | ||
""" | ||
cat ${provenance_files} > ${sample_id}_\$(date +%Y%m%d%H%M%S)_provenance.yml | ||
""" | ||
script: | ||
""" | ||
cat ${provenance_files} > ${sample_id}_\$(date +%Y%m%d%H%M%S)_provenance.yml | ||
""" | ||
} | ||
|
||
process pipeline_provenance { | ||
|
||
tag { pipeline_name + " / " + pipeline_version } | ||
tag { pipeline_name + " / " + pipeline_version } | ||
|
||
executor 'local' | ||
executor 'local' | ||
|
||
input: | ||
tuple val(pipeline_name), val(pipeline_version), val(analysis_start) | ||
input: | ||
tuple val(session_id), val(run_name), val(pipeline_name), val(pipeline_version), val(timestamp_analysis_start) | ||
|
||
output: | ||
file("pipeline_provenance.yml") | ||
output: | ||
file("pipeline_provenance.yml") | ||
|
||
script: | ||
""" | ||
printf -- "- pipeline_name: ${pipeline_name}\\n pipeline_version: ${pipeline_version}\\n- timestamp_analysis_start: ${analysis_start}\\n" > pipeline_provenance.yml | ||
""" | ||
script: | ||
""" | ||
printf -- "- pipeline_name: ${pipeline_name}\\n" >> pipeline_provenance.yml | ||
printf -- " pipeline_version: ${pipeline_version}\\n" >> pipeline_provenance.yml | ||
printf -- " nextflow_session_id: ${session_id}\\n" >> pipeline_provenance.yml | ||
printf -- " nextflow_run_name: ${run_name}\\n" >> pipeline_provenance.yml | ||
printf -- " timestamp_analysis_start: ${timestamp_analysis_start}\\n" >> pipeline_provenance.yml | ||
""" | ||
} |
Oops, something went wrong.