Skip to content

Commit

Permalink
Merge pull request #16 from linkml/patch-utils
Browse files Browse the repository at this point in the history
Adding filesystem handler.
  • Loading branch information
cmungall authored Jun 26, 2024
2 parents 0872233 + 633acc2 commit 0d33fd2
Show file tree
Hide file tree
Showing 24 changed files with 3,246 additions and 1,291 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/qc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: linkml-data-browser QC
name: linkml-store QC

on:
push:
Expand All @@ -12,6 +12,7 @@ jobs:
strategy:
matrix:
python-version: [ "3.8", "3.11" ]
mongodb-version: ['7.0']

steps:
- uses: actions/checkout@v3.0.2
Expand All @@ -33,5 +34,10 @@ jobs:
- name: Check code quality with flake8
run: poetry run tox -e lint

- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.11.0
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Test with pytest and generate coverage file
run: poetry run pytest
156 changes: 156 additions & 0 deletions docs/how-to/Query-Existing-MongoDB.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2024-06-23T01:39:45.566588Z",
"start_time": "2024-06-23T01:39:44.203426Z"
}
},
"outputs": [],
"source": [
"from linkml_store import Client\n",
"\n",
"client = Client()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"outputs": [],
"source": [
"db = client.attach_database(\"mongodb://localhost:27017/nmdc\")"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-06-23T01:39:45.571778Z",
"start_time": "2024-06-23T01:39:45.566759Z"
}
},
"id": "73685fd7e60f63b2"
},
{
"cell_type": "code",
"execution_count": 3,
"outputs": [
{
"data": {
"text/plain": "['nmdc_schema_version',\n 'ids_nmdc_gfs0',\n 'nom_analysis_activity_set',\n 'read_qc_analysis_activity_set',\n 'roles']"
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"db.list_collection_names()[0:5]"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-06-23T01:39:45.605798Z",
"start_time": "2024-06-23T01:39:45.572040Z"
}
},
"id": "46fac5899adf5b7e"
},
{
"cell_type": "code",
"execution_count": 4,
"outputs": [],
"source": [
"collection = db.get_collection(\"biosample_set\")\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-06-23T01:39:45.608722Z",
"start_time": "2024-06-23T01:39:45.605907Z"
}
},
"id": "fdc7d9bbd7a1ecae"
},
{
"cell_type": "code",
"execution_count": 5,
"outputs": [],
"source": [
"qr = collection.find({}, limit=5)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-06-23T01:39:45.711560Z",
"start_time": "2024-06-23T01:39:45.609722Z"
}
},
"id": "ed5a741307293cfa"
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [
{
"data": {
"text/plain": " id name \\\n0 gold:Gb0115231 Sand microcosm microbial communities from a hy... \n1 gold:Gb0115220 Sand microcosm microbial communities from a hy... \n2 gold:Gb0115221 Sand microcosm microbial communities from a hy... \n3 gold:Gb0115228 Sand microcosm microbial communities from a hy... \n4 gold:Gb0115225 Sand microcosm microbial communities from a hy... \n\n description \\\n0 Sterilized sand packs were incubated back in t... \n1 Sterilized sand packs were incubated back in t... \n2 Sterilized sand packs were incubated back in t... \n3 Sterilized sand packs were incubated back in t... \n4 Sterilized sand packs were incubated back in t... \n\n env_broad_scale \\\n0 {'has_raw_value': 'ENVO:01000253', 'term': {'i... \n1 {'has_raw_value': 'ENVO:01000253', 'term': {'i... \n2 {'has_raw_value': 'ENVO:01000253', 'term': {'i... \n3 {'has_raw_value': 'ENVO:01000253', 'term': {'i... \n4 {'has_raw_value': 'ENVO:01000253', 'term': {'i... \n\n env_local_scale \\\n0 {'has_raw_value': 'ENVO:01000621', 'term': {'i... \n1 {'has_raw_value': 'ENVO:01000621', 'term': {'i... \n2 {'has_raw_value': 'ENVO:01000621', 'term': {'i... \n3 {'has_raw_value': 'ENVO:01000621', 'term': {'i... \n4 {'has_raw_value': 'ENVO:01000621', 'term': {'i... \n\n env_medium type \\\n0 {'has_raw_value': 'ENVO:01000017', 'term': {'i... nmdc:Biosample \n1 {'has_raw_value': 'ENVO:01000017', 'term': {'i... nmdc:Biosample \n2 {'has_raw_value': 'ENVO:01000017', 'term': {'i... nmdc:Biosample \n3 {'has_raw_value': 'ENVO:01000017', 'term': {'i... nmdc:Biosample \n4 {'has_raw_value': 'ENVO:01000017', 'term': {'i... nmdc:Biosample \n\n collection_date \\\n0 {'has_raw_value': '2014-11-25'} \n1 {'has_raw_value': '2014-09-23'} \n2 {'has_raw_value': '2014-11-25'} \n3 {'has_raw_value': '2014-05-21'} \n4 {'has_raw_value': '2014-08-12'} \n\n depth \\\n0 {'has_raw_value': '0.5', 'has_numeric_value': ... \n1 {'has_raw_value': '0.5', 'has_numeric_value': ... \n2 {'has_raw_value': '0.5', 'has_numeric_value': ... \n3 {'has_raw_value': '0.5', 'has_numeric_value': ... \n4 {'has_raw_value': '0.5', 'has_numeric_value': ... \n\n geo_loc_name ... habitat \\\n0 {'has_raw_value': 'USA: Columbia River, Washin... ... sand microcosm \n1 {'has_raw_value': 'USA: Columbia River, Washin... ... sand microcosm \n2 {'has_raw_value': 'USA: Columbia River, Washin... ... sand microcosm \n3 {'has_raw_value': 'USA: Columbia River, Washin... ... sand microcosm \n4 {'has_raw_value': 'USA: Columbia River, Washin... ... sand microcosm \n\n location mod_date \\\n0 groundwater-surface water interaction zone in ... 2021-06-17 \n1 groundwater-surface water interaction zone in ... 2021-06-17 \n2 groundwater-surface water interaction zone in ... 2021-06-17 \n3 groundwater-surface water interaction zone in ... 2021-06-17 \n4 groundwater-surface water interaction zone in ... 2021-06-17 \n\n ncbi_taxonomy_name sample_collection_site part_of \\\n0 sediment metagenome sand microcosm [gold:Gs0114663] \n1 sediment metagenome sand microcosm [gold:Gs0114663] \n2 sediment metagenome sand microcosm [gold:Gs0114663] \n3 sediment metagenome sand microcosm [gold:Gs0114663] \n4 sediment metagenome sand microcosm [gold:Gs0114663] \n\n alternative_identifiers insdc_biosample_identifiers samp_name \\\n0 [img.taxon:3300042754] [biosample:SAMN06343877] GW-RW T4_25-Nov-14 \n1 [img.taxon:3300042744] [biosample:SAMN06343866] GW-RW T3_23-Sept-14 \n2 [img.taxon:3300042791] [biosample:SAMN06343867] GW-RW T3_25-Nov-14 \n3 [img.taxon:3300042751] [biosample:SAMN06343874] GW-RW T4_21-May-14 \n4 [img.taxon:3300042748] [biosample:SAMN06343871] GW-RW T4_12-Aug-14 \n\n gold_biosample_identifiers \n0 [gold:Gb0115231] \n1 [gold:Gb0115220] \n2 [gold:Gb0115221] \n3 [gold:Gb0115228] \n4 [gold:Gb0115225] \n\n[5 rows x 28 columns]",
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>id</th>\n <th>name</th>\n <th>description</th>\n <th>env_broad_scale</th>\n <th>env_local_scale</th>\n <th>env_medium</th>\n <th>type</th>\n <th>collection_date</th>\n <th>depth</th>\n <th>geo_loc_name</th>\n <th>...</th>\n <th>habitat</th>\n <th>location</th>\n <th>mod_date</th>\n <th>ncbi_taxonomy_name</th>\n <th>sample_collection_site</th>\n <th>part_of</th>\n <th>alternative_identifiers</th>\n <th>insdc_biosample_identifiers</th>\n <th>samp_name</th>\n <th>gold_biosample_identifiers</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>gold:Gb0115231</td>\n <td>Sand microcosm microbial communities from a hy...</td>\n <td>Sterilized sand packs were incubated back in t...</td>\n <td>{'has_raw_value': 'ENVO:01000253', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000621', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000017', 'term': {'i...</td>\n <td>nmdc:Biosample</td>\n <td>{'has_raw_value': '2014-11-25'}</td>\n <td>{'has_raw_value': '0.5', 'has_numeric_value': ...</td>\n <td>{'has_raw_value': 'USA: Columbia River, Washin...</td>\n <td>...</td>\n <td>sand microcosm</td>\n <td>groundwater-surface water interaction zone in ...</td>\n <td>2021-06-17</td>\n <td>sediment metagenome</td>\n <td>sand microcosm</td>\n <td>[gold:Gs0114663]</td>\n <td>[img.taxon:3300042754]</td>\n <td>[biosample:SAMN06343877]</td>\n <td>GW-RW T4_25-Nov-14</td>\n <td>[gold:Gb0115231]</td>\n </tr>\n <tr>\n <th>1</th>\n <td>gold:Gb0115220</td>\n <td>Sand microcosm microbial communities from a hy...</td>\n <td>Sterilized sand packs were incubated back in t...</td>\n <td>{'has_raw_value': 'ENVO:01000253', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000621', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000017', 'term': {'i...</td>\n <td>nmdc:Biosample</td>\n <td>{'has_raw_value': '2014-09-23'}</td>\n <td>{'has_raw_value': '0.5', 'has_numeric_value': ...</td>\n <td>{'has_raw_value': 'USA: Columbia River, Washin...</td>\n <td>...</td>\n <td>sand microcosm</td>\n <td>groundwater-surface water interaction zone in ...</td>\n <td>2021-06-17</td>\n <td>sediment metagenome</td>\n <td>sand microcosm</td>\n <td>[gold:Gs0114663]</td>\n <td>[img.taxon:3300042744]</td>\n <td>[biosample:SAMN06343866]</td>\n <td>GW-RW T3_23-Sept-14</td>\n <td>[gold:Gb0115220]</td>\n </tr>\n <tr>\n <th>2</th>\n <td>gold:Gb0115221</td>\n <td>Sand microcosm microbial communities from a hy...</td>\n <td>Sterilized sand packs were incubated back in t...</td>\n <td>{'has_raw_value': 'ENVO:01000253', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000621', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000017', 'term': {'i...</td>\n <td>nmdc:Biosample</td>\n <td>{'has_raw_value': '2014-11-25'}</td>\n <td>{'has_raw_value': '0.5', 'has_numeric_value': ...</td>\n <td>{'has_raw_value': 'USA: Columbia River, Washin...</td>\n <td>...</td>\n <td>sand microcosm</td>\n <td>groundwater-surface water interaction zone in ...</td>\n <td>2021-06-17</td>\n <td>sediment metagenome</td>\n <td>sand microcosm</td>\n <td>[gold:Gs0114663]</td>\n <td>[img.taxon:3300042791]</td>\n <td>[biosample:SAMN06343867]</td>\n <td>GW-RW T3_25-Nov-14</td>\n <td>[gold:Gb0115221]</td>\n </tr>\n <tr>\n <th>3</th>\n <td>gold:Gb0115228</td>\n <td>Sand microcosm microbial communities from a hy...</td>\n <td>Sterilized sand packs were incubated back in t...</td>\n <td>{'has_raw_value': 'ENVO:01000253', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000621', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000017', 'term': {'i...</td>\n <td>nmdc:Biosample</td>\n <td>{'has_raw_value': '2014-05-21'}</td>\n <td>{'has_raw_value': '0.5', 'has_numeric_value': ...</td>\n <td>{'has_raw_value': 'USA: Columbia River, Washin...</td>\n <td>...</td>\n <td>sand microcosm</td>\n <td>groundwater-surface water interaction zone in ...</td>\n <td>2021-06-17</td>\n <td>sediment metagenome</td>\n <td>sand microcosm</td>\n <td>[gold:Gs0114663]</td>\n <td>[img.taxon:3300042751]</td>\n <td>[biosample:SAMN06343874]</td>\n <td>GW-RW T4_21-May-14</td>\n <td>[gold:Gb0115228]</td>\n </tr>\n <tr>\n <th>4</th>\n <td>gold:Gb0115225</td>\n <td>Sand microcosm microbial communities from a hy...</td>\n <td>Sterilized sand packs were incubated back in t...</td>\n <td>{'has_raw_value': 'ENVO:01000253', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000621', 'term': {'i...</td>\n <td>{'has_raw_value': 'ENVO:01000017', 'term': {'i...</td>\n <td>nmdc:Biosample</td>\n <td>{'has_raw_value': '2014-08-12'}</td>\n <td>{'has_raw_value': '0.5', 'has_numeric_value': ...</td>\n <td>{'has_raw_value': 'USA: Columbia River, Washin...</td>\n <td>...</td>\n <td>sand microcosm</td>\n <td>groundwater-surface water interaction zone in ...</td>\n <td>2021-06-17</td>\n <td>sediment metagenome</td>\n <td>sand microcosm</td>\n <td>[gold:Gs0114663]</td>\n <td>[img.taxon:3300042748]</td>\n <td>[biosample:SAMN06343871]</td>\n <td>GW-RW T4_12-Aug-14</td>\n <td>[gold:Gb0115225]</td>\n </tr>\n </tbody>\n</table>\n<p>5 rows × 28 columns</p>\n</div>"
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"qr.rows_dataframe"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-06-23T01:39:45.731557Z",
"start_time": "2024-06-23T01:39:45.714621Z"
}
},
"id": "643c81991a449525"
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-06-23T01:39:45.731830Z",
"start_time": "2024-06-23T01:39:45.728994Z"
}
},
"id": "bb27cf2adebbc0da"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 0d33fd2

Please sign in to comment.