Mercurial > repos > tduigou > domestication
diff domestication.py @ 4:f78651af72e4 draft
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/Examples/blob/master/templates/template1.ipynb commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
| author | tduigou |
|---|---|
| date | Mon, 19 May 2025 13:01:50 +0000 |
| parents | 8fd9af4cb080 |
| children |
line wrap: on
line diff
--- a/domestication.py Fri May 16 09:30:35 2025 +0000 +++ b/domestication.py Mon May 19 13:01:50 2025 +0000 @@ -12,7 +12,7 @@ from Bio import SeqIO def domestication(files_to_domestication, csv_file,file_name_mapping, use_file_names_as_id, - allow_edits, output_dom): + allow_edits, output_dom, gb_dom): file_to_domestication = files_to_domestication.split(',') @@ -71,6 +71,26 @@ shutil.make_archive(output_dom, 'zip', output_dom) shutil.move(zip_path, output_dom) + temp_extract_dir = 'temp_extracted' + os.makedirs(temp_extract_dir, exist_ok=True) + + with zipfile.ZipFile(output_dom, 'r') as zip_ref: + zip_ref.extractall(temp_extract_dir) + + # Navigate into domesticated_genbanks and copy .gb files + dom_gb_dir = os.path.join(temp_extract_dir, 'domesticated_genbanks') + if os.path.isdir(dom_gb_dir): + for file in os.listdir(dom_gb_dir): + if file.endswith('.gb'): + shutil.copy(os.path.join(dom_gb_dir, file), gb_dom) + #print(f"Copied: {file}") + else: + print("Folder 'domesticated_genbanks' not found inside zip.") + + # Optional: clean up + shutil.rmtree(temp_extract_dir) + + return output_dom def methylation_protection(domestication_target, output_methprot): @@ -113,8 +133,10 @@ help="Allow sequence edits") parser.add_argument("--output_dom", required=True, help="zip output for domestication results") - parser.add_argument("--output_methprot", required=False, + parser.add_argument("--output_methprot", required=True, help="gb output for methylation protection") + parser.add_argument("--output_gb_dom", required=True, + help="gb output for mdomesticated gb files") parser.add_argument("--methylation_protection", type=lambda x: x.lower() == 'true', default=False, help="Enable methyl protection (true/false)") @@ -126,7 +148,7 @@ domestication( args.files_to_domestication, args.csv_file, args.file_name_mapping, args.use_file_names_as_id, - args.allow_edits, args.output_dom + args.allow_edits, args.output_dom, args.output_gb_dom ) if args.methylation_protection:
