tycho-components 0.26.0 → 0.26.1

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.
@@ -13,12 +13,14 @@ export default class CytoscapeTreeConverter {
13
13
  private isEmptyCategoryInChunk;
14
14
  private convertEmptyCategory;
15
15
  private convertChunk;
16
+ private shouldChunkClaimToken;
16
17
  private removeTemporaryEdges;
17
18
  private generateChunkId;
18
19
  private generateTokenId;
19
20
  private generateLeafId;
20
21
  private findParent;
21
22
  private findContainingChunks;
23
+ private findTightestContainingChunk;
22
24
  private tightestChunk;
23
25
  private initTree;
24
26
  private sortChunks;
@@ -160,12 +160,7 @@ export default class CytoscapeTreeConverter {
160
160
  });
161
161
  const tokens = this.getTokens(struct, chunk);
162
162
  for (const token of tokens) {
163
- if (token.ec)
164
- continue;
165
- if (token.l !== chunk.l)
166
- continue;
167
- const dominator = this.tightestChunk(this.findContainingChunks(struct, chunk.l, token.p, token.p));
168
- if (!dominator || this.generateChunkId(dominator) !== nodeId)
163
+ if (!this.shouldChunkClaimToken(struct, chunk, token))
169
164
  continue;
170
165
  tree.edges.push({
171
166
  data: {
@@ -176,6 +171,20 @@ export default class CytoscapeTreeConverter {
176
171
  });
177
172
  }
178
173
  }
174
+ shouldChunkClaimToken(struct, chunk, token) {
175
+ if (token.ec)
176
+ return false;
177
+ if (token.l === 0 && chunk.l > 0) {
178
+ const dominator = this.findTightestContainingChunk(struct, token.p, token.p);
179
+ return (dominator !== null &&
180
+ this.generateChunkId(dominator) === this.generateChunkId(chunk));
181
+ }
182
+ if (token.l !== chunk.l)
183
+ return false;
184
+ const dominator = this.tightestChunk(this.findContainingChunks(struct, chunk.l, token.p, token.p));
185
+ return (dominator !== null &&
186
+ this.generateChunkId(dominator) === this.generateChunkId(chunk));
187
+ }
179
188
  removeTemporaryEdges(tree, struct, chunk) {
180
189
  let levelCount = 1;
181
190
  let leveledChunks = this.getChunksByLevel(struct, chunk, levelCount);
@@ -183,6 +192,8 @@ export default class CytoscapeTreeConverter {
183
192
  for (const upperChunk of leveledChunks) {
184
193
  const upperChunkId = this.generateChunkId(upperChunk);
185
194
  for (const token of this.getTokens(struct, chunk)) {
195
+ if (!this.shouldChunkClaimToken(struct, chunk, token))
196
+ continue;
186
197
  const tokenId = this.generateTokenId(token);
187
198
  tree.edges = [
188
199
  ...tree.edges.filter((e) => !(e.data.source === upperChunkId && e.data.target === tokenId)),
@@ -222,6 +233,9 @@ export default class CytoscapeTreeConverter {
222
233
  findContainingChunks(struct, level, i, f) {
223
234
  return struct.chunks.filter((c) => c.l === level && i >= c.i && f <= c.f);
224
235
  }
236
+ findTightestContainingChunk(struct, i, f, minLevel = 1) {
237
+ return this.tightestChunk(struct.chunks.filter((c) => c.l >= minLevel && i >= c.i && f <= c.f));
238
+ }
225
239
  tightestChunk(chunks) {
226
240
  if (chunks.length === 0)
227
241
  return null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.26.0",
4
+ "version": "0.26.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {