SynBioDex / sboljs3

A library for the Synthetic Biology Open Language (SBOL) written in TypeScript, for JavaScript/TypeScript applications in the browser or node.js
4 stars 1 forks source link

sbolgraph cannot handle CombinatorialDerivation objects #17

Open jakebeal opened 2 years ago

jakebeal commented 2 years ago

Any file with a CombinatorialDerivation currently produces an opaque failure because sbolgraph currently does not know about CombinatorialDerivation objects.

Example failure:

/Users/jakebeal/projects/BioTools/iGEM_distribution/scripts/sbol:54477
            throw new Error('unknown type: ' + uri + ' a ' + type);
                  ^

Error: unknown type: https://github.com/iGEM-Engineering/iGEM-distribution/Fluorescent%20Reporter%20Proteins/Fluorescent_Proteins_in_vector_ins a http://sbols.org/v3#CombinatorialDerivation
    at SBOL3.uriToFacade (/Users/jakebeal/projects/BioTools/iGEM_distribution/scripts/sbol:54477:19)
    at SBOL3GraphView.uriToFacade (/Users/jakebeal/projects/BioTools/iGEM_distribution/scripts/sbol:49132:23)
    at /Users/jakebeal/projects/BioTools/iGEM_distribution/scripts/sbol:58779:37
    at Array.map (<anonymous>)
    at S3Collection.get members [as members] (/Users/jakebeal/projects/BioTools/iGEM_distribution/scripts/sbol:58779:14)
    at Object.convert3to2 [as default] (/Users/jakebeal/projects/BioTools/iGEM_distribution/scripts/sbol:55973:33)
    at Function.<anonymous> (/Users/jakebeal/projects/BioTools/iGEM_distribution/scripts/sbol:54525:36)
    at Generator.next (<anonymous>)
    at /Users/jakebeal/projects/BioTools/iGEM_distribution/scripts/sbol:54504:71
    at new Promise (<anonymous>)
jamesamcl commented 2 years ago

This should be fixed in the latest version of sboltools, v0.3.0.

jakebeal commented 2 years ago

Thanks, @udp; let me add a test case and make sure it works for me as well.

jakebeal commented 2 years ago

I'm getting the same error, though the line numbers are different in the new release:

/Users/jakebeal/Downloads/sbol:54529
            throw new Error('unknown type: ' + uri + ' a ' + type);
                  ^

Error: unknown type: http://sbolstandard.org/testfiles/Two_color___forw_reverse_ins a http://sbols.org/v3#CombinatorialDerivation
    at SBOL3.uriToFacade (/Users/jakebeal/Downloads/sbol:54529:19)
    at SBOL3GraphView.uriToFacade (/Users/jakebeal/Downloads/sbol:49184:23)
    at /Users/jakebeal/Downloads/sbol:58831:37
    at Array.map (<anonymous>)
    at S3Collection.get members [as members] (/Users/jakebeal/Downloads/sbol:58831:14)
    at Object.convert3to2 [as default] (/Users/jakebeal/Downloads/sbol:56025:33)
    at Function.<anonymous> (/Users/jakebeal/Downloads/sbol:54577:36)
    at Generator.next (<anonymous>)
    at /Users/jakebeal/Downloads/sbol:54556:71
    at new Promise (<anonymous>)

My test case is this file https://github.com/SynBioDex/SBOL-utilities/blob/develop/test/test_files/constraints_library.nt converted to RDF-XML and with workarounds for #16 , per https://github.com/SynBioDex/SBOL-utilities/blob/7e57aa0974498843983edd94b2c52c4992342e8c/sbol_utilities/conversion.py#L168

jamesamcl commented 2 years ago

Ok my release workflow isn't quite there yet - looks like an older version of sbolgraph got baked in. Fixing it now

jamesamcl commented 2 years ago

It should be working now with sboltools 0.4.0: https://github.com/sboltools/sboltools/releases/tag/v0.4.0

jakebeal commented 2 years ago

