Skip to content

Commit

Permalink
added option to override file extension requirement for reading fasta
Browse files Browse the repository at this point in the history
  • Loading branch information
sodiumnitrate committed Oct 18, 2024
1 parent 4b9cb49 commit 360ea7f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/sequence_analysis/seq_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SeqSet(SeqSet_cpp):
"""This class holds a list of sequence objects of a given type."""
def __init__(self, file_name=None, list_of_seqs=None):
def __init__(self, file_name=None, list_of_seqs=None, force_suffix=True):
"""
Overload the constructor so that you can set file name in one go.
Expand All @@ -23,6 +23,8 @@ def __init__(self, file_name=None, list_of_seqs=None):
raise ValueError
if Path(file_name).suffix in [".fasta", ".fna", ".fa", ".ffn", ".frn", ".fst"]:
self.read_fasta(file_name)
elif not force_suffix:
self.read_fasta(file_name)
else:
print(f"ERROR: file with suffix {Path(file_name).suffix} not supported.")
raise ValueError
Expand Down Expand Up @@ -62,4 +64,4 @@ def get_sequence_with_name(self, name):
sset = self.find_subset_with_names([name])
if len(sset) == 0:
return None
return sset.records[0]
return sset.records[0]

0 comments on commit 360ea7f

Please sign in to comment.