This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 0492c29
Showing
17 changed files
with
18,237 additions
and
0 deletions.
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,18 @@ | ||
__pycache__/ | ||
|
||
*.egg-info/ | ||
.eggs/* | ||
|
||
.ipynb_checkpoints/ | ||
|
||
higlass_widget/_version.py | ||
|
||
node_modules/ | ||
|
||
higlass_widget/nbextension/widget.js | ||
higlass_widget/nbextension/widget.css | ||
|
||
higlass_widget/labextension/package.json | ||
higlass_widget/labextension/static/* | ||
|
||
dist/ |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Trevor James Manz | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,29 @@ | ||
# higlass-widget | ||
|
||
``` | ||
pip install higlass-widget | ||
``` | ||
|
||
### Development | ||
|
||
```bash | ||
pip install -e . | ||
``` | ||
|
||
If you are using the classic Jupyter Notebook you need to install the nbextension: | ||
|
||
```bash | ||
jupyter nbextension install --py --symlink --sys-prefix higlass_widget | ||
jupyter nbextension enable --py --sys-prefix higlass_widget | ||
``` | ||
|
||
Note for developers: | ||
|
||
- the `-e` pip option allows one to modify the Python code in-place. Restart the kernel in order to see the changes. | ||
- the `--symlink` argument on Linux or OS X allows one to modify the JavaScript code in-place. This feature is not available with Windows. | ||
|
||
For developing with JupyterLab: | ||
|
||
``` | ||
jupyter labextension develop --overwrite higlass_widget | ||
``` |
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,5 @@ | ||
{ | ||
"load_extensions": { | ||
"higlass-widget/extension": true | ||
} | ||
} |
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,31 @@ | ||
import sys | ||
|
||
try: | ||
from ._version import version as __version__ | ||
except ImportError: | ||
__version__ = "unknown" | ||
|
||
try: | ||
if "google.colab" in sys.modules: | ||
from google.colab import output | ||
|
||
output.enable_custom_widget_manager() | ||
except ImportError: | ||
pass | ||
|
||
from .widget import HiGlassWidget | ||
|
||
|
||
def _jupyter_labextension_paths(): | ||
return [{"src": "labextension", "dest": "higlass-widget"}] | ||
|
||
|
||
def _jupyter_nbextension_paths(): | ||
return [ | ||
{ | ||
"section": "notebook", | ||
"src": "nbextension", | ||
"dest": "higlass-widget", | ||
"require": "higlass-widget/extension", | ||
} | ||
] |
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,15 @@ | ||
// Entry point for the notebook bundle containing custom model definitions. | ||
define(function() { | ||
"use strict"; | ||
window.requirejs?.config({ | ||
map: { | ||
'*': { | ||
'higlass-widget': 'nbextensions/higlass-widget/index', | ||
}, | ||
} | ||
}) | ||
// Export the required load_ipython_extension function | ||
return { | ||
load_ipython_extension: function() {} | ||
}; | ||
}); |
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,28 @@ | ||
// Be careful editing the contents of this file! | ||
|
||
/** @param {URL} url */ | ||
function loadCss(url) { | ||
var link = document.createElement("link"); | ||
link.type = "text/css"; | ||
link.rel = "stylesheet"; | ||
link.href = url.href; | ||
document.getElementsByTagName("head")[0].appendChild(link); | ||
} | ||
|
||
define(["@jupyter-widgets/base", "module"], function (base, module) { | ||
let baseUrl; | ||
|
||
try { | ||
// from CDN | ||
baseUrl = new URL(module.uri); | ||
} catch { | ||
// relative to localhost | ||
baseUrl = new URL(module.uri, document.baseURI); | ||
} | ||
|
||
let js = new URL("widget.js", baseUrl); | ||
let css = new URL("widget.css", baseUrl); | ||
|
||
loadCss(css); | ||
return import(js.href).then(mod => mod.default(base)); | ||
}) |
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,41 @@ | ||
import json | ||
from typing import Any, Dict | ||
|
||
import ipywidgets | ||
import traitlets.traitlets as t | ||
|
||
from ._version import version | ||
|
||
|
||
class HiGlassWidget(ipywidgets.DOMWidget): | ||
_model_name = t.Unicode("HiGlassModel").tag(sync=True) | ||
_model_module = t.Unicode("higlass-widget").tag(sync=True) | ||
_model_module_version = t.Unicode(version).tag(sync=True) | ||
|
||
_view_name = t.Unicode("HiGlassView").tag(sync=True) | ||
_view_module = t.Unicode("higlass-widget").tag(sync=True) | ||
_view_module_version = t.Unicode(version).tag(sync=True) | ||
|
||
_viewconf = t.Unicode("null").tag(sync=True) | ||
|
||
# readonly properties | ||
location = t.List(t.Union([t.Float(), t.Tuple()]), read_only=True).tag(sync=True) | ||
|
||
def __init__(self, viewconf: Dict[str, Any], **kwargs): | ||
super().__init__(_viewconf=json.dumps(viewconf), **kwargs) | ||
|
||
def reload(self, *items): | ||
msg = json.dumps(["reload", items]) | ||
self.send(msg) | ||
|
||
def zoom_to( | ||
self, | ||
view_id: str, | ||
start1: int, | ||
end1: int, | ||
start2: int = None, | ||
end2: int = None, | ||
animate_time: int = 500, | ||
): | ||
msg = json.dumps(["zoomTo", view_id, start1, end1, start2, end2, animate_time]) | ||
self.send(msg) |
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,71 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e5a27ac0", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import json\n", | ||
"\n", | ||
"from higlass_widget import HiGlassWidget\n", | ||
"\n", | ||
"with open(\"example.json\") as f:\n", | ||
" conf = json.load(f)\n", | ||
" \n", | ||
"w = HiGlassWidget(conf)\n", | ||
"w" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "919293e1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"w.zoom_to(\"aa\", 10000, 1000000)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "f5318b01", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"w.location" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "42f046a2", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.