Merge branch '8784-dir-listings'
[arvados.git] / crunch_scripts / rtg-fasta2sdf
1 #!/usr/bin/env python
2 # Copyright (C) The Arvados Authors. All rights reserved.
3 #
4 # SPDX-License-Identifier: Apache-2.0
5
6 import arvados
7 import os
8 import re
9 import sys
10 import pyrtg
11
12 this_job = arvados.current_job()
13 this_task = arvados.current_task()
14 fasta_path = arvados.util.collection_extract(
15     collection = this_job['script_parameters']['input'],
16     path = 'fasta',
17     decompress = False)
18 fasta_files = filter(lambda f: f != '.locator', os.listdir(fasta_path))
19 out_dir = os.path.join(arvados.current_task().tmpdir, 'ref-sdf')
20 arvados.util.run_command(['rm', '-rf', out_dir], stderr=sys.stderr)
21
22 pyrtg.run_rtg('format', out_dir,
23               map(lambda f: os.path.join(fasta_path, f), fasta_files))
24
25 out = arvados.CollectionWriter()
26 out.write_directory_tree(out_dir, max_manifest_depth=0)
27 this_task.set_output(out.finish())