Mercurial > repos > tduigou > cloning_simulation
annotate cloning_simulation.py @ 16:fbb241adf6c2 draft default tip
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
author | tduigou |
---|---|
date | Thu, 17 Jul 2025 10:17:24 +0000 |
parents | 16ccb36aa8e3 |
children |
rev | line source |
---|---|
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
1 import argparse |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
2 import os |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
3 import json |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
4 import zipfile |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
5 import pandas |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
6 import dnacauldron |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
7 |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
8 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
9 def cloning_simulation(files_to_assembly, domesticated_list, |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
10 csv_file, assembly_type, topology, |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
11 file_name_mapping, file_name_mapping_dom, |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
12 use_file_names_as_id, |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
13 outdir_simulation, output_simulation, enzyme, outdir_gb): |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
14 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
15 files_to_assembly = files_to_assembly.split(',') |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
16 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
17 repository = dnacauldron.SequenceRepository() |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
18 repository.import_records(files=files_to_assembly, |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
19 use_file_names_as_ids=use_file_names_as_id, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
20 topology=topology) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
21 if domesticated_list: |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
22 domesticated_files = domesticated_list.split(',') |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
23 repository.import_records(files=domesticated_files, |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
24 use_file_names_as_ids=use_file_names_as_id, |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
25 topology=topology) |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
26 |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
27 # refine the real record name dict |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
28 if isinstance(file_name_mapping, str): |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
29 file_name_mapping = dict( |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
30 item.split(":") for item in file_name_mapping.split(",") |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
31 ) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
32 real_names = { |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
33 os.path.splitext(os.path.basename(k))[0]: v.replace(".gb", "") |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
34 for k, v in file_name_mapping.items() |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
35 } |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
36 |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
37 # refine the real record name dict_dom |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
38 if file_name_mapping_dom == "": |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
39 file_name_mapping_dom = {} |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
40 else: |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
41 if isinstance(file_name_mapping_dom, str): |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
42 file_name_mapping_dom = dict( |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
43 item.split(":") for item in file_name_mapping_dom.split(",") |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
44 ) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
45 dom_real_names = { |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
46 os.path.splitext(os.path.basename(k))[0]: v.replace(".gb", "") |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
47 for k, v in file_name_mapping_dom.items() |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
48 } |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
49 real_names.update(dom_real_names) |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
50 |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
51 # update the records |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
52 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
53 for key, record in list(repository.collections["parts"].items()): |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
54 current_id = record.id |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
55 if current_id in real_names: |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
56 new_id = real_names[current_id] |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
57 record.id = new_id |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
58 record.name = new_id |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
59 record.description = new_id |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
60 repository.collections["parts"][new_id] = repository.collections["parts"].pop(key) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
61 ######################################################## |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
62 # print (f"repo: {vars(repository)}") |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
63 # any(pandas.read_csv(csv_file, index_col=0, header=None).duplicated()) |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
64 df = pandas.read_csv(csv_file, index_col=0, header=None) |
8
07e902da89ad
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
3
diff
changeset
|
65 if df.duplicated().any(): |
07e902da89ad
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
3
diff
changeset
|
66 raise ValueError("Duplicate rows found in the data!") |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
67 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
68 if assembly_type == "Type2sRestrictionAssembly": |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
69 assembly_class = dnacauldron.Type2sRestrictionAssembly |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
70 elif assembly_type == "GibsonAssembly": |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
71 assembly_class = dnacauldron.GibsonAssembly |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
72 elif assembly_type == "BASICAssembly": |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
73 assembly_class = dnacauldron.BASICAssembly |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
74 elif assembly_type == "BioBrickStandardAssembly": |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
75 assembly_class = dnacauldron.BioBrickStandardAssembly |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
76 elif assembly_type == "OligoPairAnnealin": |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
77 assembly_class = dnacauldron.OligoPairAnnealin |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
78 elif assembly_type == "LigaseCyclingReactionAssembly": |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
79 assembly_class = dnacauldron.LigaseCyclingReactionAssembly |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
80 else: |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
81 raise ValueError(f"Unsupported assembly type: {assembly_type}") |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
82 |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
83 new_csvname = "assambly.csv" |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
84 os.rename(csv_file, new_csvname) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
85 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
86 assembly_plan = dnacauldron.AssemblyPlan.from_spreadsheet( |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
87 name="auto_from_filename", |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
88 path=new_csvname, |
9
eaff3028ba07
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
8
diff
changeset
|
89 dataframe=None, |
12
556649b3f9bb
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
11
diff
changeset
|
90 header=None, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
91 assembly_class=assembly_class |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
92 ) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
93 if enzyme != 'auto': |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
94 for assembly in assembly_plan.assemblies: |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
95 assembly.enzyme = enzyme |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
96 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
97 simulation = assembly_plan.simulate(sequence_repository=repository) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
98 stats = simulation.compute_stats() |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
99 print(stats) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
100 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
101 report_writer = dnacauldron.AssemblyReportWriter( |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
102 include_mix_graphs=True, |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
103 include_assembly_plots=True, |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
104 show_overhangs_in_graph=True, |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
105 annotate_parts_homologies=True, |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
106 include_pdf_report=True, |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
107 ) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
108 simulation.write_report(outdir_simulation, assembly_report_writer=report_writer) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
109 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
110 # Append report files to .dat (ZIP) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
111 with zipfile.ZipFile(output_simulation, mode='a', compression=zipfile.ZIP_DEFLATED) as zipf: |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
112 for root, dirs, files in os.walk(outdir_simulation): |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
113 for file in files: |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
114 full_path = os.path.join(root, file) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
115 arcname = os.path.relpath(full_path, outdir_simulation) |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
116 zipf.write(full_path, arcname) |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
117 # print("Files in the zip archive:") |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
118 # for info in zipf.infolist(): |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
119 # print(info.filename) |
2
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
120 for member in zipf.namelist(): |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
121 # Only extract actual files inside 'all_construct_records/' (not subfolders) |
3
044d36066cb3
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
2
diff
changeset
|
122 if member.startswith("assambly_simulation/all_construct_records/") and not member.endswith("/"): |
2
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
123 # Get the file name only (strip folder path) |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
124 filename = os.path.basename(member) |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
125 if not filename: |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
126 continue # skip any edge cases |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
127 |
2
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
128 # Destination path directly in outdir_dir |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
129 target_path = os.path.join(outdir_gb, filename) |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
130 |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
131 # Write the file content |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
132 with zipf.open(member) as source, open(target_path, "wb") as target: |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
133 target.write(source.read()) |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
134 |
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
135 return output_simulation, outdir_gb |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
136 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
137 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
138 def parse_command_line_args(): |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
139 parser = argparse.ArgumentParser(description="Domestication") |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
140 |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
141 parser.add_argument("--parts_files", required=True, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
142 help="List of GenBank files (Comma-separated)") |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
143 parser.add_argument("--domesticated_seq", required=True, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
144 help="output of domestication (ganbank list)") |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
145 parser.add_argument("--assembly_csv", required=True, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
146 help="csv assembly") |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
147 parser.add_argument('--assembly_plan_name', type=str, required=False, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
148 help='type of assembly') |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
149 parser.add_argument('--topology', type=str, required=False, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
150 help='"circular" or "linear"') |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
151 parser.add_argument('--file_name_mapping', type=str, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
152 help='Mapping of Galaxy filenames to original filenames') |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
153 parser.add_argument('--file_name_mapping_dom', type=str, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
154 help='Mapping of Galaxy filenames to original domestication filenames') |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
155 parser.add_argument("--use_file_names_as_id", type=lambda x: x.lower() == 'true', default=True, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
156 help="Use file names as IDs (True/False)") |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
157 parser.add_argument("--outdir_simulation", required=True, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
158 help="dir output for cloning simulation results") |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
159 parser.add_argument("--output_simulation", required=True, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
160 help="zip output for cloning simulation results") |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
161 parser.add_argument('--enzyme', type=str,required=False, |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
162 help='enzyme to use') |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
163 parser.add_argument("--outdir_gb", required=True, |
2
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
164 help="dir output constructs gb files") |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
165 parser.add_argument("--use_json_paramers", required=True, |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
166 help="Use parameters from JSON: true/false") |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
167 parser.add_argument("--json_conf", required=False, |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
168 help="JSON config file with DB parameters") |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
169 |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
170 return parser.parse_args() |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
171 |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
172 |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
173 if __name__ == "__main__": |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
174 args = parse_command_line_args() |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
175 |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
176 #json param checking |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
177 config_params = {} |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
178 use_json = args.use_json_paramers == 'true' |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
179 if use_json: |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
180 if not args.json_conf: |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
181 raise ValueError("You must provide --json_conf when --use_json_paramers is 'true'") |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
182 with open(args.json_conf, "r") as f: |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
183 config_params = json.load(f) |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
184 else: |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
185 config_params = { |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
186 "assembly_plan_name": args.assembly_plan_name, |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
187 "topology": args.topology, |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
188 "enzyme": args.enzyme |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
189 } |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
190 assembly_plan_name = config_params["assembly_plan_name"] |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
191 topology = config_params["topology"] |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
192 enzyme = config_params["enzyme"] |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
193 |
0
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
194 cloning_simulation( |
dc450979fcd4
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
195 args.parts_files, args.domesticated_seq, |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
196 args.assembly_csv, assembly_plan_name, topology, |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
197 args.file_name_mapping, args.file_name_mapping_dom, |
2
3171db614963
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
198 args.use_file_names_as_id, args.outdir_simulation, |
16
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
199 args.output_simulation, enzyme, args.outdir_gb |
fbb241adf6c2
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/DnaCauldron/tree/master commit af45e5e0e81535ab0423b0bcff8b5b220bb9b4d0-dirty
tduigou
parents:
14
diff
changeset
|
200 ) |