Mercurial > repos > devteam > data_manager_twobit_builder
annotate data_manager/twobit_builder.py @ 7:94a50db37d1a draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 096286097ed5cdf189a1b68c3fc34d10f4142e54
author | iuc |
---|---|
date | Sun, 16 Apr 2023 08:31:43 +0000 |
parents | 62359a151521 |
children |
rev | line source |
---|---|
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
1 #!/usr/bin/env python |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
2 # Dan Blankenberg |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
3 from __future__ import print_function |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
4 |
5
625fd9476402
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents:
3
diff
changeset
|
5 import json |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
6 import optparse |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
7 import os |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
8 import subprocess |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
9 import sys |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
10 import tempfile |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
11 |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
12 CHUNK_SIZE = 2**20 # 1mb |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
13 |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
14 |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
15 def get_id_name(params, dbkey, fasta_description=None): |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
16 # TODO: ensure sequence_id is unique and does not already appear in location file |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
17 sequence_id = params['param_dict']['sequence_id'] |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
18 if not sequence_id: |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
19 sequence_id = dbkey # uuid.uuid4() generate and use an uuid |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
20 |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
21 sequence_name = params['param_dict']['sequence_name'] |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
22 if not sequence_name: |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
23 sequence_name = fasta_description |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
24 if not sequence_name: |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
25 sequence_name = dbkey |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
26 return sequence_id, sequence_name |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
27 |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
28 |
7
94a50db37d1a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 096286097ed5cdf189a1b68c3fc34d10f4142e54
iuc
parents:
6
diff
changeset
|
29 def build_twobit(data_manager_dict, fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name): |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
30 twobit_base_name = "%s.2bit" % (sequence_id) |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
31 twobit_filename = os.path.join(target_directory, twobit_base_name) |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
32 |
7
94a50db37d1a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 096286097ed5cdf189a1b68c3fc34d10f4142e54
iuc
parents:
6
diff
changeset
|
33 args = ['faToTwoBit', fasta_filename, twobit_filename] |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
34 tmp_stderr = tempfile.NamedTemporaryFile(prefix="tmp-data-manager-twobit-builder-stderr") |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
35 proc = subprocess.Popen(args=args, shell=False, cwd=target_directory, stderr=tmp_stderr.fileno()) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
36 return_code = proc.wait() |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
37 if return_code: |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
38 tmp_stderr.flush() |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
39 tmp_stderr.seek(0) |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
40 print("Error building index:", file=sys.stderr) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
41 while True: |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
42 chunk = tmp_stderr.read(CHUNK_SIZE) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
43 if not chunk: |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
44 break |
7
94a50db37d1a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 096286097ed5cdf189a1b68c3fc34d10f4142e54
iuc
parents:
6
diff
changeset
|
45 sys.stderr.write(chunk) |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
46 sys.exit(return_code) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
47 tmp_stderr.close() |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
48 # lastz_seqs |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
49 data_table_entry = dict(value=sequence_id, name=sequence_name, path=twobit_base_name) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
50 |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
51 _add_data_table_entry(data_manager_dict, "lastz_seqs", data_table_entry) |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
52 # twobit.loc |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
53 data_table_entry = dict(value=sequence_id, path=twobit_base_name) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
54 |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
55 _add_data_table_entry(data_manager_dict, "twobit", data_table_entry) |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
56 # alignseq |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
57 data_table_entry = dict(type="seq", value=sequence_id, path=twobit_base_name) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
58 |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
59 _add_data_table_entry(data_manager_dict, "alignseq_seq", data_table_entry) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
60 |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
61 |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
62 def _add_data_table_entry(data_manager_dict, data_table_name, data_table_entry): |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
63 data_manager_dict['data_tables'] = data_manager_dict.get('data_tables', {}) |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
64 data_manager_dict['data_tables'][data_table_name] = data_manager_dict['data_tables'].get(data_table_name, []) |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
65 data_manager_dict['data_tables'][data_table_name].append(data_table_entry) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
66 return data_manager_dict |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
67 |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
68 |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
69 def main(): |
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
70 parser = optparse.OptionParser() |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
71 parser.add_option('-f', '--fasta_filename', dest='fasta_filename', action='store', type="string", default=None, help='fasta_filename') |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
72 parser.add_option('-d', '--fasta_dbkey', dest='fasta_dbkey', action='store', type="string", default=None, help='fasta_dbkey') |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
73 parser.add_option('-t', '--fasta_description', dest='fasta_description', action='store', type="string", default=None, help='fasta_description') |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
74 (options, args) = parser.parse_args() |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
75 |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
76 filename = args[0] |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
77 |
5
625fd9476402
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents:
3
diff
changeset
|
78 with open(filename) as fh: |
625fd9476402
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents:
3
diff
changeset
|
79 params = json.load(fh) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
80 |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
81 target_directory = params['output_data'][0]['extra_files_path'] |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
82 os.mkdir(target_directory) |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
83 data_manager_dict = {} |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
84 |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
85 dbkey = options.fasta_dbkey |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
86 |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
87 if dbkey in [None, '', '?']: |
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
88 raise Exception('"%s" is not a valid dbkey. You must specify a valid dbkey.' % (dbkey)) |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
89 |
3
5c77d4091880
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 82ad45497a7b2277a710c634378a4122fb75ce1f"
iuc
parents:
2
diff
changeset
|
90 sequence_id, sequence_name = get_id_name(params, dbkey=dbkey, fasta_description=options.fasta_description) |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
91 |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
92 # build the index |
7
94a50db37d1a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 096286097ed5cdf189a1b68c3fc34d10f4142e54
iuc
parents:
6
diff
changeset
|
93 build_twobit(data_manager_dict, options.fasta_filename, params, target_directory, dbkey, sequence_id, sequence_name) |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
94 |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
95 # save info to json file |
5
625fd9476402
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents:
3
diff
changeset
|
96 with open(filename, 'w') as fh: |
625fd9476402
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 02d2967f77e3fa5a18aea63dc84aa9ab418dc165"
iuc
parents:
3
diff
changeset
|
97 json.dump(data_manager_dict, fh, sort_keys=True) |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
98 |
0
74b09c8e5f6e
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/data_managers/data_manager_twobit_builder commit 130cb0c08ad3c5b858ba46b1024dcdccc3cb68c6-dirty
devteam
parents:
diff
changeset
|
99 |
2
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
100 if __name__ == "__main__": |
9946bc39c834
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_twobit_builder commit 8652f36a3a3838dca989426961561e81432acf4f
iuc
parents:
0
diff
changeset
|
101 main() |