Skip to content

Commit

Permalink
Display perturbed nodes in downloaded svg
Browse files Browse the repository at this point in the history
  • Loading branch information
jmueller95 committed Jun 18, 2024
1 parent 84ec640 commit 5a99bc2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/BiowcPathwaygraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,20 @@ export class BiowcPathwaygraph extends LitElement {
.join('g')
.attr('class', d => `linkgroup ${d.types.join(' ')}`);

const isKinaseSubstrateLinkVisible = (linkD3: PathwayGraphLinkD3) => {
const visibilityMapKey = `${linkD3.sourceId},${linkD3.targetId}`;

// Show the arrow only if the PTM Node at the target is selected
const ptmnode = <PTMNodeD3>linkD3.target;

return (
ptmnode.selected &&
this.contextMenuStore?.get(
'kinase-substrate-relationship-visibility-map'
)[visibilityMapKey]
);
};

linksSvg.selectAll('.link').remove();
linksSvg
.append('line')
Expand Down Expand Up @@ -1639,19 +1653,19 @@ export class BiowcPathwaygraph extends LitElement {
if (d.types.includes('indirect effect')) return '7 2';
return null;
})
.attr('display', d => {
// Return 'none' if it IS a kinase-substrate-link, but it's been declared invisible for some reason
if (
d.types.includes('kinaseSubstrateLink') &&
!isKinaseSubstrateLinkVisible(d)
) {
return 'none';
}
return 'block';
})
.style('visibility', d => {
if (d.types.includes('kinaseSubstrateLink')) {
const visibilityMapKey = `${d.sourceId},${d.targetId}`;

// Show the arrow only if the PTM Node at the target is selected
const ptmnode = <PTMNodeD3>d.target;

return ptmnode.selected &&
this.contextMenuStore?.get(
'kinase-substrate-relationship-visibility-map'
)[visibilityMapKey]
? 'visible'
: 'hidden';
return isKinaseSubstrateLinkVisible(d) ? 'visible' : 'hidden';
}
if (d.types.includes('ptmlink')) {
return 'hidden';
Expand Down Expand Up @@ -3920,7 +3934,7 @@ font-family: "Roboto Light", "Helvetica Neue", "Verdana", sans-serif'><strong st
const propertySplit = prop.split(':');
if (propertySplit.length > 1) {
const key = `var(${propertySplit[0].trim()})`;
const value = propertySplit[1].trim();
const value = this._getMainDiv().style(propertySplit[0].trim());
serializedSVG = serializedSVG.replaceAll(key, value);
}
});
Expand Down
12 changes: 12 additions & 0 deletions stories/index.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default {
graphdataSkeleton: { control: 'object' },
ptmInputList: { control: 'array' },
fullProteomeInputList: { control: 'object' },
perturbedNodes: { control: 'object' },
hue: { control: 'text' },
applicationMode: { control: 'text' },
},
Expand All @@ -29,6 +30,7 @@ interface ArgTypes {
graphdataSkeleton?: object;
ptmInputList?: object;
fullProteomeInputList?: object;
perturbedNodes?: object;
hue: string;
applicationMode: string;
}
Expand All @@ -41,6 +43,7 @@ const Template: Story<ArgTypes> = (args: ArgTypes) => html`
.graphdataSkeleton=${args.graphdataSkeleton}
.ptmInputList=${args.ptmInputList}
.fullProteomeInputList=${args.fullProteomeInputList}
.perturbedNodes=${args.perturbedNodes}
.hue=${args.hue}
>
</biowc-pathwaygraph>
Expand Down Expand Up @@ -288,6 +291,7 @@ const DownloadSVGTemplate: Story<ArgTypes> = (args: ArgTypes) => html`
.graphdataSkeleton=${args.graphdataSkeleton}
.ptmInputList=${args.ptmInputList}
.fullProteomeInputList=${args.fullProteomeInputList}
.perturbedNodes=${args.perturbedNodes}
.hue=${args.hue}
>
</biowc-pathwaygraph>
Expand All @@ -296,6 +300,14 @@ const DownloadSVGTemplate: Story<ArgTypes> = (args: ArgTypes) => html`
export const DownloadGraphAsSVG = DownloadSVGTemplate.bind({});
DownloadGraphAsSVG.args = {
...ColoringNodesByPotency.args,
graphdataSkeleton: {
nodes: StoryFixtures.linkTypesFixture.nodes,
links: StoryFixtures.linkTypesFixture.links,
},
perturbedNodes: {
up: ['Protein B', 'Protein D'],
down: ['Protein A', 'Protein C'],
},
hue: 'potency',
storyTitle: 'Download Graph as SVG',
storyDescription:
Expand Down

0 comments on commit 5a99bc2

Please sign in to comment.