I'm running into a problem with my usage --- it appears there's a bunch of debugging information being dumped into the output stream as well now, which is making the files not valid RDF-XML. Is there an option I can add to turn that off?

Example output:

match type NamedNodeExt { value: 'http://sbols.org/v1#DnaSequence' }
[]
match type NamedNodeExt { value: 'http://sbols.org/v1#DnaComponent' }
[]
match type NamedNodeExt { value: 'http://sbols.org/v1#Collection' }
[]
match type NamedNodeExt { value: 'http://sbols.org/v3#ExperimentalData' }
[]
match type NamedNodeExt { value: 'http://sbols.org/v3#Experiment' }
[]
match type NamedNodeExt { value: 'http://sbols.org/v3#Sequence' }
[
  NamedNode {
    termType: 'NamedNode',
    value: 'https://synbiohub.org/public/igem/BBa_J23101_sequence'
  }
]
match type NamedNodeExt { value: 'http://sbols.org/v3#Attachment' }
[]
match type NamedNodeExt { value: 'http://sbols.org/v3#CombinatorialDerivation' }
[]
match type NamedNodeExt { value: 'http://sbols.org/v3#Component' }
[
  NamedNode {
    termType: 'NamedNode',
    value: 'https://synbiohub.org/public/igem/BBa_J23101'
  }
]
match type NamedNodeExt { value: 'http://sbols.org/v3#Component' }
[
  NamedNode {
    termType: 'NamedNode',
    value: 'https://synbiohub.org/public/igem/BBa_J23101'
  }
]
match type NamedNodeExt { value: 'http://sbols.org/v3#Component' }
[
  NamedNode {
    termType: 'NamedNode',
    value: 'https://synbiohub.org/public/igem/BBa_J23101'
  }
]
match type NamedNodeExt { value: 'http://sbols.org/v3#Implementation' }
[]
match type NamedNodeExt { value: 'http://sbols.org/v3#Collection' }
[]
<?xml version='1.0' encoding='utf-8'?>
<rdf:RDF xmlns:backport="http://sboltools.org/backport#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:ns0="http://wiki.synbiohub.org/wiki/Terms/synbiohub#" xmlns:ns1="http://wiki.synbiohub.org/wiki/Terms/igem#" xmlns:ns2="http://purl.org/dc/elements/1.1/" xmlns:prov="http://www.w3.org/ns/prov#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sbol="http://sbols.org/v2#">
  <sbol:Sequence rdf:about="https://synbiohub.org/public/igem/BBa_J23101_sequence">
    <sbol:persistentIdentity rdf:resource="https://synbiohub.org/public/igem/BBa_J23101_sequence" />
    <backport:sbol3namespace rdf:resource="https://synbiohub.org" />
    <sbol:displayId>BBa_J23101_sequence</sbol:displayId>
    <prov:wasDerivedFrom rdf:resource="http://parts.igem.org/Part:BBa_J23101" />
    <prov:wasGeneratedBy rdf:resource="https://synbiohub.org/public/igem/igem2sbol" />
    <ns0:ownedBy rdf:resource="https://synbiohub.org/user/myers" />
    <ns0:ownedBy rdf:resource="https://synbiohub.org/user/james" />
    <ns0:topLevel rdf:resource="https://synbiohub.org/public/igem/BBa_J23101_sequence" />
    <sbol:version>1</sbol:version>
    <sbol:elements>tttacagctagctcagtcctaggtattatgctagc</sbol:elements>
    <sbol:encoding rdf:resource="http://www.chem.qmul.ac.uk/iubmb/misc/naseq.html" />
  </sbol:Sequence>
  <sbol:ComponentDefinition rdf:about="https://synbiohub.org/public/igem/BBa_J23101">
    <sbol:persistentIdentity rdf:resource="https://synbiohub.org/public/igem/BBa_J23101" />
    <backport:sbol3namespace rdf:resource="https://synbiohub.org" />
    <sbol:displayId>BBa_J23101</sbol:displayId>
    <prov:wasDerivedFrom rdf:resource="http://parts.igem.org/Part:BBa_J23101" />
    <prov:wasGeneratedBy rdf:resource="https://synbiohub.org/public/igem/igem2sbol" />
    <ns0:ownedBy rdf:resource="https://synbiohub.org/user/myers" />
    <ns0:ownedBy rdf:resource="https://synbiohub.org/user/james" />
    <ns0:topLevel rdf:resource="https://synbiohub.org/public/igem/BBa_J23101" />
    <sbol:version>1</sbol:version>
    <dcterms:title>BBa_J23101</dcterms:title>
    <dcterms:description>constitutive promoter family member</dcterms:description>
    <ns1:group_u_list>_52_</ns1:group_u_list>
    <ns1:experience rdf:resource="http://wiki.synbiohub.org/wiki/Terms/igem#experience/Works" />
    <ns2:creator>John Anderson</ns2:creator>
    <ns1:discontinued>false</ns1:discontinued>
    <ns0:star>true</ns0:star>
    <dcterms:created>2006-08-03T11:00:00Z</dcterms:created>
    <ns1:owner_id>483</ns1:owner_id>
    <ns1:sampleStatus>In stock</ns1:sampleStatus>
    <ns0:mutableProvenance>later</ns0:mutableProvenance>
    <ns0:mutableNotes>N/A</ns0:mutableNotes>
    <ns1:owning_group_id>95</ns1:owning_group_id>
    <dcterms:modified>2015-08-31T04:08:40Z</dcterms:modified>
    <ns1:dominant>true</ns1:dominant>
    <ns0:bookmark>true</ns0:bookmark>
    <ns1:m_user_id>0</ns1:m_user_id>
    <ns1:status rdf:resource="http://wiki.synbiohub.org/wiki/Terms/igem#status/Available" />
    <ns1:partStatus>Released HQ 2013</ns1:partStatus>
    <ns0:mutableDescription>later</ns0:mutableDescription>
    <backport:sbol3identity rdf:resource="https://synbiohub.org/public/igem/BBa_J23101" />
    <sbol:role rdf:resource="http://wiki.synbiohub.org/wiki/Terms/igem#partType/Regulatory" />
    <sbol:role rdf:resource="http://identifiers.org/so/SO:0000167" />
    <sbol:type rdf:resource="http://www.biopax.org/release/biopax-level3.owl#DnaRegion" />
    <sbol:sequence rdf:resource="https://synbiohub.org/public/igem/BBa_J23101_sequence" />
  </sbol:ComponentDefinition>
