Skip to content

Commit

Permalink
1.1.2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
everburstSun committed Feb 22, 2024
1 parent aacb984 commit 573b4ef
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 42 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# dash-molstar Changelog

## [1.1.2] - 2024-02-22
### Bug fixes
- Fixed the problem when loading multiple structures with components.

## [1.1.1] - 2023-09-30
### Bug fixes
- Fixed the problem when selected only one target, the plugin would fail.
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dashMolstar
Title: The molstar plugin for plotly dash framework
Version: 1.1.1
Version: 1.1.2
Description: The molstar plugin for plotly dash framework
Depends: R (>= 3.0.2)
Imports:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "DashMolstar"
uuid = "1b08a953-4be3-4667-9a23-14ed597df146"
authors = ["SimonSun <[email protected]>"]
version = "1.1.1"
version = "1.1.2"

[deps]
Dash = "1b08a953-4be3-4667-9a23-3db579824955"
Expand Down
6 changes: 3 additions & 3 deletions R/internal.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.dashMolstar_js_metadata <- function() {
deps_metadata <- list(`dash_molstar` = structure(list(name = "dash_molstar",
version = "1.1.1", src = list(href = NULL,
version = "1.1.2", src = list(href = NULL,
file = "deps"), meta = NULL,
script = 'rcsb-molstar.js',
stylesheet = NULL, head = NULL, attachment = NULL, package = "dashMolstar",
all_files = FALSE), class = "html_dependency"),
`dash_molstar` = structure(list(name = "dash_molstar",
version = "1.1.1", src = list(href = NULL,
version = "1.1.2", src = list(href = NULL,
file = "deps"), meta = NULL,
script = 'dash_molstar.min.js',
stylesheet = NULL, head = NULL, attachment = NULL, package = "dashMolstar",
all_files = FALSE), class = "html_dependency"),
`dash_molstar` = structure(list(name = "dash_molstar",
version = "1.1.1", src = list(href = NULL,
version = "1.1.2", src = list(href = NULL,
file = "deps"), meta = NULL,
script = 'dash_molstar.min.js.map',
stylesheet = NULL, head = NULL, attachment = NULL, package = "dashMolstar",
Expand Down
2 changes: 1 addition & 1 deletion dash_molstar/dash_molstar.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_molstar/package-info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash_molstar",
"version": "1.1.1",
"version": "1.1.2",
"description": "The molstar plugin for plotly dash framework",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash_molstar",
"version": "1.1.1",
"version": "1.1.2",
"description": "The molstar plugin for plotly dash framework",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/DashMolstar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module DashMolstar
using Dash

const resources_path = realpath(joinpath( @__DIR__, "..", "deps"))
const version = "1.1.1"
const version = "1.1.2"

include("jl/molstarviewer.jl")

Expand Down
79 changes: 48 additions & 31 deletions src/lib/components/MolstarViewer.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class MolstarViewer extends Component {
if (model_index >= 0) {
const id = this.viewer._plugin.managers.structure.hierarchy.current.structures[model_index].cell.obj.data.units[0].model.id;
const targets = [];
if (selection.targets) {
if (selection.targets && selection.targets[0] !== null) {
// convert data from python to molstar data structure
for (let target of selection.targets) {
const newTarget = {
Expand All @@ -122,7 +122,7 @@ export default class MolstarViewer extends Component {
if (model_index >= 0) {
const id = this.viewer._plugin.managers.structure.hierarchy.current.structures[model_index].cell.obj.data.units[0].model.id;
const targets = [];
if (focus.targets) {
if (focus.targets && focus.targets[0] !== null) {
// convert data from python to molstar data structure
for (let target of focus.targets) {
const newTarget = {
Expand All @@ -146,24 +146,47 @@ export default class MolstarViewer extends Component {
}
loadData(data) {
if (typeof data === "object") {
if (data.type === "mol") {
// first load the structure into viewer
this.viewer.loadStructureFromData(data.data, data.format, false).then(() => {
if (data.type === "mol") { // loading a structure
const model_index = Object.keys(this.loadedStructures).length + 1;
this.loadedStructures[model_index] = null;
this.viewer.loadStructureFromData(data.data, data.format, false).then((result) => {
// add the structure ID to this.loadedStructures
this.loadedStructures[model_index] = result.structure.cell.obj.data.units[0].model.id;
// if user specified component(s), add them to the structure
if (data.hasOwnProperty('component')) {
// binding structure ID to component
if (Array.isArray(data.component)) {
data.component.forEach((component) => {
component.modelId = this.loadedStructures[model_index];
});
} else if (typeof data.component === "object") {
data.component.modelId = this.loadedStructures[model_index];
}
console.log(data.component)
this.handleComponentChange(data.component);
}
});
} else if (data.type === 'url') {
} else if (data.type === 'url') { // loading a URL
// load url for molecules
if (data.urlfor === 'mol') {
this.viewer.loadStructureFromUrl(data.data, data.format, false).then(() => {
if (data.urlfor === 'mol') { // loading a structure from URL
const model_index = Object.keys(this.loadedStructures).length + 1;
this.loadedStructures[model_index] = null;
this.viewer.loadStructureFromUrl(data.data, data.format, false).then((result) => {
// add the structure ID to this.loadedStructures
this.loadedStructures[model_index] = result.structure.cell.obj.data.units[0].model.id;
if (data.hasOwnProperty('component')) {
// binding structure ID to component
if (Array.isArray(data.component)) {
data.component.forEach((component) => {
component.modelId = this.loadedStructures[model_index];
});
} else if (typeof data.component === "object") {
data.component.modelId = this.loadedStructures[model_index];
}
this.handleComponentChange(data.component);
}
});
} else {
// load url for molstar snapshot file
} else { // load url for molstar snapshot file
this.viewer.loadSnapshotFromUrl(data.data, data.format);
}
} else if (data.type === 'shape') {
Expand All @@ -188,30 +211,24 @@ export default class MolstarViewer extends Component {
}//);
}
addComponent(component) {
// check if there was any structure loaded in the viewer
const model_index = this.viewer._plugin.managers.structure.hierarchy.current.structures.length - 1;
if (model_index >= 0) {
// get molstar internal structure ID for the last loaded model
const id = this.viewer._plugin.managers.structure.hierarchy.current.structures[model_index].cell.obj.data.units[0].model.id;
// construct molstar target object from python helper data
const targets = [];
for (let target of component.targets) {
const newTarget = {
modelId: id,
...target.author ? {authAsymId: target.chain_name} : {labelAsymId: target.chain_name},
}
// check if any residue number has been selected
if (target.hasOwnProperty('residue_numbers')) {
if (target.author) {
newTarget.authSeqId = target.residue_numbers;
} else {
newTarget.labelSeqId = target.residue_numbers;
}
// construct molstar target object from python helper data
const targets = [];
for (let target of component.targets) {
const newTarget = {
modelId: component.modelId,
...target.auth ? {authAsymId: target.chain_name} : {labelAsymId: target.chain_name},
}
// check if any residue number has been selected
if (target.hasOwnProperty('residue_numbers')) {
if (target.auth) {
newTarget.authSeqId = target.residue_numbers;
} else {
newTarget.labelSeqId = target.residue_numbers;
}
targets.push(newTarget);
}
this.viewer.createComponent(component.label, targets, component.representation);
targets.push(newTarget);
}
this.viewer.createComponent(component.label, targets, component.representation);
}
componentDidMount() {
if (this.viewerRef.current) {
Expand Down

0 comments on commit 573b4ef

Please sign in to comment.