diff --git a/eBlock_assembly_simulation.py b/eBlock_assembly_simulation.py index 60eae71e1cdd4f5dcc1d111051efaef241986dcf..0bd6a9645a381cb4d441d00568d8ad639c2c9c15 100755 --- a/eBlock_assembly_simulation.py +++ b/eBlock_assembly_simulation.py @@ -68,7 +68,7 @@ def assemble_blocks_simulation(eBlocks_list: list, nbr_mol: int) -> dict: """ use the statistics of overhangs assemblies to simulation the assembly of blocks """ - overhang_assembly_stats_dict = dfr.read_fasta("file_test_assembly/overhangs_stats.txt") + overhang_assembly_stats_dict = dfr.read_fasta(os.path.abspath(os.path.dirname(__file__))+"/overhangs_eBlocks_probas.fasta") assembly_dict = {} @@ -90,8 +90,8 @@ def assemble_blocks_simulation(eBlocks_list: list, nbr_mol: int) -> dict: current_assembly += block[overhang_size:] # link the block to the current assembly else: assembly_dict["molecule_"+str(mol_index)] = current_assembly # the current assembly is not linked to the block, so its is completed - current_assembly = block[overhang_size:] # begin a new assembly starting from this block mol_index += 1 + current_assembly = block[overhang_size:] # begin a new assembly starting from this block # add the assembly to the dict assembly_dict["molecule_"+str(mol_index)] = current_assembly @@ -132,7 +132,7 @@ def test_assembly(input_path, output_path: str, nbr_mol: int) -> None: -def eBlocks_assembly(input_path: str, output_path: str, nbr_mol: int) -> None: +def eBlocks_assembly(input_path: str, output_dir_path: str, nbr_mol: int) -> None: """ simulate an ordered assembly of eBlocks surrounded by the primers the resulting molecules are saved to a .fasta file to simulate the storing @@ -145,16 +145,23 @@ def eBlocks_assembly(input_path: str, output_path: str, nbr_mol: int) -> None: exit(1) blocks_list = list(eBlocks_dict.values()) - + # simulate removal of buffers blocks_list = remove_buffer(blocks_list) # simulate bsaI digestion blocks_list = digest_bsaI(blocks_list) + + 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 + + # 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+".fasta") + # simulation assembly by overhangs, fatal error if overhangs are not compatibles for successive blocks #assembly_dict = assemble_blocks(blocks_list) assembly_dict = assemble_blocks_simulation(blocks_list, nbr_mol) # save the assemblies into file - dfr.save_dict_to_fasta(assembly_dict, output_path) + dfr.save_dict_to_fasta(assembly_dict, output_file_path) @@ -165,8 +172,7 @@ def container_assembly(input_dir_path, output_dir_path, nbr_mol): if os.path.isdir(file_path): input_file = file_path+"/5_blocks_buffer.fasta" - output_file = os.path.join(output_dir_path, filename+".fasta") - eBlocks_assembly(input_file, output_file, nbr_mol) + eBlocks_assembly(input_file, output_dir_path, nbr_mol) # =================== main =======================#