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

Commit

Permalink
update to refget2, seq prefix, remove refget extension
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Sep 14, 2023
1 parent 7974c01 commit 2d335c3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
28 changes: 24 additions & 4 deletions seqcol/seqcol.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import henge
import logging
import refget
import yacman

from itertools import compress

Expand All @@ -12,14 +12,34 @@
henge.ITEM_TYPE = "_item_type"


class SeqColHenge(refget.RefGetClient):
class SeqColConf(yacman.YAMLConfigManager):
"""
Simple configuration manager object for SeqColHenge.
"""
def __init__(
self,
entries={},
filepath=None,
yamldata=None,
writable=False,
wait_max=60,
skip_read_lock=False,
):
filepath = yacman.select_config(
config_filepath=filepath,
config_env_vars=["SEQCOLAPI_CONFIG"],
config_name="seqcol"
)
super(SeqColConf, self).__init__(entries, filepath, yamldata, writable)


class SeqColHenge(henge.Henge):
"""
Extension of henge that accommodates collections of sequences.
"""

def __init__(
self,
api_url_base=None,
database={},
schemas=None,
henges=None,
Expand All @@ -38,7 +58,6 @@ def __init__(
serialized items stored in this henge.
"""
super(SeqColHenge, self).__init__(
api_url_base=api_url_base,
database=database,
schemas=schemas or INTERNAL_SCHEMAS,
henges=henges,
Expand Down Expand Up @@ -123,6 +142,7 @@ def retrieve(self, druid, reclimit=None, raw=False):
return super(SeqColHenge, self).retrieve(druid, reclimit, raw)
except henge.NotFoundException as e:
_LOGGER.debug(e)
raise e
try:
return self.refget(druid)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion seqcol/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def fasta_obj_to_seqcol(
seq = str(fa_object[k])
seq_length = len(seq)
seq_name = fa_object[k].name
seq_digest = digest_function(seq.upper())
seq_digest = "SQ."+digest_function(seq.upper())
snlp = {"length": seq_length, "name": seq_name} # sorted_name_length_pairs
snlp_digest = digest_function(canonical_str(snlp))
CSC["lengths"].append(seq_length)
Expand Down

0 comments on commit 2d335c3

Please sign in to comment.