-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ga4gh.core import ga4gh_identify\n", | ||
"from ga4gh.vrs import models" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cpb = models.CisPhasedBlock(\n", | ||
" members=[\n", | ||
" models.Allele(\n", | ||
" location=models.SequenceLocation(start=1, end=2),\n", | ||
" state=models.LiteralSequenceExpression(sequence=\"C\")\n", | ||
" ),\n", | ||
" models.Allele(\n", | ||
" location=models.SequenceLocation(start=3, end=4),\n", | ||
" state=models.LiteralSequenceExpression(sequence=\"T\")\n", | ||
" )\n", | ||
" ],\n", | ||
" sequenceReference=models.SequenceReference(\n", | ||
" refgetAccession=\"SQ.S_KjnFVz-FE7M0W6yoaUDgYxLPc1jyWU\"\n", | ||
" )\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 18, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "AttributeError", | ||
"evalue": "This class does not support prior version identifiers.", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", | ||
"File \u001b[0;32m~/Documents/git/ga4gh/vrs-python/src/ga4gh/vrs/models.py:245\u001b[0m, in \u001b[0;36m_Ga4ghIdentifiableObject.compute_digest\u001b[0;34m(self, store, as_version)\u001b[0m\n\u001b[1;32m 244\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 245\u001b[0m digest \u001b[38;5;241m=\u001b[39m sha512t24u(\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mga4gh_serialize_as_version\u001b[49m(as_version)\u001b[38;5;241m.\u001b[39mencode(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mutf-8\u001b[39m\u001b[38;5;124m\"\u001b[39m))\n\u001b[1;32m 246\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mAttributeError\u001b[39;00m:\n", | ||
"File \u001b[0;32m~/Documents/git/ga4gh/vrs-python/venv/lib/python3.10/site-packages/pydantic/main.py:828\u001b[0m, in \u001b[0;36mBaseModel.__getattr__\u001b[0;34m(self, item)\u001b[0m\n\u001b[1;32m 826\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 827\u001b[0m \u001b[38;5;66;03m# this is the current error\u001b[39;00m\n\u001b[0;32m--> 828\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mAttributeError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mtype\u001b[39m(\u001b[38;5;28mself\u001b[39m)\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m!r}\u001b[39;00m\u001b[38;5;124m object has no attribute \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mitem\u001b[38;5;132;01m!r}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n", | ||
"\u001b[0;31mAttributeError\u001b[0m: 'CisPhasedBlock' object has no attribute 'ga4gh_serialize_as_version'", | ||
"\nDuring handling of the above exception, another exception occurred:\n", | ||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[0;32mIn[18], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mga4gh_identify\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcpb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mas_version\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m1.3\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", | ||
"File \u001b[0;32m~/Documents/git/ga4gh/vrs-python/src/ga4gh/core/identifiers.py:165\u001b[0m, in \u001b[0;36mga4gh_identify\u001b[0;34m(vro, in_place, as_version)\u001b[0m\n\u001b[1;32m 162\u001b[0m do_compute \u001b[38;5;241m=\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m vro\u001b[38;5;241m.\u001b[39mhas_valid_ga4gh_id()\n\u001b[1;32m 164\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m do_compute:\n\u001b[0;32m--> 165\u001b[0m obj_id \u001b[38;5;241m=\u001b[39m \u001b[43mvro\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_or_create_ga4gh_identifier\u001b[49m\u001b[43m(\u001b[49m\u001b[43min_place\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mas_version\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mas_version\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 167\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m obj_id\n\u001b[1;32m 169\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n", | ||
"File \u001b[0;32m~/Documents/git/ga4gh/vrs-python/src/ga4gh/vrs/models.py:270\u001b[0m, in \u001b[0;36m_Ga4ghIdentifiableObject.get_or_create_ga4gh_identifier\u001b[0;34m(self, in_place, recompute, as_version)\u001b[0m\n\u001b[1;32m 251\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Sets and returns a GA4GH Computed Identifier for the object.\u001b[39;00m\n\u001b[1;32m 252\u001b[0m \u001b[38;5;124;03mOverwrites the existing identifier if overwrite is True.\u001b[39;00m\n\u001b[1;32m 253\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 267\u001b[0m \u001b[38;5;124;03mthe VRS version indicated by 'as_version'.\u001b[39;00m\n\u001b[1;32m 268\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 269\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m as_version \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 270\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcompute_ga4gh_identifier\u001b[49m\u001b[43m(\u001b[49m\u001b[43mas_version\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mas_version\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 272\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m in_place \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdefault\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[1;32m 273\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mid \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n", | ||
"File \u001b[0;32m~/Documents/git/ga4gh/vrs-python/src/ga4gh/vrs/models.py:298\u001b[0m, in \u001b[0;36m_Ga4ghIdentifiableObject.compute_ga4gh_identifier\u001b[0;34m(self, recompute, as_version)\u001b[0m\n\u001b[1;32m 296\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mCURIE_NAMESPACE\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mCURIE_SEP\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mga4gh\u001b[38;5;241m.\u001b[39mprefix\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mGA4GH_PREFIX_SEP\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdigest\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 297\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 298\u001b[0m digest \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcompute_digest\u001b[49m\u001b[43m(\u001b[49m\u001b[43mas_version\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mas_version\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 299\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mCURIE_NAMESPACE\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mCURIE_SEP\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mga4gh\u001b[38;5;241m.\u001b[39mpriorPrefix[as_version]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mGA4GH_PREFIX_SEP\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00mdigest\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\n", | ||
"File \u001b[0;32m~/Documents/git/ga4gh/vrs-python/src/ga4gh/vrs/models.py:247\u001b[0m, in \u001b[0;36m_Ga4ghIdentifiableObject.compute_digest\u001b[0;34m(self, store, as_version)\u001b[0m\n\u001b[1;32m 245\u001b[0m digest \u001b[38;5;241m=\u001b[39m sha512t24u(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mga4gh_serialize_as_version(as_version)\u001b[38;5;241m.\u001b[39mencode(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mutf-8\u001b[39m\u001b[38;5;124m\"\u001b[39m))\n\u001b[1;32m 246\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mAttributeError\u001b[39;00m:\n\u001b[0;32m--> 247\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mAttributeError\u001b[39;00m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mThis class does not support prior version identifiers.\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 248\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m digest\n", | ||
"\u001b[0;31mAttributeError\u001b[0m: This class does not support prior version identifiers." | ||
] | ||
} | ||
], | ||
"source": [ | ||
"ga4gh_identify(cpb, as_version=\"1.3\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'ga4gh:SL.aoRy21xCtDozd151eDZmVTm6cejLNxt9'" | ||
] | ||
}, | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"ga4gh_identify(sl)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.14" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters