Mercurial > repos > tduigou > create_assembly_picklists
comparison CreateAssemblyPicklists_script.py @ 1:196e13c09881 draft
planemo upload for repository https://github.com/Edinburgh-Genome-Foundry/Plateo commit fe52aec22c97cd357d1b6c40c2954d27ebad87d3-dirty
| author | tduigou |
|---|---|
| date | Wed, 06 Aug 2025 14:38:40 +0000 |
| parents | 4bde3e90ee98 |
| children |
comparison
equal
deleted
inserted
replaced
| 0:4bde3e90ee98 | 1:196e13c09881 |
|---|---|
| 55 new_path = path.replace("__sq__", "'") | 55 new_path = path.replace("__sq__", "'") |
| 56 if new_path != path: | 56 if new_path != path: |
| 57 os.rename(path, new_path) | 57 os.rename(path, new_path) |
| 58 fixed_paths.append(new_path) | 58 fixed_paths.append(new_path) |
| 59 return fixed_paths | 59 return fixed_paths |
| 60 | |
| 61 | |
| 62 def parse_optional_float(x): | |
| 63 if x == '': | |
| 64 return None | |
| 65 return float(x) | |
| 60 | 66 |
| 61 | 67 |
| 62 def did_you_mean(name, other_names, limit=5, min_score=50): # test | 68 def did_you_mean(name, other_names, limit=5, min_score=50): # test |
| 63 results = process.extract(name, list(other_names), limit=limit) | 69 results = process.extract(name, list(other_names), limit=limit) |
| 64 return [e for (e, score) in results if score >= min_score] | 70 return [e for (e, score) in results if score >= min_score] |
| 376 | 382 |
| 377 parser = argparse.ArgumentParser(description="Generate picklist for DNA assembly.") | 383 parser = argparse.ArgumentParser(description="Generate picklist for DNA assembly.") |
| 378 parser.add_argument("--parts_files", help="Directory with parts data or file with part sizes") | 384 parser.add_argument("--parts_files", help="Directory with parts data or file with part sizes") |
| 379 parser.add_argument("--picklist", type=str, help="Path to the assembly plan CSV or Excel file") | 385 parser.add_argument("--picklist", type=str, help="Path to the assembly plan CSV or Excel file") |
| 380 parser.add_argument("--source_plate", help="Source plate file (CSV or Excel)") | 386 parser.add_argument("--source_plate", help="Source plate file (CSV or Excel)") |
| 381 parser.add_argument("--backbone_name", help="Name of the backbone") | 387 parser.add_argument("--backbone_name", required=False, help="Name of the backbone") |
| 382 parser.add_argument("--result_zip", help="Name of the output zip file") | 388 parser.add_argument("--result_zip", help="Name of the output zip file") |
| 383 parser.add_argument("--part_backbone_ratio", type=float, help="Part to backbone molar ratio") | 389 parser.add_argument("--part_backbone_ratio", type=parse_optional_float, required=False, help="Part to backbone molar ratio") |
| 384 parser.add_argument("--quantity_unit", choices=["fmol", "nM", "ng"], help="Quantity unit") | 390 parser.add_argument("--quantity_unit", choices=["fmol", "nM", "ng"], help="Quantity unit") |
| 385 parser.add_argument("--part_quantity", type=float, help="Quantity of each part") | 391 parser.add_argument("--part_quantity", type=float, help="Quantity of each part") |
| 386 parser.add_argument("--buffer_volume", type=float, help="Buffer volume in µL") | 392 parser.add_argument("--buffer_volume", type=float, help="Buffer volume in µL") |
| 387 parser.add_argument("--total_volume", type=float, help="Total reaction volume in µL") | 393 parser.add_argument("--total_volume", type=float, help="Total reaction volume in µL") |
| 388 parser.add_argument("--dispenser", choices=["labcyte_echo", "tecan_evo"], help="Dispenser machine") | 394 parser.add_argument("--dispenser", choices=["labcyte_echo", "tecan_evo"], help="Dispenser machine") |
| 484 complement_to=total_volume * 1e-6, # convert uL to L | 490 complement_to=total_volume * 1e-6, # convert uL to L |
| 485 buffer_volume=buffer_volume * 1e-6, | 491 buffer_volume=buffer_volume * 1e-6, |
| 486 volume_rounding=2.5e-9, # not using parameter from form | 492 volume_rounding=2.5e-9, # not using parameter from form |
| 487 minimal_dispense_volume=5e-9, # Echo machine's minimum dispense - | 493 minimal_dispense_volume=5e-9, # Echo machine's minimum dispense - |
| 488 ) | 494 ) |
| 489 backbone_name_list = backbone_name.split(",") | 495 if backbone_name != '' and backbone_name != 'Non': |
| 496 backbone_name_list = backbone_name.split(",") | |
| 490 source_plate = plate_from_content_spreadsheet(source_plate_path) | 497 source_plate = plate_from_content_spreadsheet(source_plate_path) |
| 491 | 498 |
| 492 for well in source_plate.iter_wells(): | 499 for well in source_plate.iter_wells(): |
| 493 if well.is_empty: | 500 if well.is_empty: |
| 494 continue | 501 continue |
| 495 quantities = well.content.quantities | 502 quantities = well.content.quantities |
| 496 part, quantity = list(quantities.items())[0] | 503 part, quantity = list(quantities.items())[0] |
| 497 quantities.pop(part) | 504 quantities.pop(part) |
| 498 quantities[part.replace(" ", "_")] = quantity | 505 quantities[part.replace(" ", "_")] = quantity |
| 499 | 506 |
| 500 if part in backbone_name_list: | 507 if backbone_name != '' and backbone_name != 'Non': |
| 501 # This section multiplies the backbone concentration with the | 508 if part in backbone_name_list: |
| 502 # part:backbone molar ratio. This tricks the calculator into making | 509 # This section multiplies the backbone concentration with the |
| 503 # a picklist with the desired ratio. | 510 # part:backbone molar ratio. This tricks the calculator into making |
| 504 # For example, a part:backbone = 2:1 will multiply the | 511 # a picklist with the desired ratio. |
| 505 # backbone concentration by 2, therefore half as much of it will be | 512 # For example, a part:backbone = 2:1 will multiply the |
| 506 # added to the well. | 513 # backbone concentration by 2, therefore half as much of it will be |
| 507 quantities[part.replace(" ", "_")] = quantity * part_backbone_ratio | 514 # added to the well. |
| 508 else: | 515 quantities[part.replace(" ", "_")] = quantity * part_backbone_ratio |
| 509 quantities[part.replace(" ", "_")] = quantity | 516 else: |
| 517 quantities[part.replace(" ", "_")] = quantity | |
| 510 | 518 |
| 511 source_plate.name = "Source" | 519 source_plate.name = "Source" |
| 512 if destination_plate: | 520 if destination_plate: |
| 513 dest_filelike = file_to_filelike_object(destination_plate) | 521 dest_filelike = file_to_filelike_object(destination_plate) |
| 514 destination_plate = plate_from_content_spreadsheet(destination_plate) | 522 destination_plate = plate_from_content_spreadsheet(destination_plate) |
