Skip to content

Commit

Permalink
Added arguments to sequences_to_features for allowing annotation of o…
Browse files Browse the repository at this point in the history
…ne component with another component that is the same size and for specifying which properties should be removed when deriving a newly curated component from another (based on the prefixes/namespaces of these properties). Previously removed some SynBioHub properties by default. Currently onlys removes by default sbol:wasGeneratedBy and dcterms properties such as creator that are more relevant to the provenance of the target uncurated component.
  • Loading branch information
nroehner committed Oct 19, 2021
1 parent 34f5c1b commit 4daa7d9
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 96 deletions.
2 changes: 1 addition & 1 deletion features_to_circuits/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See https://www.python.org/dev/peps/pep-0440/ for info on version numbering
__version__ = '1.5'
__version__ = '1.5.1'

from features_to_circuits.features_to_circuits import *
50 changes: 27 additions & 23 deletions features_to_circuits/features_to_circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def get_activated_by_template(self, template):
else:
return set()

def extend_circuits_by_name(self, mismatch_threshold):
def extend_circuits_by_name(self, mismatch_threshold, strip_prefixes=[]):
self.logger.info('Extending circuit library')

aligner = Align.PairwiseAligner()
Expand Down Expand Up @@ -335,7 +335,8 @@ def extend_circuits_by_name(self, mismatch_threshold):
definition_copy = self.copy_module_definition(circuit_definition,
circuit_doc,
circuit_doc,
True)
True,
strip_prefixes=strip_prefixes)

feature_doc = self.__feature_library.get_document(feature_definition.identity)

Expand Down Expand Up @@ -475,25 +476,26 @@ def make_variant_circuit_definition(cls, circuit_doc, variant_doc, circuit_defin

product_fc.definition = variant_product_definition.identity

@classmethod
def strip_origin_properties(cls, sbol_obj):
origin_props = []
# @classmethod
# def strip_origin_properties(cls, sbol_obj):
# origin_props = []

for prop in sbol_obj.properties:
if (prop.startswith('http://wiki.synbiohub.org/wiki/Terms/synbiohub#')
or prop.startswith('http://purl.org/dc/terms/created')
or prop.startswith('http://purl.org/dc/terms/modified')
or prop.startswith('http://www.ncbi.nlm.nih.gov/genbank#')
or prop.startswith('http://sbols.org/genBankConversion#')):
origin_props.append(prop)
# for prop in sbol_obj.properties:
# if (prop.startswith('http://wiki.synbiohub.org/wiki/Terms/synbiohub#')
# or prop.startswith('http://purl.org/dc/terms/created')
# or prop.startswith('http://purl.org/dc/terms/modified')
# or prop.startswith('http://www.ncbi.nlm.nih.gov/genbank#')
# or prop.startswith('http://sbols.org/genBankConversion#')):
# origin_props.append(prop)

for origin_prop in origin_props:
del sbol_obj.properties[origin_prop]
# for origin_prop in origin_props:
# del sbol_obj.properties[origin_prop]

sbol_obj.wasGeneratedBy = []
# sbol_obj.wasGeneratedBy = []

@classmethod
def copy_module_definition(cls, mod_definition, source_doc, sink_doc, import_namespace=False, deep_copy=False):
def copy_module_definition(cls, mod_definition, source_doc, sink_doc, import_namespace=False, deep_copy=False,
strip_prefixes=[]):
if import_namespace:
mod_namespace = '/'.join(mod_definition.identity.split('/')[:-2])

Expand Down Expand Up @@ -528,22 +530,23 @@ def copy_module_definition(cls, mod_definition, source_doc, sink_doc, import_nam
else:
raise

cls.strip_origin_properties(mod_definition_copy)
FeatureLibrary.strip_origin_properties(mod_definition_copy, strip_prefixes)
for sub_mod_copy in mod_definition_copy.modules:
cls.strip_origin_properties(sub_mod_copy)
FeatureLibrary.strip_origin_properties(sub_mod_copy, strip_prefixes)
for func_comp_copy in mod_definition_copy.functionalComponents:
cls.strip_origin_properties(func_comp_copy)
FeatureLibrary.strip_origin_properties(func_comp_copy, strip_prefixes)
for intxn_copy in mod_definition_copy.interactions:
cls.strip_origin_properties(intxn_copy)
FeatureLibrary.strip_origin_properties(intxn_copy, strip_prefixes)

for parti_copy in intxn_copy.participations:
cls.strip_origin_properties(parti_copy)
FeatureLibrary.strip_origin_properties(parti_copy, strip_prefixes)

if deep_copy:
for sub_mod in mod_definition.modules:
sub_mod_definition = source_doc.moduleDefinitions.get(sub_mod.definition)

sub_mod_definition_copy = cls.copy_module_definition(sub_mod_definition, source_doc, sink_doc, import_namespace, deep_copy)
sub_mod_definition_copy = cls.copy_module_definition(sub_mod_definition, source_doc, sink_doc,
import_namespace, deep_copy, strip_prefixes)

sub_mod_copy = mod_definition_copy.modules.get(sub_mod.displayId)

Expand Down Expand Up @@ -1210,6 +1213,7 @@ def main(args=None):
parser.add_argument('-d', '--tx_threshold', nargs='?', default='200')
parser.add_argument('-f', '--flanking_length', nargs='?', default='200')
parser.add_argument('-iv', '--infer_devices', action='store_true')
parser.add_argument('-sp', '--strip_prefixes', nargs='*', default=[])

# Sub-circuit library extension arguments
parser.add_argument('-e', '--extend_sub_circuits', action='store_true')
Expand Down Expand Up @@ -1250,7 +1254,7 @@ def main(args=None):
if args.extend_sub_circuits:
circuit_library = CircuitLibrary(circuit_docs, True)

circuit_library.extend_circuits_by_name(float(args.extension_threshold))
circuit_library.extend_circuits_by_name(float(args.extension_threshold), args.strip_prefixes)

for extended_doc in circuit_library.get_updated_documents():
(extended_file_base, extended_file_extension) = os.path.splitext(extended_doc.name)
Expand Down
2 changes: 1 addition & 1 deletion sequences_to_features/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# See https://www.python.org/dev/peps/pep-0440/ for info on version numbering
__version__ = '1.5'
__version__ = '1.5.1'

from sequences_to_features.sequences_to_features import *
Loading

0 comments on commit 4daa7d9

Please sign in to comment.