Skip to content

Commit

Permalink
remove reading_frames_single_stranded function
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Jun 24, 2023
1 parent a90ce82 commit 23ddbab
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions intact/intact.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,78 +474,6 @@ def has_rev_response_element(alignment, rre_locus, rre_tolerance):
return None
#/end def has_rev_response_element

def reading_frames_single_stranded(alignment, sequence, length):
"""
Find all reading frames longer than length in the forward strand
of the given sequence.
Args:
sequence: the sequence to check.
length: the minimum nucleotide length of a reading frame
Returns:
A list of tuples of (frame_start, frame_end, frame_deletions, frame_insertions)
"""

# figure out where the query starts w.r.t HXB2 in case full
# genome consensus is not being used
# offset = re.search(r'[^-]', str(alignment[1].seq)).start()

# for each position in the query, figure out how many inserts and
# deletes we've seen with respect to the reference
delete_offset = []
insert_offset = []
delete_count = 0
insert_count = 0

for i in range(len(alignment[0])):
if alignment[1][i] == "-":
delete_count += 1
continue
if alignment[0][i] == "-":
insert_count += 1
delete_offset.append(delete_count)
insert_offset.append(insert_count)

long_frames = []

for frame in range(0, 3):

for_translation = sequence.seq[frame:]
current_length = len(for_translation)
for _ in range(3 - current_length % 3):
for_translation += 'N'

protein = Seq.translate(for_translation)

current_start = 0
current_len = 0


for i, elem in enumerate(protein):
if elem == "*":
fs = current_start * 3 + 0 + frame
frame_start = fs + delete_offset[fs] - insert_offset[fs]
fe = i * 3 + 1 + frame
frame_end = fe + delete_offset[fe] - insert_offset[fe]

if current_len * 3 >= length:
long_frames.append(
ReceivedORF(frame_start,
frame_end + 1,
delete_offset[fe] - delete_offset[fs],
insert_offset[fe] - insert_offset[fs])
)
current_len = 0
continue
elif current_len == 0:
current_start = i

current_len += 1

long_frames.sort(key=lambda x: x.start)

return long_frames

def alignment_score(alignment):
"""
Expand Down

0 comments on commit 23ddbab

Please sign in to comment.