From e18846e495b42d6c14f8fe716df6e44998f40081 Mon Sep 17 00:00:00 2001 From: Puja Trivedi Date: Thu, 3 Oct 2024 23:03:59 -0700 Subject: [PATCH 1/3] added documentation for data translators --- .../genome_annotation_translator.py | 7 +- .../library_generation_translator.py | 27 ++- docs/data_translators.rst | 181 ++++++++++++++++++ docs/index.rst | 19 +- 4 files changed, 212 insertions(+), 22 deletions(-) create mode 100644 docs/data_translators.rst diff --git a/bkbit/data_translators/genome_annotation_translator.py b/bkbit/data_translators/genome_annotation_translator.py index 68f9ec6..4c47be9 100644 --- a/bkbit/data_translators/genome_annotation_translator.py +++ b/bkbit/data_translators/genome_annotation_translator.py @@ -7,10 +7,10 @@ 4. Serialize the extracted information into JSON-LD format for further use. Classes: - Gff3: A class to handle the entire process of downloading, parsing, and processing GFF3 files. + Gff3: The Gff3 class is designed to handle the complete lifecycle of downloading, parsing, and processing GFF3 files from NCBI or Ensembl repositories. It extracts gene annotations and serializes the data into JSON-LD format. Functions: - cli: Command line interface function to execute the module as a script. + gff2jsonld: The gff2jsonld function is responsible for creating GeneAnnotation objects from a provided GFF3 file and serializing the extracted information into the JSON-LD format. Usage: The module can be run as a standalone script by executing it with appropriate arguments and options: @@ -18,6 +18,7 @@ ``` python genome_annotation_translator.py -a -s -l -f ``` + The script will download the GFF3 file from the specified URL, parse it, and serialize the extracted information into JSON-LD format. Example: @@ -180,7 +181,7 @@ def __init__( self.taxon_scientific_name = load_json(TAXON_SCIENTIFIC_NAME_PATH) self.taxon_common_name = load_json(TAXON_COMMON_NAME_PATH) except FileNotFoundError as e: - self.logger.critical("NCBI Taxonomy not downloaded. Run 'bkbit download_ncbi_taxonomy' command first." ) + self.logger.critical("NCBI Taxonomy not downloaded. Run 'bkbit download-ncbi-taxonomy' command first." ) print(e) sys.exit(2) diff --git a/bkbit/data_translators/library_generation_translator.py b/bkbit/data_translators/library_generation_translator.py index 898e625..07ee3e8 100644 --- a/bkbit/data_translators/library_generation_translator.py +++ b/bkbit/data_translators/library_generation_translator.py @@ -21,7 +21,7 @@ The module can be run as a standalone script using the command-line interface with the appropriate arguments and options: ``` - python specimen_portal.py -d + python specimen_portal.py [-d] ``` This script will parse the nhash ID and serialize the generated data into JSON-LD format, with the option to parse descendants or ancestors. @@ -95,18 +95,15 @@ class SpecimenPortal: serialize_to_jsonld(exclude_none=True, exclude_unset=False): Serializes the generated objects into JSON-LD format for further use or storage. - Static Methods: - __check_valueset_membership(enum_type, nimp_value): - Checks if a given value belongs to a specified enum. - - Private Methods: - __parse_single_nashid(jwt_token, nhash_id, descendants, save_to_file=False): + parse_single_nashid(jwt_token, nhash_id, descendants, save_to_file=False): Parses a single nhash ID and optionally saves the result to a JSON-LD file. - __parse_multiple_nashids(jwt_token, file_path, descendants): - Parses multiple nhash IDs from a file and saves the results to JSON-LD files. - + parse_multiple_nashids(jwt_token, file_path, descendants): + Parses multiple nhash IDs from a file and saves the results to JSON-LD files. + Static Methods: + __check_valueset_membership(enum_type, nimp_value): + Checks if a given value belongs to a specified enum. """ def __init__(self, jwt_token): self.jwt_token = jwt_token @@ -360,7 +357,7 @@ def serialize_to_jsonld( return json.dumps(output_data, indent=2) -def __parse_single_nashid(jwt_token, nhash_id, descendants, save_to_file=False): +def parse_single_nashid(jwt_token, nhash_id, descendants, save_to_file=False): """ Parse a single nashid using the SpecimenPortal class. @@ -388,7 +385,7 @@ def __parse_single_nashid(jwt_token, nhash_id, descendants, save_to_file=False): print(sp_obj.serialize_to_jsonld()) -def __parse_multiple_nashids(jwt_token, file_path, descendants): +def parse_multiple_nashids(jwt_token, file_path, descendants): """ Parse multiple nashids from a file. @@ -405,7 +402,7 @@ def __parse_multiple_nashids(jwt_token, file_path, descendants): nhashids = [line.strip() for line in file.readlines()] with Pool() as pool: results = pool.starmap( - __parse_single_nashid, + parse_single_nashid, [(jwt_token, nhash_id, descendants, True) for nhash_id in nhashids], ) return results @@ -438,9 +435,9 @@ def specimen2jsonld(nhash_id: str, descendants: bool): if not jwt_token or jwt_token == "": raise ValueError("JWT token is required") if os.path.isfile(nhash_id): - __parse_multiple_nashids(jwt_token, nhash_id, descendants) + parse_multiple_nashids(jwt_token, nhash_id, descendants) else: - __parse_single_nashid(jwt_token, nhash_id, descendants) + parse_single_nashid(jwt_token, nhash_id, descendants) if __name__ == "__main__": diff --git a/docs/data_translators.rst b/docs/data_translators.rst new file mode 100644 index 0000000..e7f4a28 --- /dev/null +++ b/docs/data_translators.rst @@ -0,0 +1,181 @@ +.. _datatranslators: + +Data Translators +====== + +Annotated Genome Data +---------------------- +Generate JSON-LD files for annotated genes from a given GFF3 file. Currently GFF3 files from ENSEMBL and NCBI are supported. + +Each JSON-LD file will contain: + +- GeneAnnotation objects +- 1 GenomeAnnotation object +- 1 GenomeAssembly object +- 1 OrganismTaxon object +- 1 Checksum object + +Command Line +............. + +``bkbit gff2jsonld`` +,,,,,,,,,,,,,,,,,,,,, + + .. code-block:: bash + + $ bkbit gff2jsonld [OPTIONS] GFF3_URL + +Options +,,,,,,,, + + ``-a, --assembly_accession`` + ID assigned to the genomic assembly used in the GFF3 file. + **Note: Must be provided when using ENSEMBL GFF3 files** + + ``-s, --assembly_strain`` + Specific strain of the organism associated with the GFF3 file. + + ``-l, --log_level`` + Logging level. + + Default: + WARNING + Options: + DEBUG | INFO | WARNING | ERROR | CRITICIAL + + ``-f, --log_to_file`` + Log to a file instead of the console. + + Default: + FALSE + +Arguments +,,,,,,,, + + ``GFF3_URL`` + URL to the GFF3 file. + +Examples +......... + +Example 1: NCBI GFF3 file +,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + $ bkbit gff2jsonld 'https://ftp.ncbi.nlm.nih.gov/genomes/all/annotation_releases/9823/106/GCF_000003025.6_Sscrofa11.1/GCF_000003025.6_Sscrofa11.1_genomic.gff.gz' > output.jsonld + + +Example 2: ENSEMBL GFF3 file +,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + $ bkbit gff2jsonld -a 'GCF_003339765.1' 'https://ftp.ensembl.org/pub/release-104/gff3/macaca_mulatta/Macaca_mulatta.Mmul_10.104.gff3.gz' > output.jsonld + + +Specimen Data +---------------------- +Generate JSON-LD files for specimens, subjects, and their repective ancestors or descendants. Data is retrieved from the `BICAN Specimen Portal `_. + +Command Line +............. + +``bkbit specimen2jsonld`` +,,,,,,,,,,,,,,,,,,,,, + + .. code-block:: bash + + $ bkbit specimen2jsonld [OPTIONS] NHASH_ID_OR_FILE + +Options +,,,,,,,, + + ``-d, --decendants`` + A boolean flag that, when provided, generates BICAN objects for the given NHASH_ID and all of its descendants. + If this flag is not set (DEFAULT), then the ancestors will be processed. + +Arguments +,,,,,,,, + + ``NHASH_ID_OR_FILE`` + The NHASH_ID of the specimen or a file containing a list of NHASH_IDs. + If a file is provided, the file should contain one NHASH_ID per line. + +Environment Variables +............. + +jwt_token +,,,,,,,,, + + You **must** set the SpecimenPortal Personal API Token as an environment variable before running ``bkbit specimen2jsonld``. Once set, the token will be used to authenticate with the Specimen Portal API and retrieve the specimen metadata. + + .. code-block:: bash + + $ export jwt_token=specimen_portal_personal_api_token + + +Examples +......... + +Example 1: Parse a single record and its ancestors +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + # Run specimen2jsonld command + $ bkbit specimen2jsonld 'LP-CVFLMQ819998' > output.jsonld + +Example 2: Parse a single record and its descendants +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + # Run specimen2jsonld command. Important: include '--descendants' flag + $ bkbit specimen2jsonld -d 'DO-GICE7463' > output.jsonld + +Example 3: Parse a file containing record(s) and their respective ancestors +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + # Contents of input file + $ cat input_nhash_ids.txt + LA-TZWCWB265559FVVNTS329147 + LA-IAXCCV360563HBFKKM103455 + LA-JFCEST535498UIPMOH349083 + + # Run specimen2jsonld command + $ bkbit specimen2jsonld input_nhash_ids.txt + + # Expected output + $ ls . + LA-TZWCWB265559FVVNTS329147.jsonld + LA-IAXCCV360563HBFKKM103455.jsonld + LA-JFCEST535498UIPMOH349083.jsonld + +Example 4: Parse a file containing record(s) and their respective descendants +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + # Contents of input file + $ cat input_nhash_ids.txt + DO-XIQQ6047 + DO-WFFF3774 + DO-RMRL6873 + + # Run specimenjsonld command. Important: include '--descendants' flag + $ bkbit specimen2jsonld -d input_nhash_ids.txt + + # Expected output + $ ls . + DO-XIQQ6047.jsonld + DO-WFFF3774.jsonld + DO-RMRL6873.jsonld + +Structured Anatomical Data +---------------------------- + + + diff --git a/docs/index.rst b/docs/index.rst index 3bfd967..921af7c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,14 +8,25 @@ Brain Knowledge Base Interaction Toolkit Documentation This package contains tools to use the BICAN Knowledgebase Data Models. .. toctree:: - :maxdepth: 2 - :caption: Contents: + :maxdepth: 1 + :caption: GETTING STARTED install - bkbit-quickstart - contributing + +.. toctree:: + :maxdepth: 2 + :caption: USAGE + + data_translators + +.. toctree:: + :maxdepth: 1 + :caption: REFERENCE + modules + + Indices and tables ================== From 02c6d57af5b4cf8bc8c0e849c505b2dfc54b74ae Mon Sep 17 00:00:00 2001 From: Puja Trivedi Date: Thu, 3 Oct 2024 23:54:00 -0700 Subject: [PATCH 2/3] added more documentation as well as reformatted the files --- docs/genome_annotation.rst | 75 ++++++++++++++ docs/index.rst | 12 +-- docs/specimen_file_manifest.rst | 4 + ..._translators.rst => specimen_metadata.rst} | 99 ++++--------------- 4 files changed, 106 insertions(+), 84 deletions(-) create mode 100644 docs/genome_annotation.rst create mode 100644 docs/specimen_file_manifest.rst rename docs/{data_translators.rst => specimen_metadata.rst} (61%) diff --git a/docs/genome_annotation.rst b/docs/genome_annotation.rst new file mode 100644 index 0000000..2912748 --- /dev/null +++ b/docs/genome_annotation.rst @@ -0,0 +1,75 @@ +.. _genome_annotation: + +Annotated Genome Data +---------------------- + +Overview +......... + +Generate JSON-LD files for annotated genes from a given GFF3 file. Currently GFF3 files from ENSEMBL and NCBI are supported. + +Each JSON-LD file will contain: + +- GeneAnnotation objects +- 1 GenomeAnnotation object +- 1 GenomeAssembly object +- 1 OrganismTaxon object +- 1 Checksum object + +Command Line +............. + +``bkbit gff2jsonld`` +,,,,,,,,,,,,,,,,,,,,, + + .. code-block:: bash + + $ bkbit gff2jsonld [OPTIONS] GFF3_URL + +Options +,,,,,,,, + + ``-a, --assembly_accession`` + ID assigned to the genomic assembly used in the GFF3 file. + **Note: Must be provided when using ENSEMBL GFF3 files** + + ``-s, --assembly_strain`` + Specific strain of the organism associated with the GFF3 file. + + ``-l, --log_level`` + Logging level. + + Default: + WARNING + Options: + DEBUG | INFO | WARNING | ERROR | CRITICIAL + + ``-f, --log_to_file`` + Log to a file instead of the console. + + Default: + FALSE + +Arguments +,,,,,,,,,,, + + ``GFF3_URL`` + URL to the GFF3 file. + +Examples +......... + +Example 1: NCBI GFF3 file +,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + $ bkbit gff2jsonld 'https://ftp.ncbi.nlm.nih.gov/genomes/all/annotation_releases/9823/106/GCF_000003025.6_Sscrofa11.1/GCF_000003025.6_Sscrofa11.1_genomic.gff.gz' > output.jsonld + + +Example 2: ENSEMBL GFF3 file +,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + $ bkbit gff2jsonld -a 'GCF_003339765.1' 'https://ftp.ensembl.org/pub/release-104/gff3/macaca_mulatta/Macaca_mulatta.Mmul_10.104.gff3.gz' > output.jsonld diff --git a/docs/index.rst b/docs/index.rst index 921af7c..1028ac3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,10 +14,12 @@ This package contains tools to use the BICAN Knowledgebase Data Models. install .. toctree:: - :maxdepth: 2 - :caption: USAGE + :maxdepth: 4 + :caption: DATA TRANSLATORS - data_translators + specimen_file_manifest + specimen_metadata + genome_annotation .. toctree:: :maxdepth: 1 @@ -25,11 +27,9 @@ This package contains tools to use the BICAN Knowledgebase Data Models. modules - - Indices and tables ================== * :ref:`genindex` * :ref:`modindex` -* :ref:`search` \ No newline at end of file +.. * :ref:`search` diff --git a/docs/specimen_file_manifest.rst b/docs/specimen_file_manifest.rst new file mode 100644 index 0000000..1e6507d --- /dev/null +++ b/docs/specimen_file_manifest.rst @@ -0,0 +1,4 @@ +.. _specimen_file_manifest: + +Specimen File Manifest +---------------------- diff --git a/docs/data_translators.rst b/docs/specimen_metadata.rst similarity index 61% rename from docs/data_translators.rst rename to docs/specimen_metadata.rst index e7f4a28..c262a67 100644 --- a/docs/data_translators.rst +++ b/docs/specimen_metadata.rst @@ -1,107 +1,55 @@ -.. _datatranslators: +.. _specimen_metadata: -Data Translators -====== - -Annotated Genome Data +Specimen Metadata ---------------------- -Generate JSON-LD files for annotated genes from a given GFF3 file. Currently GFF3 files from ENSEMBL and NCBI are supported. -Each JSON-LD file will contain: +Overview +......... -- GeneAnnotation objects -- 1 GenomeAnnotation object -- 1 GenomeAssembly object -- 1 OrganismTaxon object -- 1 Checksum object +Generate JSON-LD files for specimens, subjects, and their repective ancestors or descendants. Data is retrieved from the `BICAN Specimen Portal `_. Command Line ............. -``bkbit gff2jsonld`` +``bkbit specimen2jsonld`` ,,,,,,,,,,,,,,,,,,,,, - .. code-block:: bash - - $ bkbit gff2jsonld [OPTIONS] GFF3_URL - -Options -,,,,,,,, - - ``-a, --assembly_accession`` - ID assigned to the genomic assembly used in the GFF3 file. - **Note: Must be provided when using ENSEMBL GFF3 files** - - ``-s, --assembly_strain`` - Specific strain of the organism associated with the GFF3 file. - - ``-l, --log_level`` - Logging level. - - Default: - WARNING - Options: - DEBUG | INFO | WARNING | ERROR | CRITICIAL - - ``-f, --log_to_file`` - Log to a file instead of the console. - - Default: - FALSE - -Arguments -,,,,,,,, - - ``GFF3_URL`` - URL to the GFF3 file. - -Examples -......... - -Example 1: NCBI GFF3 file -,,,,,,,,,,,,,,,,,,,,,,,,,, - .. code-block:: bash - $ bkbit gff2jsonld 'https://ftp.ncbi.nlm.nih.gov/genomes/all/annotation_releases/9823/106/GCF_000003025.6_Sscrofa11.1/GCF_000003025.6_Sscrofa11.1_genomic.gff.gz' > output.jsonld - + $ bkbit specimen2jsonld [OPTIONS] NHASH_ID_OR_FILE -Example 2: ENSEMBL GFF3 file -,,,,,,,,,,,,,,,,,,,,,,,,,,,,, - -.. code-block:: bash - - $ bkbit gff2jsonld -a 'GCF_003339765.1' 'https://ftp.ensembl.org/pub/release-104/gff3/macaca_mulatta/Macaca_mulatta.Mmul_10.104.gff3.gz' > output.jsonld +**Options** + ``-d, --decendants`` + A boolean flag that, when provided, generates BICAN objects for the given NHASH_ID and all of its descendants. + If this flag is not set (DEFAULT), then the ancestors will be processed. -Specimen Data ----------------------- -Generate JSON-LD files for specimens, subjects, and their repective ancestors or descendants. Data is retrieved from the `BICAN Specimen Portal `_. +**Arguments** -Command Line -............. + ``NHASH_ID_OR_FILE`` + The NHASH_ID of the specimen or a file containing a list of NHASH_IDs. + If a file is provided, the file should contain one NHASH_ID per line. -``bkbit specimen2jsonld`` +``filemanifest2jsonld`` ,,,,,,,,,,,,,,,,,,,,, - .. code-block:: bash +.. code-block:: bash - $ bkbit specimen2jsonld [OPTIONS] NHASH_ID_OR_FILE + $ bkbit specimen2jsonld [OPTIONS] NHASH_ID_OR_FILE -Options -,,,,,,,, +**Options** ``-d, --decendants`` A boolean flag that, when provided, generates BICAN objects for the given NHASH_ID and all of its descendants. If this flag is not set (DEFAULT), then the ancestors will be processed. -Arguments -,,,,,,,, +**Arguments** ``NHASH_ID_OR_FILE`` The NHASH_ID of the specimen or a file containing a list of NHASH_IDs. If a file is provided, the file should contain one NHASH_ID per line. + Environment Variables ............. @@ -174,8 +122,3 @@ Example 4: Parse a file containing record(s) and their respective descendants DO-WFFF3774.jsonld DO-RMRL6873.jsonld -Structured Anatomical Data ----------------------------- - - - From 2c4d144a06361d3b90b2b272b3ce92c4e17e6b07 Mon Sep 17 00:00:00 2001 From: Puja Trivedi Date: Fri, 4 Oct 2024 10:45:29 -0700 Subject: [PATCH 3/3] finished docs for data translators --- docs/genome_annotation.rst | 2 ++ docs/index.rst | 2 +- docs/specimen_file_manifest.rst | 64 +++++++++++++++++++++++++++++++++ docs/specimen_metadata.rst | 32 +++++++---------- 4 files changed, 79 insertions(+), 21 deletions(-) diff --git a/docs/genome_annotation.rst b/docs/genome_annotation.rst index 2912748..979c4fc 100644 --- a/docs/genome_annotation.rst +++ b/docs/genome_annotation.rst @@ -64,6 +64,7 @@ Example 1: NCBI GFF3 file .. code-block:: bash + # Run gff2jsonld command $ bkbit gff2jsonld 'https://ftp.ncbi.nlm.nih.gov/genomes/all/annotation_releases/9823/106/GCF_000003025.6_Sscrofa11.1/GCF_000003025.6_Sscrofa11.1_genomic.gff.gz' > output.jsonld @@ -72,4 +73,5 @@ Example 2: ENSEMBL GFF3 file .. code-block:: bash + # Run gff2jsonld command $ bkbit gff2jsonld -a 'GCF_003339765.1' 'https://ftp.ensembl.org/pub/release-104/gff3/macaca_mulatta/Macaca_mulatta.Mmul_10.104.gff3.gz' > output.jsonld diff --git a/docs/index.rst b/docs/index.rst index 1028ac3..5dfa853 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,7 +14,7 @@ This package contains tools to use the BICAN Knowledgebase Data Models. install .. toctree:: - :maxdepth: 4 + :maxdepth: 1 :caption: DATA TRANSLATORS specimen_file_manifest diff --git a/docs/specimen_file_manifest.rst b/docs/specimen_file_manifest.rst index 1e6507d..2a6cffa 100644 --- a/docs/specimen_file_manifest.rst +++ b/docs/specimen_file_manifest.rst @@ -2,3 +2,67 @@ Specimen File Manifest ---------------------- + +Overview +......... + +Generates a JSON-LD file containing specimen file data using the BICAN Library Generation Schema. + +Command Line +............. + +``bkbit filemanifest2jsonld`` +,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + $ bkbit filemanifest2jsonld [OPTIONS] FILE_MANIFEST_CSV + +**Options** + + ``--list_library_aliquots`` + A boolean flag that, when provided, generates a list of unique library aliquots contained in the given file manifest and saves output in file called 'file_manifest_library_aliquots.txt'. + If this flag is not set (DEFAULT), then only the JSON-LD output will be generated. + +**Arguments** + + ``FILE_MANIFEST_CSV`` + Required argument. + FILE_MANIFEST_CSV can be optained from Brain Knowledge Platform and **must** contains the following columns: + + - Project ID + - Specimen ID + - File Name + - Checksum + - File Type + - Archive + - Archive URI + +Examples +......... + +Example 1: Only generate JSON-LD output +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + # Run filemanifest2jsonld command + $ bkbit filemanifest2jsonld file_manifest.csv > output.jsonld + +Example 2: Generate JSON-LD output and list of library aliquots +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, + +.. code-block:: bash + + # Run filemanifest2jsonld command + $ bkbit filemanifest2jsonld --list_library_aliquots file_manifest.csv > output.jsonld + + # Generated output files + $ ls . + output.jsonld + file_manifest_library_aliquots.txt + + # Contents of file_manifest_library_aliquots.txt + $ cat file_manifest_library_aliquots.txt + LP-123 + LP-345 \ No newline at end of file diff --git a/docs/specimen_metadata.rst b/docs/specimen_metadata.rst index c262a67..1d642d9 100644 --- a/docs/specimen_metadata.rst +++ b/docs/specimen_metadata.rst @@ -30,26 +30,6 @@ Command Line The NHASH_ID of the specimen or a file containing a list of NHASH_IDs. If a file is provided, the file should contain one NHASH_ID per line. -``filemanifest2jsonld`` -,,,,,,,,,,,,,,,,,,,,, - -.. code-block:: bash - - $ bkbit specimen2jsonld [OPTIONS] NHASH_ID_OR_FILE - -**Options** - - ``-d, --decendants`` - A boolean flag that, when provided, generates BICAN objects for the given NHASH_ID and all of its descendants. - If this flag is not set (DEFAULT), then the ancestors will be processed. - -**Arguments** - - ``NHASH_ID_OR_FILE`` - The NHASH_ID of the specimen or a file containing a list of NHASH_IDs. - If a file is provided, the file should contain one NHASH_ID per line. - - Environment Variables ............. @@ -70,6 +50,9 @@ Example 1: Parse a single record and its ancestors ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, .. code-block:: bash + + # If first time running specimen2jsonld or if token is expired, set jwt_token environment variable + $ export jwt_token=specimen_portal_personal_api_token # Run specimen2jsonld command $ bkbit specimen2jsonld 'LP-CVFLMQ819998' > output.jsonld @@ -79,6 +62,9 @@ Example 2: Parse a single record and its descendants .. code-block:: bash + # If first time running specimen2jsonld or if token is expired, set jwt_token environment variable + $ export jwt_token=specimen_portal_personal_api_token + # Run specimen2jsonld command. Important: include '--descendants' flag $ bkbit specimen2jsonld -d 'DO-GICE7463' > output.jsonld @@ -87,6 +73,9 @@ Example 3: Parse a file containing record(s) and their respective ancestors .. code-block:: bash + # If first time running specimen2jsonld or if token is expired, set jwt_token environment variable + $ export jwt_token=specimen_portal_personal_api_token + # Contents of input file $ cat input_nhash_ids.txt LA-TZWCWB265559FVVNTS329147 @@ -107,6 +96,9 @@ Example 4: Parse a file containing record(s) and their respective descendants .. code-block:: bash + # If first time running specimen2jsonld or if token is expired, set jwt_token environment variable + $ export jwt_token=specimen_portal_personal_api_token + # Contents of input file $ cat input_nhash_ids.txt DO-XIQQ6047