Skip to content

Commit 5a99bc2

Browse files
committed
Display perturbed nodes in downloaded svg
1 parent 84ec640 commit 5a99bc2

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

src/BiowcPathwaygraph.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,20 @@ export class BiowcPathwaygraph extends LitElement {
16111611
.join('g')
16121612
.attr('class', d => `linkgroup ${d.types.join(' ')}`);
16131613

1614+
const isKinaseSubstrateLinkVisible = (linkD3: PathwayGraphLinkD3) => {
1615+
const visibilityMapKey = `${linkD3.sourceId},${linkD3.targetId}`;
1616+
1617+
// Show the arrow only if the PTM Node at the target is selected
1618+
const ptmnode = <PTMNodeD3>linkD3.target;
1619+
1620+
return (
1621+
ptmnode.selected &&
1622+
this.contextMenuStore?.get(
1623+
'kinase-substrate-relationship-visibility-map'
1624+
)[visibilityMapKey]
1625+
);
1626+
};
1627+
16141628
linksSvg.selectAll('.link').remove();
16151629
linksSvg
16161630
.append('line')
@@ -1639,19 +1653,19 @@ export class BiowcPathwaygraph extends LitElement {
16391653
if (d.types.includes('indirect effect')) return '7 2';
16401654
return null;
16411655
})
1656+
.attr('display', d => {
1657+
// Return 'none' if it IS a kinase-substrate-link, but it's been declared invisible for some reason
1658+
if (
1659+
d.types.includes('kinaseSubstrateLink') &&
1660+
!isKinaseSubstrateLinkVisible(d)
1661+
) {
1662+
return 'none';
1663+
}
1664+
return 'block';
1665+
})
16421666
.style('visibility', d => {
16431667
if (d.types.includes('kinaseSubstrateLink')) {
1644-
const visibilityMapKey = `${d.sourceId},${d.targetId}`;
1645-
1646-
// Show the arrow only if the PTM Node at the target is selected
1647-
const ptmnode = <PTMNodeD3>d.target;
1648-
1649-
return ptmnode.selected &&
1650-
this.contextMenuStore?.get(
1651-
'kinase-substrate-relationship-visibility-map'
1652-
)[visibilityMapKey]
1653-
? 'visible'
1654-
: 'hidden';
1668+
return isKinaseSubstrateLinkVisible(d) ? 'visible' : 'hidden';
16551669
}
16561670
if (d.types.includes('ptmlink')) {
16571671
return 'hidden';
@@ -3920,7 +3934,7 @@ font-family: "Roboto Light", "Helvetica Neue", "Verdana", sans-serif'><strong st
39203934
const propertySplit = prop.split(':');
39213935
if (propertySplit.length > 1) {
39223936
const key = `var(${propertySplit[0].trim()})`;
3923-
const value = propertySplit[1].trim();
3937+
const value = this._getMainDiv().style(propertySplit[0].trim());
39243938
serializedSVG = serializedSVG.replaceAll(key, value);
39253939
}
39263940
});

stories/index.stories.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default {
1111
graphdataSkeleton: { control: 'object' },
1212
ptmInputList: { control: 'array' },
1313
fullProteomeInputList: { control: 'object' },
14+
perturbedNodes: { control: 'object' },
1415
hue: { control: 'text' },
1516
applicationMode: { control: 'text' },
1617
},
@@ -29,6 +30,7 @@ interface ArgTypes {
2930
graphdataSkeleton?: object;
3031
ptmInputList?: object;
3132
fullProteomeInputList?: object;
33+
perturbedNodes?: object;
3234
hue: string;
3335
applicationMode: string;
3436
}
@@ -41,6 +43,7 @@ const Template: Story<ArgTypes> = (args: ArgTypes) => html`
4143
.graphdataSkeleton=${args.graphdataSkeleton}
4244
.ptmInputList=${args.ptmInputList}
4345
.fullProteomeInputList=${args.fullProteomeInputList}
46+
.perturbedNodes=${args.perturbedNodes}
4447
.hue=${args.hue}
4548
>
4649
</biowc-pathwaygraph>
@@ -288,6 +291,7 @@ const DownloadSVGTemplate: Story<ArgTypes> = (args: ArgTypes) => html`
288291
.graphdataSkeleton=${args.graphdataSkeleton}
289292
.ptmInputList=${args.ptmInputList}
290293
.fullProteomeInputList=${args.fullProteomeInputList}
294+
.perturbedNodes=${args.perturbedNodes}
291295
.hue=${args.hue}
292296
>
293297
</biowc-pathwaygraph>
@@ -296,6 +300,14 @@ const DownloadSVGTemplate: Story<ArgTypes> = (args: ArgTypes) => html`
296300
export const DownloadGraphAsSVG = DownloadSVGTemplate.bind({});
297301
DownloadGraphAsSVG.args = {
298302
...ColoringNodesByPotency.args,
303+
graphdataSkeleton: {
304+
nodes: StoryFixtures.linkTypesFixture.nodes,
305+
links: StoryFixtures.linkTypesFixture.links,
306+
},
307+
perturbedNodes: {
308+
up: ['Protein B', 'Protein D'],
309+
down: ['Protein A', 'Protein C'],
310+
},
299311
hue: 'potency',
300312
storyTitle: 'Download Graph as SVG',
301313
storyDescription:

0 commit comments

Comments
 (0)