Skip to content

Commit

Permalink
no cloning needed
Browse files Browse the repository at this point in the history
  • Loading branch information
rvosa committed Aug 19, 2024
1 parent 1fbccba commit d6273e7
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions barcode_validator/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,22 @@ def align_to_hmm(sequence):


def marker_seqlength(sequence):
"""
Calculate the length of the sequence within the marker region,
excluding gaps and ambiguous bases.
:param sequence: A BioPython SeqRecord object
:return: The length of the sequence within the marker region
"""
logging.info("Calculating non-missing bases within marker region")

# Clone the sequence, remove gaps and missing in the sequence
cloned_seq = deepcopy(sequence)
cloned_seq.letter_annotations = {}
cloned_seq.seq = cloned_seq.seq.replace('-', '')
cloned_seq.seq = cloned_seq.seq.replace('N', '')
cloned_seq.seq = cloned_seq.seq.replace('n', '')
logging.debug(f"Within marker sequence length: {len(cloned_seq)}")
return len(cloned_seq)
# Operate on the cloned sequence string directly
raw_seq = str(sequence.seq)
raw_seq = raw_seq.replace('-', '')
raw_seq = raw_seq.replace('N', '')
raw_seq = raw_seq.replace('n', '')

logging.debug(f"Within marker sequence length: {len(raw_seq)}")
return len(raw_seq)


def num_ambiguous(sequence):
Expand Down

0 comments on commit d6273e7

Please sign in to comment.