@@ -287,25 +287,26 @@ export class BiowcPathwaygraph extends LitElement {
287
287
288
288
contextMenuStore ?: Map < string , any > ;
289
289
290
- isAddingEdge : Boolean = false ;
290
+ isAddingEdge : boolean = false ;
291
291
292
- isCreatingGroup : Boolean = false ;
292
+ isCreatingGroup : boolean = false ;
293
293
294
- ptmNodeLabelsVisible : Boolean = false ;
294
+ allPtmNodeLabelsVisible : boolean = false ;
295
295
296
- kinaseSubstrateLinksVisible : Boolean = false ;
296
+ kinaseSubstrateLinksVisible : boolean = false ;
297
297
298
- perturbedNodesVisible : Boolean = false ;
298
+ perturbedNodesVisible : boolean = false ;
299
+
300
+ // For the context menu I need to explicitly enumerate all possible class lists of gene protein nodes
301
+ static regulation_strings = [ '' , '.down' , '.up' , '.both' , '.not' ] ;
302
+
303
+ static circle_strings = [ '' , '.circle-down' , '.circle-up' ] ;
299
304
300
- // TODO: Is there no way I can generalize this to rect.node-rect?
301
305
static geneProteinPathwayCompoundsNodes : string [ ] = [
302
- 'rect.node-rect.gene_protein' ,
303
- 'rect.node-rect.gene_protein.down' ,
304
- 'rect.node-rect.gene_protein.up' ,
305
- 'rect.node-rect.gene_protein.both' ,
306
- 'rect.node-rect.gene_protein.not' ,
307
- 'rect.node-rect.pathway' ,
308
- 'rect.node-rect.compound' ,
306
+ ...this . regulation_strings . flatMap ( s1 =>
307
+ this . circle_strings . map ( s2 => `rect.node-rect.gene_protein${ s1 } ${ s2 } ` )
308
+ ) ,
309
+ ...[ 'rect.node-rect.pathway' , 'rect.node-rect.compound' ] ,
309
310
] ;
310
311
311
312
static nodeTypes : { id : string ; label : string } [ ] = [
@@ -598,6 +599,7 @@ export class BiowcPathwaygraph extends LitElement {
598
599
[ 'show-up' , true ] ,
599
600
[ 'show-down' , true ] ,
600
601
[ 'show-not' , true ] ,
602
+ [ 'peptide-label-visibility-map' , { } ] ,
601
603
] ) ;
602
604
603
605
this . _initEditModeForms ( ) ;
@@ -3900,19 +3902,21 @@ font-family: "Roboto Light", "Helvetica Neue", "Verdana", sans-serif'><strong st
3900
3902
a . click ( ) ;
3901
3903
}
3902
3904
3903
- public toggleLabelPeptideNodes ( ) {
3904
- this . ptmNodeLabelsVisible = ! this . ptmNodeLabelsVisible ;
3905
+ public updatePeptideNodeLabels ( ) {
3905
3906
this . d3Nodes ! . forEach ( node => {
3906
3907
if ( node . type === 'ptm' ) {
3908
+ const ptmNode = < PTMNodeD3 > node ;
3907
3909
// TODO: If available, use Site identifier before sequence
3908
3910
const ptmNodeLabel =
3909
3911
// @ts -ignore
3910
- ( < PTMNodeD3 > node ) . details ?. Site ?. text ||
3911
- ( < PTMNodeD3 > node ) . details ! [ 'Modified Sequence' ] ||
3912
- ( < PTMNodeD3 > node ) . details ! . Sequence ||
3912
+ ptmNode . details ?. Site ?. text ||
3913
+ ptmNode . details ! [ 'Modified Sequence' ] ||
3914
+ ptmNode . details ! . Sequence ||
3913
3915
'test' ;
3914
3916
// eslint-disable-next-line no-param-reassign
3915
- node . currentDisplayedLabel = this . ptmNodeLabelsVisible
3917
+ ptmNode . currentDisplayedLabel = this . contextMenuStore ?. get (
3918
+ 'peptide-label-visibility-map'
3919
+ ) [ ptmNode . geneProteinNode ?. nodeId ! ]
3916
3920
? String ( ptmNodeLabel )
3917
3921
: '' ;
3918
3922
}
@@ -4083,10 +4087,25 @@ font-family: "Roboto Light", "Helvetica Neue", "Verdana", sans-serif'><strong st
4083
4087
} ,
4084
4088
{
4085
4089
target : 'svg' ,
4086
- label : 'Show PTM Node Labels' ,
4087
- execute : ( ) => this . toggleLabelPeptideNodes ( ) ,
4090
+ label : 'Show PTM Labels' ,
4091
+ execute : ( ) => {
4092
+ this . allPtmNodeLabelsVisible = ! this . allPtmNodeLabelsVisible ;
4093
+ const peptideNodeVisibilityMap = this . contextMenuStore ?. get (
4094
+ 'peptide-label-visibility-map'
4095
+ ) ;
4096
+ this . d3Nodes ! . forEach ( node => {
4097
+ peptideNodeVisibilityMap [ node . nodeId ! ] =
4098
+ this . allPtmNodeLabelsVisible ;
4099
+ } ) ;
4100
+ this . contextMenuStore ?. set (
4101
+ 'peptide-label-visibility-map' ,
4102
+ peptideNodeVisibilityMap
4103
+ ) ;
4104
+
4105
+ this . updatePeptideNodeLabels ( ) ;
4106
+ } ,
4088
4107
type : 'radio' ,
4089
- checked : ( ) => this . ptmNodeLabelsVisible ,
4108
+ checked : ( ) => this . allPtmNodeLabelsVisible ,
4090
4109
} ,
4091
4110
{
4092
4111
target : 'svg' ,
@@ -4179,8 +4198,28 @@ font-family: "Roboto Light", "Helvetica Neue", "Verdana", sans-serif'><strong st
4179
4198
} ,
4180
4199
] ;
4181
4200
this . contextMenuCommands . push (
4182
- ...[
4201
+ ...( < ContextMenuCommand [ ] > [
4183
4202
// Context Menu for Gene/Protein Nodes
4203
+ {
4204
+ target : BiowcPathwaygraph . geneProteinPathwayCompoundsNodes ,
4205
+ label : 'Show PTM Labels for Node' ,
4206
+ execute : ( ctx : ExecuteOptions ) => {
4207
+ const peptideNodeVisibilityMap = this . contextMenuStore ?. get (
4208
+ 'peptide-label-visibility-map'
4209
+ ) ;
4210
+ // @ts -ignore
4211
+ peptideNodeVisibilityMap [ ctx . target . __data__ . nodeId ] =
4212
+ // @ts -ignore
4213
+ ! peptideNodeVisibilityMap [ ctx . target . __data__ . nodeId ] ;
4214
+ this . updatePeptideNodeLabels ( ) ;
4215
+ } ,
4216
+ type : 'radio' ,
4217
+ checked : ctx =>
4218
+ this . contextMenuStore ?. get ( 'peptide-label-visibility-map' ) [
4219
+ // @ts -ignore
4220
+ ctx . target . __data__ . nodeId
4221
+ ] ,
4222
+ } ,
4184
4223
{
4185
4224
target : BiowcPathwaygraph . geneProteinPathwayCompoundsNodes . concat ( [
4186
4225
'path.group-path' ,
@@ -4217,7 +4256,7 @@ font-family: "Roboto Light", "Helvetica Neue", "Verdana", sans-serif'><strong st
4217
4256
label : 'Alternative Names' ,
4218
4257
// Children will be created dynamically!
4219
4258
} ,
4220
- ]
4259
+ ] )
4221
4260
) ;
4222
4261
4223
4262
// Now we set up an event listener for nodes that dynamically creates the children of the 'Alternative Names' menu entry
0 commit comments