INNER CODE UNIT · Python
_infer_skbio_type
TimoLassmann/kalign · python-kalign/__init__.py:167
def _infer_skbio_type(sequences, skbio_seq):
"""Infer the appropriate skbio sequence class from raw sequence content."""
chars = set()
for seq in sequences:
chars.update(seq.upper().replace("-", "").replace(".", ""))
dna_chars = set("ACGTNRYSWKMBDHV")
rna_chars = set("ACGUNRYSWKMBDHV")
if "U" in chars and "T" not in chars and chars <= rna_chars:
return skbio_seq.RNA
if chars <= dna_chars:
return skbio_seq.DNA
return skbio_seq.Protein
def _validate_sequences(sequences):
"""Validate input sequences, raising on empty/invalid input."""
if not sequences:
raise ValueError("No sequences were found in the input")