Skip to content

Commit

Permalink
working jupyter notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
sierra-moxon committed Mar 5, 2025
1 parent 4f54855 commit a445ef4
Showing 1 changed file with 153 additions and 1 deletion.
154 changes: 153 additions & 1 deletion docs/nb/ontology_loader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,161 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "9bba2a21-76b8-4665-b7e2-259686b6a1f5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"id id type name description alternative_identifiers alternative_names definition relations\n",
"\u0007\u001b[H\u001b[2J\u001b[H\u001b[H\u001b[2J\u001b[Hid id type name description alternative_identifiers alternative_names definition relations\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[1m~\u001b[m\n",
"\u001b[K\u001b[7m(END)\u001b[m\u001b[K"
]
}
],
"source": [
"!less /Users/SMoxon/Documents/src/nmdc-runtime/docs/nb/ontology_reports/ontology_inserts.tsv"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "0e3617d2-af3d-4d50-b940-6766ea6f5882",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"id id type name description alternative_identifiers alternative_names definition relations\n",
"ENVO:00000000 ENVO:00000000 nmdc:OntologyClass [] ['geographic feature', 'macroscopic spatial feature'] An astrononmical body part which delimited by physical discontinuities with its surroundings. []\n",
"ENVO:00000002 ENVO:00000002 nmdc:OntologyClass [] ['manmade feature', 'man-made feature', 'anthropogenic geographic feature'] An anthropogenic geographic feature is a geographic feature resulting from the influence of human beings on nature. []\n",
"ENVO:00000004 ENVO:00000004 nmdc:OntologyClass [] ['prefecture', 'civil area', 'administrative region', 'protectorate', 'sheikdom', 'trade zone', 'administrative entity', 'neutral zone (political)', 'leased zone (government)', 'boundary region', 'free trade zone', 'administrative area', 'sultanate', 'governed place', 'district', 'leased area (government)', 'administrative division'] []\n",
"ENVO:00000005 ENVO:00000005 nmdc:OntologyClass [] ['first-order administrative region', 'first level subdivision', 'first-order administrative division', 'countries, 1st order division'] A primary administrative division of a country, such as a state in the United States. []\n",
"ENVO:00000006 ENVO:00000006 nmdc:OntologyClass [] ['second-order administrative region', 'second level subdivision', 'countries, 2nd order division', 'second-order administrative division'] A subdivision of a first-order administrative division. []\n",
"\u0007\u001b[H\u001b[2J\u001b[H\u001b[H\u001b[2J\u001b[Hid id type name description alternative_identifiers alternative_names definition relations\n",
"ENVO:00000000 ENVO:00000000 nmdc:OntologyClass [] ['geographic feature', 'macroscopic spatial feature'] An astrononmical body part which delimited by physical discontinuities with its surroundings. []\n",
"ENVO:00000002 ENVO:00000002 nmdc:OntologyClass [] ['manmade feature', 'man-made feature', 'anthropogenic geographic feature'] An anthropogenic geographic feature is a geographic feature resulting from the influence of human beings on nature. []\n",
"ENVO:00000004 ENVO:00000004 nmdc:OntologyClass [] ['prefecture', 'civil area', 'administrative region', 'protectorate', 'sheikdom', 'trade zone', 'administrative entity', 'neutral zone (political)', 'leased zone (government)', 'boundary region', 'free trade zone', 'administrative area', 'sultanate', 'governed place', 'district', 'leased area (government)', 'administrative division'] []\n",
"ENVO:00000005 ENVO:00000005 nmdc:OntologyClass [] ['first-order administrative region', 'first level subdivision', 'first-order administrative division', 'countries, 1st order division'] A primary administrative division of a country, such as a state in the United States. []\n",
"ENVO:00000006 ENVO:00000006 nmdc:OntologyClass [] ['second-order administrative region', 'second level subdivision', 'countries, 2nd order division', 'second-order administrative division'] A subdivision of a first-order administrative division. []\n",
"\u001b[KENVO:00000007 ENVO:00000007 nmdc:OntologyClass [] :\u001b[K"
]
}
],
"source": [
"!less /Users/SMoxon/Documents/src/nmdc-runtime/docs/nb/ontology_reports/ontology_updates.tsv"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "afb486ca-d4e4-407b-bbbf-b25013404bd0",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2025-03-05 12:49:55,431 - INFO - MongoDB connection string: mongodb://admin:root@localhost:27018/nmdc?authSource=admin\n",
"2025-03-05 12:49:55,433 - INFO - Initializing databases\n",
"2025-03-05 12:49:55,434 - INFO - Attaching mongodb://admin:root@localhost:27018/nmdc?authSource=admin\n",
"2025-03-05 12:49:55,434 - INFO - Connected to MongoDB: <linkml_store.api.stores.mongodb.mongodb_database.MongoDBDatabase object at 0x126e00650>\n"
]
}
],
"source": [
"from ontology_loader.mongodb_loader import MongoDBLoader\n",
"from ontology_loader.utils import load_yaml_from_package\n",
"\n",
"nmdc_sv = load_yaml_from_package(\"nmdc_schema\", \"nmdc_materialized_patterns.yaml\")\n",
"mdb = MongoDBLoader(schema_view=nmdc_sv)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "5514315c-54c4-4b48-a770-c944cde521fc",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"mongodb://admin:root@localhost:27018/nmdc?authSource=admin\n"
]
}
],
"source": [
"print(mdb.client.handle)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "a30f1903-da45-4b24-a6e3-e119691d1a78",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"first ontology_class_set rows: {'id': 'ENVO:00000001', 'type': 'nmdc:OntologyClass', 'name': None, 'description': None, 'alternative_identifiers': [], 'alternative_names': ['bedding-plane cave'], 'definition': 'A cavity developed along a bedding-plane and elongate in cross-section as a result.', 'relations': []}\n",
"{'id': 'ENVO:00000001', 'type': 'nmdc:OntologyClass', 'name': None, 'description': None, 'alternative_identifiers': [], 'alternative_names': ['bedding-plane cave'], 'definition': 'A cavity developed along a bedding-plane and elongate in cross-section as a result.', 'relations': []}\n",
"number of ontology_relation_set rows: 1852298\n",
"first ontology_relation_set rows: {'type': 'nmdc:OntologyRelation', 'subject': 'ENVO:00000000', 'predicate': 'is_a', 'object': 'ENVO:01000813'}\n"
]
}
],
"source": [
"database = mdb.client.get_database()\n",
"ontology_class_set = database.get_collection(\"ontology_class_set\")\n",
"qr = ontology_class_set.find()\n",
"print(\"first ontology_class_set rows: \", qr.rows[1])\n",
"print(qr.rows[1])\n",
"\n",
"ontology_relation_set = database.get_collection(\"ontology_relation_set\")\n",
"qr = ontology_relation_set.find()\n",
"print(\"number of ontology_relation_set rows: \", qr.num_rows)\n",
"print(\"first ontology_relation_set rows: \", qr.rows[1])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a296e178-2824-479e-b377-40e566dbb89e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "08f3ded2-6957-401a-a1a6-db48a41781fa",
"metadata": {},
"outputs": [],
"source": []
}
Expand Down

0 comments on commit a445ef4

Please sign in to comment.