Skip to content

Commit

Permalink
bug fixing assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliesCodes committed Jan 31, 2022
1 parent 10a2167 commit bce8375
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
12 changes: 8 additions & 4 deletions algorithms/de_novo_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create_seqparts():
and wraps them into one big, sorted list
Returns:
[list]: len decreasing sorted list of substrings with random parts from origin
[list]: len decreasing sorted list of substrings with random parts from origin
"""
seqparts = []
for _ in range(SUBSEQ_NUM):
Expand Down Expand Up @@ -90,17 +90,21 @@ def mapping(seqparts):
print("Startsequence:", main_seq)
while seqparts and len(main_seq) <= ASSEMBLY_MAXLEN:
fragments = []
for seq2 in seqparts:
for parts_index, seq2 in enumerate(seqparts):
# use imported smith-waterman algorithm without output function
sim_tup, main_seq_new = fsa.main(main_seq, seq2, True)
if 0.9*len(seq2) >= sim_tup[0] > 0.2*len(seq2):
fragments.append((sim_tup[0], main_seq_new))
fragments.append((sim_tup[0], main_seq_new, parts_index))
if fragments:
sorted_frags = sorted(
fragments, key=lambda tup: tup[0], reverse=True)
main_seq = sorted_frags[0][1]
main_seq = "," + main_seq
seqparts.pop(0)
try:
del seqparts[sorted_frags[0][2]]
except:
print("An exception occurred! No fitting part found")

return main_seq


Expand Down
16 changes: 10 additions & 6 deletions algorithms/mapping_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,28 @@ def mapping(seqparts, origin_len):
main_seq = seqparts.pop(0)
while seqparts and len(main_seq) <= origin_len:
fragments = []
for seq2 in seqparts:
for parts_index, seq2 in enumerate(seqparts):
# use imported smith-waterman algorithm without output function
sim_tup, main_seq_new = fsa.main(main_seq, seq2, True)
if 0.9*len(seq2) >= sim_tup[0] > 0.2*len(seq2):
fragments.append((sim_tup[0], main_seq_new))
fragments.append((sim_tup[0], main_seq_new, parts_index))
if fragments:
sorted_frags = sorted(fragments, key=lambda tup: tup[0], reverse=True)
sorted_frags = sorted(
fragments, key=lambda tup: tup[0], reverse=True)
main_seq = sorted_frags[0][1]
main_seq = "," + main_seq
seqparts.pop(0)
try:
del seqparts[sorted_frags[0][2]]
except:
print("An exception occurred! No fitting part found")
return main_seq


def main():
origin, origin_len = generate_origin()
minl = round(0.10*origin_len)
minl = round(0.05*origin_len)
maxl = round(0.20*origin_len)
set_num = 20
set_num = 10
seqparts = cut_origin_to_seqparts(origin, minl, maxl, set_num)
seqparts = get_unique_seqparts(seqparts)
assembly_sequence = mapping(seqparts, origin_len)
Expand Down
1 change: 1 addition & 0 deletions algorithms/needleman_wunsch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# =============================================================================
"""
Needleman-Wunsch Algorithm
Global Alignment Algorithm
This module uses dynamic programming to find the optimal
Expand Down
1 change: 1 addition & 0 deletions algorithms/smith_waterman.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# =============================================================================
"""
Smith-Waterman Algorithm
Local Alignment Algorithm
This module uses dynamic programming to find the optimal
Expand Down

0 comments on commit bce8375

Please sign in to comment.