@intact-ebi/cytoscape-lumina 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 EMBL-EBI
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # LUMINA:
2
+
3
+ ## Usage
4
+
5
+ ### Installation
6
+
7
+ ```zsh
8
+ npm install @intact-portal/sub-structure-cyto-layout cytoscape
9
+ ```
10
+
11
+ ### Minimal import
12
+
13
+ ```js
14
+ import cytoscape from 'cytoscape';
15
+ import registerSubstructureLayout from '@intact-portal/sub-structure-cyto-layout';
16
+
17
+ registerSubstructureLayout(cytoscape);
18
+
19
+ const cy = cytoscape({
20
+ container: document.getElementById('cy'),
21
+ elements
22
+ });
23
+
24
+ cy.layout({
25
+ name: 'substructure-layout'
26
+ }).run();
27
+ ```
28
+
29
+ ### Demo project
30
+
31
+ ```js
32
+ <!doctype html>
33
+ <html lang="en">
34
+ <head>
35
+ <meta charset="utf-8">
36
+ <meta name="viewport" content="width=device-width, initial-scale=1">
37
+ <title>Cytoscape LUMINA demo</title>
38
+ <style>
39
+ html,
40
+ body {
41
+ height: 100%;
42
+ margin: 0;
43
+ font-family: system-ui, sans-serif;
44
+ }
45
+
46
+ body {
47
+ display: grid;
48
+ grid-template-rows: auto 1fr;
49
+ }
50
+ </style>
51
+
52
+ <script type="importmap">
53
+ {
54
+ "imports": {
55
+ "cytoscape": "./node_modules/cytoscape/dist/cytoscape.esm.min.mjs",
56
+ "@intact-ebi/cytoscape-lumina": "./node_modules/@intact-ebi/cytoscape-lumina/dist/index.js"
57
+ }
58
+ }
59
+ </script>
60
+ </head>
61
+ <body>
62
+ <header>
63
+ <h1>LUMINA layout demo</h1>
64
+ </header>
65
+ <main id="cy" aria-label="Interactive network graph"></main>
66
+
67
+ <script type="module">
68
+ import cytoscape from 'cytoscape';
69
+ import registerSubstructureLayout from '@intact-ebi/cytoscape-lumina';
70
+
71
+ registerSubstructureLayout(cytoscape);
72
+
73
+ const elements = [
74
+ { data: { id: 'a' } },
75
+ { data: { id: 'b' } },
76
+ { data: { id: 'c' } },
77
+ { data: { id: 'd' } },
78
+ { data: { id: 'hub' } },
79
+ { data: { id: 'leaf-1' } },
80
+ { data: { id: 'leaf-2' } },
81
+ { data: { id: 'leaf-3' } },
82
+ { data: { id: 'chain-1' } },
83
+ { data: { id: 'chain-2' } },
84
+ { data: { id: 'ab', source: 'a', target: 'b' } },
85
+ { data: { id: 'bc', source: 'b', target: 'c' } },
86
+ { data: { id: 'cd', source: 'c', target: 'd' } },
87
+ { data: { id: 'da', source: 'd', target: 'a' } },
88
+ { data: { id: 'c-hub', source: 'c', target: 'hub' } },
89
+ { data: { id: 'hub-leaf-1', source: 'hub', target: 'leaf-1' } },
90
+ { data: { id: 'hub-leaf-2', source: 'hub', target: 'leaf-2' } },
91
+ { data: { id: 'hub-leaf-3', source: 'hub', target: 'leaf-3' } },
92
+ { data: { id: 'd-chain-1', source: 'd', target: 'chain-1' } },
93
+ { data: { id: 'chain-1-chain-2', source: 'chain-1', target: 'chain-2' } }
94
+ ];
95
+
96
+ const cy = cytoscape({
97
+ container: document.getElementById('cy'),
98
+ elements,
99
+ style: [
100
+ {
101
+ selector: 'node',
102
+ style: {
103
+ 'label': 'data(id)',
104
+ }
105
+ },
106
+ ]
107
+ });
108
+
109
+ cy.layout({
110
+ name: 'substructure-layout',
111
+ }).run();
112
+ </script>
113
+ </body>
114
+ </html>
115
+ ```
116
+
117
+ ## Configuration
118
+
119
+ TODO
120
+
121
+ ## Development
122
+
123
+ TODO
@@ -0,0 +1,115 @@
1
+ import cytoscape from 'cytoscape';
2
+ export type LayoutAlgorithm = 'force' | 'stress';
3
+ export interface LayoutParameters {
4
+ LAYOUT_ALGORITHM: LayoutAlgorithm;
5
+ IDEAL_LENGTH: number;
6
+ REPULSION: number;
7
+ SPRING_K: number;
8
+ ITERATIONS: number;
9
+ ANGULAR_STRENGTH: number;
10
+ CENTER_GRAVITY: number;
11
+ USE_ANGULAR_FORCE: boolean;
12
+ RANDOMIZE_INITIAL_POSITIONS: boolean;
13
+ MIN_STAR_LEAVES: number;
14
+ MIN_CYCLE_LENGTH: number;
15
+ MAX_CYCLE_LENGTH: number;
16
+ MIN_CHAIN_LENGTH: number;
17
+ MIN_PARALLEL_NEIGHBORS: number;
18
+ CYCLE_NODE_SPACING: number;
19
+ STAR_RING_SPACING: number;
20
+ STAR_BASE_NODES_PER_RING: number;
21
+ CHAIN_MIN_RADIUS: number;
22
+ PARALLEL_GAP: number;
23
+ LEAF_NODE_DISTANCE: number;
24
+ VNODE_RADIUS_MULTIPLIER: number;
25
+ VNODE_REPULSION: number;
26
+ VNODE_SPRING_K: number;
27
+ VNODE_ITERATIONS: number;
28
+ VNODE_ANGULAR_STRENGTH: number;
29
+ SPREAD_V_NODES: boolean;
30
+ SUBSTRUCTURE_LAYOUT: boolean;
31
+ ENABLE_INITIAL_FORCE_LAYOUT: boolean;
32
+ STEP_BY_STEP: boolean;
33
+ SHOW_ALL_EDGES: boolean;
34
+ }
35
+ export declare const DEFAULT_PARAMS: LayoutParameters;
36
+ export interface LayoutStep {
37
+ stepNumber: number;
38
+ stepName: string;
39
+ description: string;
40
+ nodePositions: {
41
+ [nodeId: string]: {
42
+ x: number;
43
+ y: number;
44
+ };
45
+ };
46
+ virtualNodes?: VNode[];
47
+ virtualEdges?: VEdge[];
48
+ metadata?: any;
49
+ }
50
+ export type SubstructureType = 'Normal' | 'Cycle' | 'Chain' | 'Star-Center' | 'Star-Member' | 'Parallel' | 'LeafButNotChain';
51
+ type Node = cytoscape.NodeSingular;
52
+ declare class VNode {
53
+ id: string;
54
+ type: any;
55
+ center_x: number;
56
+ center_y: number;
57
+ radius: number;
58
+ rotate_angle: number;
59
+ nodes: Node[];
60
+ neighbors: VNode[];
61
+ _permanentOrder?: string[];
62
+ constructor(id: string, x: number, y: number, radius: number);
63
+ get position(): {
64
+ x: number;
65
+ y: number;
66
+ };
67
+ setPosition(x: number, y: number): void;
68
+ addNode(node: Node): void;
69
+ setPermanentOrder(order: string[]): void;
70
+ getPermanentOrder(): string[] | undefined;
71
+ toSnapshot(): {
72
+ id: string;
73
+ type: any;
74
+ center_x: number;
75
+ center_y: number;
76
+ radius: number;
77
+ rotate_angle: number;
78
+ nodeIds: cytoscape.NodeSingular[];
79
+ };
80
+ }
81
+ declare class VEdge {
82
+ source: VNode;
83
+ target: VNode;
84
+ weight: number;
85
+ constructor(source: VNode, target: VNode, weight?: number);
86
+ toSnapshot(): {
87
+ source: string;
88
+ target: string;
89
+ weight: number;
90
+ };
91
+ }
92
+ /**
93
+ * Register this layout as a Cytoscape.js layout extension.
94
+ *
95
+ * Usage:
96
+ * import cytoscape from 'cytoscape';
97
+ * import substructureLayout from './cytoscape-substructure-layout';
98
+ *
99
+ * substructureLayout(cytoscape);
100
+ *
101
+ * cy.layout({
102
+ * name: 'substructure-layout',
103
+ * layoutAlgorithm: 'force',
104
+ * idealLength: 100,
105
+ * repulsion: 10000,
106
+ * springK: 0.15,
107
+ * iterations: 400
108
+ * }).run();
109
+ */
110
+ export default function register(cytoscapeInstance: any): void;
111
+ export { SubstructureLayout };
112
+ /**
113
+ * Enhanced force-directed layout with structure awareness
114
+ */
115
+ declare function SubstructureLayout(this: any, options: any): void;