Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev' of github.com:refgenie/seqcol into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Sep 11, 2023
2 parents 8acce14 + 70e51ce commit 8172d5d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion seqcol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@


__classes__ = ["SeqColClient"]
__all__ = (__classes__ + ["build_sorted_name_length_pairs", "compare", "validate_seqcol"],)
__all__ = (__classes__ + ["build_sorted_name_length_pairs", "compare", "validate_seqcol", "fasta_to_digest"],)
5 changes: 5 additions & 0 deletions seqcol/seqcol.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def explain_flag(flag):
if flag & 2**e:
print(FLAGS[2**e])

def fasta_to_digest(fa_file_path: str) -> str:
"""Given a fasta, return a digest"""
seqcol_obj = fasta_to_seqcol(fa_file_path)
return seqcol_digest(seqcol_obj)


def parse_fasta(fa_file) -> pyfaidx.Fasta:
"""
Expand Down
2 changes: 1 addition & 1 deletion seqcol/seqcol_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def compare_digests(self, digestA, digestB):
B = self.retrieve(digestB, reclimit=1)
# _LOGGER.info(A)
# _LOGGER.info(B)
return compare(A, B)
return compare_seqcols(A, B)

def retrieve(self, druid, reclimit=None, raw=False):
try:
Expand Down
14 changes: 14 additions & 0 deletions seqcol/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ def validate_seqcol(seqcol_obj: SeqCol, schema=None) -> Optional[dict]:
errors = sorted(validator.iter_errors(seqcol_obj), key=lambda e: e.path)
raise InvalidSeqColError("Validation failed", errors)
return True

def format_itemwise(csc: SeqCol) -> list:
"""
Format a SeqCol object into a list of dicts, one per sequence.
"""
list_of_dicts = []
for i in range(len(csc["lengths"])):
list_of_dicts.append(
{
"name": csc["names"][i],
"length": csc["lengths"][i],
"sequence": csc["sequences"][i],
})
return list_of_dicts

0 comments on commit 8172d5d

Please sign in to comment.