mc-react-structure-visualizer 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/StructureWindow/3dmol/Visualizer3dmol.js +32 -4
- package/dist/StructureWindow/3dmol/bondLengths.js +107 -0
- package/dist/StructureWindow/index.js +3 -2
- package/package.json +2 -2
- package/src/App.js +4 -0
- package/src/StructureVisualizer/StructureWindow/3dmol/Visualizer3dmol.js +36 -4
- package/src/StructureVisualizer/StructureWindow/3dmol/bondLengths.js +100 -0
- package/src/StructureVisualizer/StructureWindow/index.js +2 -5
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var $3Dmol = _interopRequireWildcard(require("3dmol"));
|
|
10
|
+
var _bondLengths = require("./bondLengths");
|
|
10
11
|
require("./Visualizer3dmol.css");
|
|
11
|
-
var _utils = require("@testing-library/user-event/dist/utils");
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -24,6 +24,32 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
24
24
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
25
25
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
26
26
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
27
|
+
// override the covalent bond detection based on examples in MC3D
|
|
28
|
+
var overrideBondLengths = {
|
|
29
|
+
// uuid = "aaea1e0f-337c-453f-a23a-acc06ddc93c9"; // BaTiO3 mc3d-46554/pbe
|
|
30
|
+
Ba: 0.92 * _bondLengths.covalentRadii["Ba"],
|
|
31
|
+
Ti: 0.94 * _bondLengths.covalentRadii["Ti"],
|
|
32
|
+
// uuid = "a490b0ff-012a-44c8-a48a-f734dc634b3c"; // EuI4La mc3d-34858/pbe
|
|
33
|
+
I: 1.05 * _bondLengths.covalentRadii["I"],
|
|
34
|
+
Eu: 1.05 * _bondLengths.covalentRadii["Eu"]
|
|
35
|
+
};
|
|
36
|
+
function setCustomBondLengths() {
|
|
37
|
+
function setCustomBondLength(elem, len) {
|
|
38
|
+
// 3dmol adds 0.25 to the total bond length as a "fudge_factor"
|
|
39
|
+
var fudgeCorrection = 0.125;
|
|
40
|
+
$3Dmol.setBondLength(elem, len - fudgeCorrection);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// override the default bond lengths with covalentRadii
|
|
44
|
+
Object.keys(_bondLengths.covalentRadii).forEach(function (elem) {
|
|
45
|
+
setCustomBondLength(elem, _bondLengths.covalentRadii[elem]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// override further based on custom-defined lengths
|
|
49
|
+
Object.keys(overrideBondLengths).forEach(function (elem) {
|
|
50
|
+
setCustomBondLength(elem, overrideBondLengths[elem]);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
27
53
|
var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
28
54
|
_inherits(Visualizer3dmol, _React$Component);
|
|
29
55
|
var _super = _createSuper(Visualizer3dmol);
|
|
@@ -31,6 +57,7 @@ var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
|
31
57
|
var _this;
|
|
32
58
|
_classCallCheck(this, Visualizer3dmol);
|
|
33
59
|
_this = _super.call(this, props);
|
|
60
|
+
setCustomBondLengths();
|
|
34
61
|
_this.viewer = null;
|
|
35
62
|
_this.model = null;
|
|
36
63
|
|
|
@@ -91,11 +118,12 @@ var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
|
91
118
|
y: atom.y,
|
|
92
119
|
z: atom.z
|
|
93
120
|
},
|
|
94
|
-
fontColor:
|
|
121
|
+
fontColor: "black",
|
|
122
|
+
bold: true,
|
|
95
123
|
fontSize: 18,
|
|
96
124
|
showBackground: false,
|
|
97
|
-
backgroundOpacity: 0
|
|
98
|
-
inFront:
|
|
125
|
+
backgroundOpacity: 1.0,
|
|
126
|
+
inFront: true
|
|
99
127
|
}, null, true);
|
|
100
128
|
});
|
|
101
129
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.covalentRadii = void 0;
|
|
7
|
+
// from https://en.wikipedia.org/wiki/Covalent_radius
|
|
8
|
+
// unit: angstrom
|
|
9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
|
+
I: 1.39,
|
|
63
|
+
Xe: 1.4,
|
|
64
|
+
Cs: 2.44,
|
|
65
|
+
Ba: 2.15,
|
|
66
|
+
La: 2.07,
|
|
67
|
+
Ce: 2.04,
|
|
68
|
+
Pr: 2.03,
|
|
69
|
+
Nd: 2.01,
|
|
70
|
+
Pm: 1.99,
|
|
71
|
+
Sm: 1.98,
|
|
72
|
+
Eu: 1.98,
|
|
73
|
+
Gd: 1.96,
|
|
74
|
+
Tb: 1.94,
|
|
75
|
+
Dy: 1.92,
|
|
76
|
+
Ho: 1.92,
|
|
77
|
+
Er: 1.89,
|
|
78
|
+
Tm: 1.9,
|
|
79
|
+
Yb: 1.87,
|
|
80
|
+
Lu: 1.75,
|
|
81
|
+
Hf: 1.87,
|
|
82
|
+
Ta: 1.7,
|
|
83
|
+
W: 1.62,
|
|
84
|
+
Re: 1.51,
|
|
85
|
+
Os: 1.44,
|
|
86
|
+
Ir: 1.41,
|
|
87
|
+
Pt: 1.36,
|
|
88
|
+
Au: 1.36,
|
|
89
|
+
Hg: 1.32,
|
|
90
|
+
Tl: 1.45,
|
|
91
|
+
Pb: 1.46,
|
|
92
|
+
Bi: 1.48,
|
|
93
|
+
Po: 1.4,
|
|
94
|
+
At: 1.5,
|
|
95
|
+
Rn: 1.5,
|
|
96
|
+
Fr: 2.6,
|
|
97
|
+
Ra: 2.21,
|
|
98
|
+
Ac: 2.15,
|
|
99
|
+
Th: 2.06,
|
|
100
|
+
Pa: 2.0,
|
|
101
|
+
U: 1.96,
|
|
102
|
+
Np: 1.9,
|
|
103
|
+
Pu: 1.87,
|
|
104
|
+
Am: 1.8,
|
|
105
|
+
Cm: 1.69
|
|
106
|
+
};
|
|
107
|
+
exports.covalentRadii = covalentRadii;
|
|
@@ -40,8 +40,9 @@ var StructureWindow = /*#__PURE__*/function (_React$Component) {
|
|
|
40
40
|
mouseNoteText = "Interaction on";
|
|
41
41
|
mouseNoteClass = "mouse-disabled-note on";
|
|
42
42
|
}
|
|
43
|
-
return /*#__PURE__*/_react["default"].createElement("div",
|
|
44
|
-
className: "structure-window-outer"
|
|
43
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
44
|
+
className: "structure-window-outer"
|
|
45
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
45
46
|
onClick: function onClick() {
|
|
46
47
|
return _this.props.setMouseEnabledState(true);
|
|
47
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mc-react-structure-visualizer",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"author": "Kristjan Eimre <kristjan.eimre@epfl.ch>",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@testing-library/jest-dom": "^5.16.5",
|
|
15
15
|
"@testing-library/react": "^13.4.0",
|
|
16
16
|
"@testing-library/user-event": "^13.5.0",
|
|
17
|
-
"3dmol": "^2.0.
|
|
17
|
+
"3dmol": "^2.0.2",
|
|
18
18
|
"bootstrap": "^5.2.3",
|
|
19
19
|
"react": "^18.2.0",
|
|
20
20
|
"react-bootstrap": "^2.7.1",
|
package/src/App.js
CHANGED
|
@@ -11,6 +11,10 @@ async function fetchCif() {
|
|
|
11
11
|
// Fetch a cif file from the Materials Cloud AiiDA rest api
|
|
12
12
|
const aiidaRestEndpoint = "https://aiida.materialscloud.org/mc3d/api/v4";
|
|
13
13
|
const uuid = "85260507-9cb4-4849-a10d-703f32697dd7";
|
|
14
|
+
//const uuid = "07e48338-e639-485c-bed0-5f23bf6cfae2"; // Ag
|
|
15
|
+
//const uuid = "e36f52ac-0f64-47eb-86eb-550608c8672c"; // BN mc3d-66325/pbe
|
|
16
|
+
//const uuid = "aaea1e0f-337c-453f-a23a-acc06ddc93c9"; // BaTiO3 mc3d-46554/pbe
|
|
17
|
+
//const uuid = "a490b0ff-012a-44c8-a48a-f734dc634b3c"; // EuI4La mc3d-34858/pbe
|
|
14
18
|
|
|
15
19
|
const responseAiiDACif = await fetch(
|
|
16
20
|
`${aiidaRestEndpoint}/nodes/${uuid}/download?download_format=cif&download=false`
|
|
@@ -2,13 +2,44 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import * as $3Dmol from "3dmol";
|
|
4
4
|
|
|
5
|
+
import { covalentRadii } from "./bondLengths";
|
|
6
|
+
|
|
5
7
|
import "./Visualizer3dmol.css";
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
// override the covalent bond detection based on examples in MC3D
|
|
10
|
+
const overrideBondLengths = {
|
|
11
|
+
// uuid = "aaea1e0f-337c-453f-a23a-acc06ddc93c9"; // BaTiO3 mc3d-46554/pbe
|
|
12
|
+
Ba: 0.92 * covalentRadii["Ba"],
|
|
13
|
+
Ti: 0.94 * covalentRadii["Ti"],
|
|
14
|
+
// uuid = "a490b0ff-012a-44c8-a48a-f734dc634b3c"; // EuI4La mc3d-34858/pbe
|
|
15
|
+
I: 1.05 * covalentRadii["I"],
|
|
16
|
+
Eu: 1.05 * covalentRadii["Eu"],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function setCustomBondLengths() {
|
|
20
|
+
function setCustomBondLength(elem, len) {
|
|
21
|
+
// 3dmol adds 0.25 to the total bond length as a "fudge_factor"
|
|
22
|
+
let fudgeCorrection = 0.125;
|
|
23
|
+
$3Dmol.setBondLength(elem, len - fudgeCorrection);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// override the default bond lengths with covalentRadii
|
|
27
|
+
Object.keys(covalentRadii).forEach((elem) => {
|
|
28
|
+
setCustomBondLength(elem, covalentRadii[elem]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// override further based on custom-defined lengths
|
|
32
|
+
Object.keys(overrideBondLengths).forEach((elem) => {
|
|
33
|
+
setCustomBondLength(elem, overrideBondLengths[elem]);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
7
36
|
|
|
8
37
|
class Visualizer3dmol extends React.Component {
|
|
9
38
|
constructor(props) {
|
|
10
39
|
super(props);
|
|
11
40
|
|
|
41
|
+
setCustomBondLengths();
|
|
42
|
+
|
|
12
43
|
this.viewer = null;
|
|
13
44
|
this.model = null;
|
|
14
45
|
|
|
@@ -62,11 +93,12 @@ class Visualizer3dmol extends React.Component {
|
|
|
62
93
|
atom.elem,
|
|
63
94
|
{
|
|
64
95
|
position: { x: atom.x, y: atom.y, z: atom.z },
|
|
65
|
-
fontColor:
|
|
96
|
+
fontColor: "black",
|
|
97
|
+
bold: true,
|
|
66
98
|
fontSize: 18,
|
|
67
99
|
showBackground: false,
|
|
68
|
-
backgroundOpacity: 0
|
|
69
|
-
inFront:
|
|
100
|
+
backgroundOpacity: 1.0,
|
|
101
|
+
inFront: true,
|
|
70
102
|
},
|
|
71
103
|
null,
|
|
72
104
|
true
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// from https://en.wikipedia.org/wiki/Covalent_radius
|
|
2
|
+
// unit: angstrom
|
|
3
|
+
export const covalentRadii = {
|
|
4
|
+
H: 0.31,
|
|
5
|
+
He: 0.28,
|
|
6
|
+
Li: 1.28,
|
|
7
|
+
Be: 0.96,
|
|
8
|
+
B: 0.84,
|
|
9
|
+
C: 0.76,
|
|
10
|
+
N: 0.71,
|
|
11
|
+
O: 0.66,
|
|
12
|
+
F: 0.57,
|
|
13
|
+
Ne: 0.58,
|
|
14
|
+
Na: 1.66,
|
|
15
|
+
Mg: 1.41,
|
|
16
|
+
Al: 1.21,
|
|
17
|
+
Si: 1.11,
|
|
18
|
+
P: 1.07,
|
|
19
|
+
S: 1.05,
|
|
20
|
+
Cl: 1.02,
|
|
21
|
+
Ar: 1.06,
|
|
22
|
+
K: 2.03,
|
|
23
|
+
Ca: 1.76,
|
|
24
|
+
Sc: 1.7,
|
|
25
|
+
Ti: 1.6,
|
|
26
|
+
V: 1.53,
|
|
27
|
+
Cr: 1.39,
|
|
28
|
+
Mn: 1.61,
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|
81
|
+
Pt: 1.36,
|
|
82
|
+
Au: 1.36,
|
|
83
|
+
Hg: 1.32,
|
|
84
|
+
Tl: 1.45,
|
|
85
|
+
Pb: 1.46,
|
|
86
|
+
Bi: 1.48,
|
|
87
|
+
Po: 1.4,
|
|
88
|
+
At: 1.5,
|
|
89
|
+
Rn: 1.5,
|
|
90
|
+
Fr: 2.6,
|
|
91
|
+
Ra: 2.21,
|
|
92
|
+
Ac: 2.15,
|
|
93
|
+
Th: 2.06,
|
|
94
|
+
Pa: 2.0,
|
|
95
|
+
U: 1.96,
|
|
96
|
+
Np: 1.9,
|
|
97
|
+
Pu: 1.87,
|
|
98
|
+
Am: 1.8,
|
|
99
|
+
Cm: 1.69,
|
|
100
|
+
};
|
|
@@ -20,11 +20,8 @@ class StructureWindow extends React.Component {
|
|
|
20
20
|
mouseNoteClass = "mouse-disabled-note on";
|
|
21
21
|
}
|
|
22
22
|
return (
|
|
23
|
-
<div>
|
|
24
|
-
<div
|
|
25
|
-
className="structure-window-outer"
|
|
26
|
-
onClick={() => this.props.setMouseEnabledState(true)}
|
|
27
|
-
>
|
|
23
|
+
<div className="structure-window-outer">
|
|
24
|
+
<div onClick={() => this.props.setMouseEnabledState(true)}>
|
|
28
25
|
<div className={swClassName}>
|
|
29
26
|
<Visualizer3dmol
|
|
30
27
|
ref={this.props.visualizerRef}
|