From 7911f44b67defede836ab34e2c6385ec90a64f7c Mon Sep 17 00:00:00 2001 From: nroehner Date: Thu, 21 Oct 2021 21:13:53 -0400 Subject: [PATCH] Updated to version 1.5.2 with additional download of sequences when downloading components from SynBioHub. --- features_to_circuits/__init__.py | 2 +- sequences_to_features/__init__.py | 2 +- .../sequences_to_features.py | 30 ++++++++++++++++++- setup.py | 4 +-- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/features_to_circuits/__init__.py b/features_to_circuits/__init__.py index 61f3d48..4bec5b3 100644 --- a/features_to_circuits/__init__.py +++ b/features_to_circuits/__init__.py @@ -1,4 +1,4 @@ # See https://www.python.org/dev/peps/pep-0440/ for info on version numbering -__version__ = '1.5.1' +__version__ = '1.5.2' from features_to_circuits.features_to_circuits import * \ No newline at end of file diff --git a/sequences_to_features/__init__.py b/sequences_to_features/__init__.py index 655c207..e49b2df 100644 --- a/sequences_to_features/__init__.py +++ b/sequences_to_features/__init__.py @@ -1,4 +1,4 @@ # See https://www.python.org/dev/peps/pep-0440/ for info on version numbering -__version__ = '1.5.1' +__version__ = '1.5.2' from sequences_to_features.sequences_to_features import * \ No newline at end of file diff --git a/sequences_to_features/sequences_to_features.py b/sequences_to_features/sequences_to_features.py index 3282334..03bba56 100644 --- a/sequences_to_features/sequences_to_features.py +++ b/sequences_to_features/sequences_to_features.py @@ -198,8 +198,8 @@ class FeatureLibrary(): def __init__(self, docs, require_sequence=True): self.features = [] self.docs = docs - self.__updated_indices = set() + self.__updated_indices = set() self.__feature_map = {} self.__feature_dict = {} self.__name_to_idents = {} @@ -1513,6 +1513,28 @@ def curate(feature_library, target_library, output_library, output_files, extend target_library.docs[i].write(output_files[i]) +def download_sequences(doc, synbiohub): + for comp_definition in doc.componentDefinitions: + for seq_URI in comp_definition.sequences: + download_sequence = False + + try: + doc.getSequence(seq_URI) + except RuntimeError: + download_sequence = True + except NotFoundError as exc: + if is_sbol_not_found(exc): + download_sequence = True + + if download_sequence: + try: + synbiohub.pull(seq_URI, doc) + except NotFoundError as exc: + if is_sbol_not_found(exc): + logger.warning('Unable to download sequence %s, seq_URI)') + else: + raise + def main(args=None): if args is None: args = sys.argv[1:] @@ -1666,6 +1688,8 @@ def main(args=None): try: synbiohub.pull(feature_URL, feature_doc) + download_sequences(feature_doc, synbiohub) + feature_docs.append(feature_doc) except NotFoundError as exc: if is_sbol_not_found(exc): @@ -1688,6 +1712,8 @@ def main(args=None): try: synbiohub.pull(target_URL, target_doc) + download_sequences(target_doc, synbiohub) + target_docs.append(target_doc) except NotFoundError as exc: target_docs.append(None) @@ -1741,6 +1767,8 @@ def main(args=None): target_doc = sbol2.Document() synbiohub.pull(target_URL, target_doc) + + download_sequences(target_doc, synbiohub) except NotFoundError as exc: if is_sbol_not_found(exc): logger.warning('Unable to find target URL %s at %s', target_URL, sbh_URL) diff --git a/setup.py b/setup.py index abcab1e..5bb9596 100644 --- a/setup.py +++ b/setup.py @@ -12,13 +12,13 @@ setup( name='SYNBICT', - version='1.5.1', + version='1.5.2', description='Synthetic Biology Curation Tools (SYNBICT)', long_description='Synthetic Biology Curation Tools (SYNBICT) is a Python tool suite for automation-assisted annotation, curation, and functional inference for genetic designs.', author='Nicholas Roehner', author_email='nicholasroehner@gmail.com', url='https://github.com/SD2E/SYNBICT', - download_url='https://github.com/SD2E/SYNBICT/archive/refs/tags/v1.4.tar.gz', + download_url='https://github.com/SD2E/SYNBICT/archive/refs/tags/v1.5.2.tar.gz', packages=find_packages(), install_requires=install_requires, classifiers=[