Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 64218c17 authored by BOULLE Olivier's avatar BOULLE Olivier
Browse files

save simulations to fasta format, add a number to the output filenames for...

save simulations to fasta format, add a number to the output filenames for assembly with same primers couples
parent 32da1a0f
No related branches found
No related tags found
No related merge requests found
...@@ -132,7 +132,7 @@ def test_assembly(input_path, output_path: str, nbr_mol: int) -> None: ...@@ -132,7 +132,7 @@ def test_assembly(input_path, output_path: str, nbr_mol: int) -> None:
def eBlocks_assembly(input_path: str, output_dir_path: str, nbr_mol: int) -> None: def eBlocks_assembly(input_path: str, output_dir_path: str, nbr_mol: int, assembly_number: int) -> None:
""" """
simulate an ordered assembly of eBlocks surrounded by the primers simulate an ordered assembly of eBlocks surrounded by the primers
the resulting molecules are saved to a .fasta file to simulate the storing the resulting molecules are saved to a .fasta file to simulate the storing
...@@ -151,28 +151,30 @@ def eBlocks_assembly(input_path: str, output_dir_path: str, nbr_mol: int) -> Non ...@@ -151,28 +151,30 @@ def eBlocks_assembly(input_path: str, output_dir_path: str, nbr_mol: int) -> Non
# simulate bsaI digestion # simulate bsaI digestion
blocks_list = digest_bsaI(blocks_list) blocks_list = digest_bsaI(blocks_list)
start_primer = blocks_list[0][overhang_size:overhang_size+primer_size] # get the start primer start_primer = blocks_list[0][overhang_size: overhang_size + primer_size] # get the start primer
stop_primer = dfr.reverse_complement(blocks_list[-1][-overhang_size-primer_size:-overhang_size]) # the stop primer stop_primer = dfr.reverse_complement(blocks_list[-1][- overhang_size - primer_size: -overhang_size]) # the stop primer
# name of the output file contains the 2 primers because the sequencing file is obtained from these primers # name of the output file contains the 2 primers because the sequencing file is obtained from these primers
output_file_path = os.path.join(output_dir_path, start_primer+"_"+stop_primer+".fastq") output_file_path = os.path.join(output_dir_path, start_primer+"_"+stop_primer+"_"+str(assembly_number)+".fasta")
# simulation assembly by overhangs, fatal error if overhangs are not compatibles for successive blocks # simulation assembly by overhangs, fatal error if overhangs are not compatibles for successive blocks
#assembly_dict = assemble_blocks(blocks_list) #assembly_dict = assemble_blocks(blocks_list)
assembly_dict = assemble_blocks_simulation(blocks_list, nbr_mol) assembly_dict = assemble_blocks_simulation(blocks_list, nbr_mol)
# save the assemblies into file # save the assemblies into file
dfr.save_dict_to_fastq(assembly_dict, output_file_path) dfr.save_dict_to_fasta(assembly_dict, output_file_path)
def container_assembly(input_dir_path, output_dir_path, nbr_mol): def container_assembly(input_dir_path, output_dir_path, nbr_mol):
assembly_number = 1 # number to add to the assembly name to distinguish assemblies with the same primers couple
for filename in os.listdir(input_dir_path): for filename in os.listdir(input_dir_path):
file_path = os.path.join(input_dir_path, filename) file_path = os.path.join(input_dir_path, filename)
if os.path.isdir(file_path): if os.path.isdir(file_path):
input_file = file_path+"/5_blocks_buffer.fasta" input_file = file_path+"/5_blocks_buffer.fasta"
eBlocks_assembly(input_file, output_dir_path, nbr_mol) eBlocks_assembly(input_file, output_dir_path, nbr_mol, assembly_number)
assembly_number += 1
# =================== main =======================# # =================== main =======================#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment