Skip to content

Commit

Permalink
Merge pull request #201 from SynBioDex/200-kludge-defuzz-fuzzy-features
Browse files Browse the repository at this point in the history
Kludge defuzz fuzzy features
  • Loading branch information
jakebeal authored Mar 27, 2023
2 parents 9637402 + 4029e26 commit 1840948
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 48 deletions.
11 changes: 3 additions & 8 deletions sbol_utilities/sbol3_genbank_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,7 @@ class Location_GenBank_Extension(sbol3.Location):
start and end position types (AfterPostion / BeforePosition / ExactPosition).
:extends: sbol3.Location class
"""
# Use the SBOL3 namespace for the type URI as a workaround for
# a bug in pySBOL3.
# TODO: use genbank namespace when the pySBOL3 bug is fixed
# NOTE: pySBOL3 BUG REPORT: https://github.com/SynBioDex/pySBOL3/issues/414
# NOTE: pySBOL3 BUG FIX : https://github.com/SynBioDex/pySBOL3/pull/415
# GENBANK_RANGE_NS = "http://www.ncbi.nlm.nih.gov/genbank#locationPosition"
GENBANK_RANGE_NS = sbol3.SBOL3_NS + "locationPosition"
GENBANK_RANGE_NS = "http://www.ncbi.nlm.nih.gov/genbank#locationPosition"

def __init__(self, sequence: sbol3.Sequence = sbol3.Sequence("autoCreatedSequence"),
*, identity: str = None, type_uri: str = GENBANK_RANGE_NS,
Expand Down Expand Up @@ -734,7 +728,8 @@ def _handle_features_gb_to_sbol(self, record: SeqRecord,
start_position = self.SBOL_LOCATION_POSITION[type(gb_loc.start)]
# If both start and end positions are exact positions, the
# feature location can be created simply as a range object
if start_position == 1 and end_position == 1:
# Kludge truncation of fuzzy ranges (https://github.com/SynBioDex/SBOL-utilities/issues/200)
if start_position == 1 and end_position == 1 or True:
locs = sbol3.Range(
sequence = seq,
orientation = feat_loc_orientation,
Expand Down
72 changes: 32 additions & 40 deletions test/test_files/sbol3_genbank_conversion/test_location_types.nt
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@
<https://test.sbol3.genbank/JWYZ01000115/Reference_1> <http://www.ncbi.nlm.nih.gov/genbank#reference#title> "Direct Submission" .
<https://test.sbol3.genbank/JWYZ01000115/Reference_1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#TopLevel> .
<https://test.sbol3.genbank/JWYZ01000115/Reference_1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.ncbi.nlm.nih.gov/genbank#reference> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> <http://sbols.org/v3#displayId> "locationPosition1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> <http://sbols.org/v3#locationPosition#end> "115"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> <http://sbols.org/v3#locationPosition#end_position> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> <http://sbols.org/v3#locationPosition#start> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> <http://sbols.org/v3#locationPosition#start_position> "0"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001031> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#locationPosition> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/Range1> <http://sbols.org/v3#displayId> "Range1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/Range1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/Range1> <http://sbols.org/v3#end> "115"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/Range1> <http://sbols.org/v3#start> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/Range1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001031> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/Range1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#Range> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature10/Range1> <http://sbols.org/v3#displayId> "Range1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature10/Range1> <http://sbols.org/v3#end> "2299"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature10/Range1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
Expand Down Expand Up @@ -128,32 +126,28 @@
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature13> <http://www.ncbi.nlm.nih.gov/genbank#featureQualifier#value> "6:KIG36583.1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature13> <http://www.ncbi.nlm.nih.gov/genbank#featureQualifier#value> "7:MIIGNIHNLQPWLPQELRQAIEHIKAHVTAETPKGKHDIEGNHLFYLISEDMTEPYEARRAEYHARYLDIQIVLKGQEGMTFSTQPAGTPDTDWLADKDIAFLPEGVDEKTVILNEGDFVVFYPGEVHKPLCAVGAPAQVRKAVVKMLMA" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature13> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#SequenceFeature> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> <http://sbols.org/v3#displayId> "locationPosition1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> <http://sbols.org/v3#locationPosition#end> "3242"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> <http://sbols.org/v3#locationPosition#end_position> "2"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> <http://sbols.org/v3#locationPosition#start> "3019"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> <http://sbols.org/v3#locationPosition#start_position> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001030> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#locationPosition> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/Range1> <http://sbols.org/v3#displayId> "Range1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/Range1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/Range1> <http://sbols.org/v3#end> "3242"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/Range1> <http://sbols.org/v3#start> "3019"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/Range1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001030> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/Range1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#Range> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://sbols.org/v3#displayId> "SequenceFeature14" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://sbols.org/v3#hasLocation> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/locationPosition1> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://sbols.org/v3#hasLocation> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14/Range1> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://sbols.org/v3#name> "_converted_feature_13" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001030> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://sbols.org/v3#role> <https://identifiers.org/SO:0000704> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://www.ncbi.nlm.nih.gov/genbank#featureQualifier#key> "0:locus_tag" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://www.ncbi.nlm.nih.gov/genbank#featureQualifier#value> "0:PU64_23690" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#SequenceFeature> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> <http://sbols.org/v3#displayId> "locationPosition1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> <http://sbols.org/v3#locationPosition#end> "3242"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> <http://sbols.org/v3#locationPosition#end_position> "2"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> <http://sbols.org/v3#locationPosition#start> "3019"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> <http://sbols.org/v3#locationPosition#start_position> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001030> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#locationPosition> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/Range1> <http://sbols.org/v3#displayId> "Range1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/Range1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/Range1> <http://sbols.org/v3#end> "3242"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/Range1> <http://sbols.org/v3#start> "3019"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/Range1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001030> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/Range1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#Range> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> <http://sbols.org/v3#displayId> "SequenceFeature15" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> <http://sbols.org/v3#hasLocation> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/locationPosition1> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> <http://sbols.org/v3#hasLocation> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15/Range1> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> <http://sbols.org/v3#name> "_converted_feature_14" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001030> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> <http://sbols.org/v3#role> <https://identifiers.org/SO:0000316> .
Expand All @@ -175,23 +169,21 @@
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> <http://www.ncbi.nlm.nih.gov/genbank#featureQualifier#value> "7:MSKISGWNFSQNITSADNCKQKNEDLDTWYVGMNDFARIAGGQNSRSNILSPRAFLEFLAKIFTLGYVDFSKRS" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#SequenceFeature> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://sbols.org/v3#displayId> "SequenceFeature1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://sbols.org/v3#hasLocation> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/locationPosition1> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://sbols.org/v3#hasLocation> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1/Range1> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://sbols.org/v3#name> "_converted_feature_0" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001031> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://sbols.org/v3#role> <https://identifiers.org/SO:0000704> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://www.ncbi.nlm.nih.gov/genbank#featureQualifier#key> "0:locus_tag" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://www.ncbi.nlm.nih.gov/genbank#featureQualifier#value> "0:PU64_23660" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#SequenceFeature> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> <http://sbols.org/v3#displayId> "locationPosition1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> <http://sbols.org/v3#locationPosition#end> "115"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> <http://sbols.org/v3#locationPosition#end_position> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> <http://sbols.org/v3#locationPosition#start> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> <http://sbols.org/v3#locationPosition#start_position> "0"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001031> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#locationPosition> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/Range1> <http://sbols.org/v3#displayId> "Range1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/Range1> <http://sbols.org/v3#hasSequence> <https://test.sbol3.genbank/JWYZ01000115_sequence> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/Range1> <http://sbols.org/v3#end> "115"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/Range1> <http://sbols.org/v3#start> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/Range1> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001031> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/Range1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://sbols.org/v3#Range> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2> <http://sbols.org/v3#displayId> "SequenceFeature2" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2> <http://sbols.org/v3#hasLocation> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/locationPosition1> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2> <http://sbols.org/v3#hasLocation> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2/Range1> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2> <http://sbols.org/v3#name> "_converted_feature_1" .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2> <http://sbols.org/v3#orientation> <https://identifiers.org/SO:0001031> .
<https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2> <http://sbols.org/v3#role> <https://identifiers.org/SO:0000316> .
Expand Down Expand Up @@ -437,10 +429,10 @@
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#date> "16-JAN-2015" .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#dbxrefs> "BioProject:PRJNA266657::BioSample:SAMN03177677" .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#division> "BCT" .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#fuzzyFeatures> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#fuzzyFeatures> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#fuzzyFeatures> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#fuzzyFeatures> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2> .
<https://test.sbol3.genbank/JWYZ01000115> <http://sbols.org/v3#hasFeature> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature14> .
<https://test.sbol3.genbank/JWYZ01000115> <http://sbols.org/v3#hasFeature> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature15> .
<https://test.sbol3.genbank/JWYZ01000115> <http://sbols.org/v3#hasFeature> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature1> .
<https://test.sbol3.genbank/JWYZ01000115> <http://sbols.org/v3#hasFeature> <https://test.sbol3.genbank/JWYZ01000115/SequenceFeature2> .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#id> "JWYZ01000115.1" .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#keywords> "WGS" .
<https://test.sbol3.genbank/JWYZ01000115> <http://www.ncbi.nlm.nih.gov/genbank#locus> "JWYZ01000115" .
Expand Down
1 change: 1 addition & 0 deletions test/test_genbank_sbol3_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def test_feature_location_types_ignore_fuzzy(self):
sbol3.set_namespace(self.converter.TEST_NAMESPACE)
self._test_genbank_to_sbol3(sample_sbol3_file=sbol3_file, sample_genbank_file=genbank_file)

@unittest.skip(reason="Round-tripping blocked by https://github.com/SynBioDex/SBOL-utilities/issues/200")
def test_feature_location_types_round_trip_fuzzy(self):
"""Test ability to correctly round trip genbank test files in the iGEM distribution which have
different FeatureLocation types like BeforePosition / AfterPosition / ExactPosition.
Expand Down

0 comments on commit 1840948

Please sign in to comment.