Mentions légales du service

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

refactors, name result file by primers

parent 4ba034e1
Branches
No related tags found
No related merge requests found
...@@ -68,7 +68,7 @@ def assemble_blocks_simulation(eBlocks_list: list, nbr_mol: int) -> dict: ...@@ -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 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 = {} assembly_dict = {}
...@@ -90,8 +90,8 @@ def assemble_blocks_simulation(eBlocks_list: list, nbr_mol: int) -> 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 current_assembly += block[overhang_size:] # link the block to the current assembly
else: else:
assembly_dict["molecule_"+str(mol_index)] = current_assembly # the current assembly is not linked to the block, so its is completed 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 mol_index += 1
current_assembly = block[overhang_size:] # begin a new assembly starting from this block
# add the assembly to the dict # add the assembly to the dict
assembly_dict["molecule_"+str(mol_index)] = current_assembly assembly_dict["molecule_"+str(mol_index)] = current_assembly
...@@ -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_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 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
...@@ -145,16 +145,23 @@ def eBlocks_assembly(input_path: str, output_path: str, nbr_mol: int) -> None: ...@@ -145,16 +145,23 @@ def eBlocks_assembly(input_path: str, output_path: str, nbr_mol: int) -> None:
exit(1) exit(1)
blocks_list = list(eBlocks_dict.values()) blocks_list = list(eBlocks_dict.values())
# simulate removal of buffers # simulate removal of buffers
blocks_list = remove_buffer(blocks_list) blocks_list = remove_buffer(blocks_list)
# 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
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 # 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_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): ...@@ -165,8 +172,7 @@ def container_assembly(input_dir_path, output_dir_path, nbr_mol):
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"
output_file = os.path.join(output_dir_path, filename+".fasta") eBlocks_assembly(input_file, output_dir_path, nbr_mol)
eBlocks_assembly(input_file, output_file, nbr_mol)
# =================== main =======================# # =================== main =======================#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment