diff --git a/.github/workflows/npm-grunt.yml b/.github/workflows/npm-grunt.yml new file mode 100644 index 00000000..287f79f2 --- /dev/null +++ b/.github/workflows/npm-grunt.yml @@ -0,0 +1,28 @@ +name: NodeJS with Grunt + +on: + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Build + run: | + npm install + grunt diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 00000000..2a4766d3 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/sbol_utilities/conversion.py b/sbol_utilities/conversion.py index 225c55b7..e74a43b3 100644 --- a/sbol_utilities/conversion.py +++ b/sbol_utilities/conversion.py @@ -114,12 +114,25 @@ def convert2to3(sbol2_doc: Union[str, sbol2.Document], namespaces=None, use_nati # TODO: remove workaround after conversion errors fixed in https://github.com/sboltools/sbolgraph/issues/14 # add in the missing namespace fields where possible, defaulting otherwise # TODO: add check for non-TopLevel? See https://github.com/SynBioDex/pySBOL3/issues/295 - needs_namespace = {o for o in doc.objects if o.namespace is None} - for n in namespaces: - assignable = {o for o in needs_namespace if o.identity.startswith(n)} - for a in assignable: - a.namespace = n - needs_namespace = needs_namespace - assignable + # Namespace Assignment +needs_namespace = {o for o in doc.objects if o.namespace is None} +for n in namespaces: + assignable = {o for o in needs_namespace if o.identity.startswith(n)} + for a in assignable: + a.namespace = n + needs_namespace = needs_namespace - assignable +for o in needs_namespace: + p = urllib.parse.urlparse(o.identity) + server = urllib.parse.urlunparse([p.scheme, p.netloc, '', '', '', '']) + o.namespace = server + +# Sequence Inference +for s in (o for o in doc.objects if isinstance(o, sbol3.Component)): + if len(s.sequences) != 1: + continue + for f in (f for f in s.features if isinstance(f, sbol3.SequenceFeature) or isinstance(f, sbol3.SubComponent)): + for loc in f.locations: + loc.sequence = s.sequences[0] for o in needs_namespace: # if no supplied namespace matches, default to scheme//netloc # figure out the server to access from the URL p = urllib.parse.urlparse(o.identity)