</rdf:RDF>
jamesamcl commented 2 years ago

That's annoying! Should be fixed now:

https://github.com/sboltools/sboltools/releases/tag/v0.5.0

jakebeal commented 2 years ago

Getting closer now; I've got a couple of errors in content now, but I don't yet know whether they're issues in sbolgraph or issues that sbolgraph is now revealing about my own library...

jakebeal commented 2 years ago

Looks like SBOL LocalSubComponent objects are being dropped on down-conversion. Instead, they should be changed into a Component or FunctionalComponent that links to a new ComponentDefinition.

Currently, the SBOL2 file is technically valid but incomplete (since it's missing the variables), but becomes invalid on conversion back to SBOL3, where the links are to child objects and not allowed to be missing.

An example of a file where this is happening: constraints_library.nt.txt

JMante1 commented 2 years ago

I am also struggling with this, at least I assume it is this:

Traceback (most recent call last): File "/home/runner/work/github-to-SynBioHub/github-to-SynBioHub/main.py", line 14, in doc2 = conv.convert3to2(doc3) File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/sbol_utilities/conversion.py", line 221, in convert3to2 Error: raise ValueError('Embedded SBOL 3-to-2 converter failed opaquely, possibly indicating an invalid SBOL file.') ValueError: Embedded SBOL 3-to-2 converter failed opaquely, possibly indicating an invalid SBOL file. Error: Process completed with exit code 1.