From 0fc65ed1c9b751b89171bbbfa615b3127cdb6ea1 Mon Sep 17 00:00:00 2001 From: Garrett Stevens Date: Mon, 21 Oct 2024 22:11:35 -0600 Subject: [PATCH] Replace some CLI flags with args, fix checks not being added to assembly (#471) * bug: filter conflicting keys when adding jb config * Make input files args not flags in CLI * Make "not-editable" the default when adding fasta * Remove external dependency from test * bug: keep file from being unzipped multiple times * Add default checks to assembly when it is created * Fix dev env ontology location * Remove unused import * Set assembly status to 0 so feature checks work * Fix CLI tests --- .github/workflows/pull_request.yml | 1 + .github/workflows/reload_demo_data.yml | 10 +- packages/apollo-cli/README.md | 53 +++--- .../src/commands/assembly/add-from-fasta.ts | 109 ++++++------ .../src/commands/assembly/add-from-gff.ts | 38 +++-- packages/apollo-cli/src/commands/config.ts | 3 +- .../apollo-cli/src/commands/feature/import.ts | 20 ++- .../apollo-cli/src/commands/file/upload.ts | 26 +-- .../src/commands/refseq/add-alias.ts | 20 ++- packages/apollo-cli/src/utils.ts | 70 ++++---- packages/apollo-cli/test/test.py | 155 +++++++----------- .../.development.env | 2 +- .../apollo-collaboration-server/package.json | 1 + .../src/changes/changes.module.ts | 2 + .../src/changes/changes.service.ts | 11 +- .../src/checks/checks.module.ts | 2 +- .../src/files/filesUtil.ts | 30 +--- .../src/operations/operations.module.ts | 2 + .../src/operations/operations.service.ts | 6 + .../test/data/volvox.fa.gz | Bin 0 -> 16251 bytes .../test/data/volvox.fa.gz.fai | 2 + .../test/data/volvox.fa.gz.gzi | Bin 0 -> 8 bytes packages/apollo-common/src/Operation.ts | 2 + .../AddAssemblyAndFeaturesFromFileChange.ts | 7 +- .../Changes/AddAssemblyFromExternalChange.ts | 5 +- .../src/Changes/AddAssemblyFromFileChange.ts | 18 +- .../src/Changes/ImportJBrowseConfigChange.ts | 3 +- packages/website/docs/cli/assembly.md | 17 +- packages/website/docs/cli/feature.md | 12 +- packages/website/docs/cli/file.md | 12 +- packages/website/docs/cli/refseq.md | 12 +- yarn.lock | 1 + 32 files changed, 327 insertions(+), 325 deletions(-) create mode 100644 packages/apollo-collaboration-server/test/data/volvox.fa.gz create mode 100644 packages/apollo-collaboration-server/test/data/volvox.fa.gz.fai create mode 100644 packages/apollo-collaboration-server/test/data/volvox.fa.gz.gzi diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 52ad1fc67..d823790f7 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -40,6 +40,7 @@ jobs: working-directory: packages/jbrowse-plugin-apollo - name: Start apollo run: | + yarn --cwd packages/apollo-collaboration-server/test/data/ serve --listen 3131 & yarn --cwd packages/apollo-shared start & ALLOW_ROOT_USER=true ROOT_USER_NAME=admin ROOT_USER_PASSWORD=pass yarn --cwd packages/apollo-collaboration-server start & - name: Run CLI tests diff --git a/.github/workflows/reload_demo_data.yml b/.github/workflows/reload_demo_data.yml index f5fa4a1e6..a332be577 100644 --- a/.github/workflows/reload_demo_data.yml +++ b/.github/workflows/reload_demo_data.yml @@ -89,23 +89,21 @@ jobs: /data/schistosoma_haematobium.TD2_PRJEB44434.WBPS19.genomic.fa.gz \ --fai /data/schistosoma_haematobium.TD2_PRJEB44434.WBPS19.genomic.fa.gz.fai \ --gzi /data/schistosoma_haematobium.TD2_PRJEB44434.WBPS19.genomic.fa.gz.gzi \ - --assembly 'Schistosoma haematobium' \ - --not-editable + --assembly 'Schistosoma haematobium' apollo assembly \ add-from-fasta \ /data/schistosoma_mansoni.PRJEA36577.WBPS19.genomic.fa.gz \ --fai /data/schistosoma_mansoni.PRJEA36577.WBPS19.genomic.fa.gz.fai \ --gzi /data/schistosoma_mansoni.PRJEA36577.WBPS19.genomic.fa.gz.gzi \ - --assembly 'Schistosoma mansoni' \ - --not-editable + --assembly 'Schistosoma mansoni' apollo feature \ import \ - --input-file /data/schistosoma_haematobium.TD2_PRJEB44434.WBPS19.annotations.genes.gff3 \ + /data/schistosoma_haematobium.TD2_PRJEB44434.WBPS19.annotations.genes.gff3 \ --assembly 'Schistosoma haematobium' apollo feature \ import \ - --input-file /data/schistosoma_mansoni.PRJEA36577.WBPS19.annotations.genes.gff3 \ + /data/schistosoma_mansoni.PRJEA36577.WBPS19.annotations.genes.gff3 \ --assembly 'Schistosoma mansoni' diff --git a/packages/apollo-cli/README.md b/packages/apollo-cli/README.md index 74bd15ece..b0faa1f00 100644 --- a/packages/apollo-cli/README.md +++ b/packages/apollo-cli/README.md @@ -47,18 +47,18 @@ USAGE - [`apollo feature edit-type`](#apollo-feature-edit-type) - [`apollo feature get`](#apollo-feature-get) - [`apollo feature get-id`](#apollo-feature-get-id) -- [`apollo feature import`](#apollo-feature-import) +- [`apollo feature import INPUT-FILE`](#apollo-feature-import-input-file) - [`apollo feature search`](#apollo-feature-search) - [`apollo file delete`](#apollo-file-delete) - [`apollo file download`](#apollo-file-download) - [`apollo file get`](#apollo-file-get) -- [`apollo file upload`](#apollo-file-upload) +- [`apollo file upload INPUT-FILE`](#apollo-file-upload-input-file) - [`apollo help [COMMANDS]`](#apollo-help-commands) - [`apollo jbrowse get-config`](#apollo-jbrowse-get-config) - [`apollo jbrowse set-config INPUTFILE`](#apollo-jbrowse-set-config-inputfile) - [`apollo login`](#apollo-login) - [`apollo logout`](#apollo-logout) -- [`apollo refseq add-alias`](#apollo-refseq-add-alias) +- [`apollo refseq add-alias INPUT-FILE`](#apollo-refseq-add-alias-input-file) - [`apollo refseq get`](#apollo-refseq-get) - [`apollo status`](#apollo-status) - [`apollo user get`](#apollo-user-get) @@ -69,21 +69,20 @@ Add a new assembly from fasta input ``` USAGE - $ apollo assembly add-from-fasta INPUT [--profile ] [--config-file ] [-a ] [-x ] [-f] [-n] - [--fai ] [--gzi ] [-z | -d] + $ apollo assembly add-from-fasta INPUT [--profile ] [--config-file ] [-a ] [-f] [-e] [--fai ] + [--gzi ] [-z | -d] ARGUMENTS - INPUT Input fasta file, local or remote, or id of a previously uploaded file + INPUT Input fasta file, local or remote, or id of a previously uploaded file. For local or remote files, it is + assumed the file is bgzip'd with `bgzip` and indexed with `samtools faidx`. The indexes are assumed to be at + .fai and .gzi unless the options --fai and --gzi are provided. FLAGS -a, --assembly= Name for this assembly. Use the file name if omitted -d, --decompressed For local file input: Override autodetection and instruct that input is decompressed + -e, --editable Instead of using indexed fasta lookup, the sequence is loaded into the Apollo database and + is editable. Use with caution, as editing the sequence often has unintended side effects. -f, --force Delete existing assembly, if it exists - -n, --not-editable The fasta sequence is not editable. Apollo will not load it into the database and instead - use the provided indexes to query it. This option assumes the fasta file is bgzip'd with - `bgzip` and indexed with `samtools faidx`. Indexes should be named .gzi and - .fai unless options --fai and --gzi are set - -x, --index= URL of the index. Required if input is an external source -z, --gzip For local file input: Override autodetection and instruct that input is gzip compressed --config-file= Use this config file (mostly for testing) --fai= Fasta index of the (not-editable) fasta file @@ -137,7 +136,7 @@ DESCRIPTION EXAMPLES Import sequences and features: - $ apollo assembly add-from-gff -i genome.gff -a myAssembly + $ apollo assembly add-from-gff genome.gff -a myAssembly Import sequences only: @@ -674,18 +673,20 @@ EXAMPLES _See code: [src/commands/feature/get-id.ts](https://github.com/GMOD/Apollo3/blob/v0.1.20/packages/apollo-cli/src/commands/feature/get-id.ts)_ -## `apollo feature import` +## `apollo feature import INPUT-FILE` Import features from local gff file ``` USAGE - $ apollo feature import -i -a [--profile ] [--config-file ] [-d] + $ apollo feature import INPUT-FILE -a [--profile ] [--config-file ] [-d] + +ARGUMENTS + INPUT-FILE Input gff file FLAGS -a, --assembly= (required) Import into this assembly name or assembly ID -d, --delete-existing Delete existing features before importing - -i, --input-file= (required) Input gff file --config-file= Use this config file (mostly for testing) --profile= Use credentials from this profile @@ -697,7 +698,7 @@ DESCRIPTION EXAMPLES Delete features in myAssembly and then import features.gff3: - $ apollo feature import -d -i features.gff3 -a myAssembly + $ apollo feature import features.gff3 -d -a myAssembly ``` _See code: @@ -836,18 +837,20 @@ EXAMPLES _See code: [src/commands/file/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.20/packages/apollo-cli/src/commands/file/get.ts)_ -## `apollo file upload` +## `apollo file upload INPUT-FILE` Upload a local file to the Apollo server ``` USAGE - $ apollo file upload -i [--profile ] [--config-file ] [-t + $ apollo file upload INPUT-FILE [--profile ] [--config-file ] [-t text/x-fasta|text/x-gff3|application/x-bgzip-fasta|text/x-fai|application/x-gzi] [-z | -d] +ARGUMENTS + INPUT-FILE Local file to upload + FLAGS -d, --decompressed Override autodetection and instruct that input is decompressed - -i, --input-file= (required) Local file to upload -t, --type=