File size: 14,479 Bytes
56fa79a
 
ffa70f2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56fa79a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<!DOCTYPE html>
<html>

  <head>
 
    <link  rel="stylesheet" href="https://ebi.emblstatic.net/web_guidelines/EBI-Icon-fonts/v1.2/fonts.css"  type="text/css" media="all"/>
    <script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
    <script type="text/javascript" src="https://www.ebi.ac.uk/pdbe/pdb-component-library/js/protvista-pdb-3.3.0.js"></script>
 
  </head>

  <body>
    <h4>ProtVista PDB custom data demo</h4>

    <div>
      <protvista-pdb custom-data="true" id="pv1"></protvista-pdb>
    </div>
    
    <script>
    document.addEventListener('DOMContentLoaded', () => {
        
        //Get web-component element
        const pvInstance = document.getElementById('pv1');
        if(!pvInstance) return;
        (async () => {

            // PDBe sequence conservation api data
            let scFetch = await fetch('https://www.ebi.ac.uk/pdbe/graph-api/uniprot/sequence_conservation/P29373');
            let scResponseData = await scFetch.json();
            const seqConservationData = scResponseData;
            // seqConservationData is a json array with following fields. Please refer the fetch api url for the data struture
            // [
            //     {
            //         "start": 1,
            //         "end": 1,
            //         "conservation_score": 1,
            //         "tooltipContent": "Conservation score: 1",
            //         "amino": [
            //             {
            //                 "end": 1,
            //                 "letter": "P",
            //                 "proba": 0.428,
            //                 "start": 1,
            //                 "color": "#c0c000",
            //                 "tooltipContent": "Amino acid: PRO<br/>Probability: 42.80%"
            //             },...
            //         ]
            //     }...
            // ]

            // PDBe variation api data
            let vrFetch = await fetch('https://www.ebi.ac.uk/pdbe/graph-api/uniprot/protvista/variation/P29373');
            let vrResponseData = await vrFetch.json();
            const variationData = vrResponseData;
            // variationData is a json with following fields. Please refer the fetch api url for the data struture
            // {
            //     "sequence": "PNFSGNWKIIRSENFEELLKVLGVNVMLRKIAVAAASKPAVEIKQEGDTFYIKTSTTVRTTEINFKVGEEFEEQTVDGRPCKSLVKWESENKMVCEQKLLKGEGPKTSWTRELTNDGELILTMTADDVVCTRVYVRE",
            //     "variants": [
            //         {
            //             "accession": "NC_000001.11:g.156705439T>C",
            //             "association": [],
            //             "clinicalSignificances": null,
            //             "color": "#002594",
            //             "end": "2",
            //             "polyphenScore": 0.003,
            //             "siftScore": 0.055,
            //             "sourceType": "large_scale_study",
            //             "start": "2",
            //             "tooltipContent": "XYZ Variant",
            //             "variant": "S",
            //             "xrefNames": [
            //                 "gnomAD"
            //             ],
            //             "keywords": [  // Keywords are used to filter the variats
            //                 "predicted",
            //                 "large_scale_studies"
            //             ]
            //         },...
            //     ]
            // }
            
        
            //Custom data model
            const customData = {
                displayNavigation: true, // Set to false to hide navigation scale
                displaySequence: true, // Set to false to hide sequence track
                sequence: 'MPNFSGNWKIIRSENFEELLKVLGVNVMLRKIAVAAASKPAVEIKQEGDTFYIKTSTTVRTTEINFKVGEEFEEQTVDGRPCKSLVKWESENKMVCEQKLLKGEGPKTSWTRELTNDGELILTMTADDVVCTRVYVRE', //Protein sequence
                length: 138, // Length of the sequence
                offset: 1, // Offset navigation scale start. Example offset:10 will display the navigation start from 10 instead of default 1.
                tracks: [ // Array of track objects  (PDBe implementation extends core ProtVista track component. Refer - https://github.com/ebi-webcomponents/nightingale/tree/master/packages/protvista-track#data-array for all the supported track properties )
                    {
                        label: "Domains", // Track label
                        labelType: "text", // Supported values 'text' and 'html'
                        data: [
                            {
                                accession: "d1", // Some unique id
                                type: "UniProt range", // Displayed in tooltip title
                                label: "Domain 1", // Expected values 'text' and 'html'
                                labelTooltip: "Residues mapped to domain 1", // Label tooltip content. Support text and HTML mark-up 
                                locations: [ // Array of sub-tracks
                                {
                                    fragments : [ // Array of sub-track fragments
                                    {
                                        start: 1, // Track start value
                                        end: 56, // Track end value
                                        tooltipContent: "Type: domain 1<br>Range: XYZ1 - XYZ56",  // track tooltip content. Support text and HTML mark-up 
                                        color: "rgb(135,158,247)" // track (fragment) colour, supported rgb and hex code value
                                    },
                                    {
                                        start: 70,
                                        end: 130,
                                        tooltipContent: "Type: domain 1<br>Range: XYZ70 - XYZ130",
                                        color: "rgb(160,174,232)"
                                    }
                                    ]
                                }
                                ]
                            },
                            {
                                accession: "d2",
                                type: "UniProt range",
                                label: "<div><i class='icon icon-generic' data-icon=';' style='color: #000;'></i> <a href='resource.xyz'>Domain 2</a></div>", //HTML strcutured label with font-icons. You can add any HTML markup.
                                labelTooltip: "<strong>Domain Compound</strong><br><img src='https://www.ebi.ac.uk/pdbe/static/files/pdbechem_v2/REA_200.svg'>", // labelTooltip HTML mark-up example displaying compound image in the tooltip.
                                locations: [
                                {
                                    fragments : [
                                    {
                                        start: 1,
                                        end: 20,
                                        tooltipContent: "<strong>Type: domain 2</strong><br>Range: XY1 - XYZ20<br><a href='resource.xyz' style='color:blue'>view details</a>", // tooltipContent HTML mark-up example
                                        color: "rgb(107,119,39)"
                                    },
                                    {
                                        start: 22,
                                        end: 137,
                                        tooltipContent: "Type: domain 2<br>Range: XYZ22 - XYZ137",
                                        color: "rgb(90,102,23)"
                                    }
                                    ]
                                }
                                ]
                            }
                        ]

                    },
                    {
                        label: "Annotations",
                        labelType: "text",
                        labelColor: "rgb(128,128,128)", // Set labelColor to change label background colour
                        data: [
                            {
                                accession: "a1",
                                type: "UniProt range",
                                label: "Annotations 1",
                                labelType: "text",
                                labelTooltip: "Residues mapped to annotations 1",
                                labelColor: "rgb(211,211,211)",
                                color: "rgb(255,99,163)",
                                locations: [
                                {
                                    fragments : [
                                    {
                                        start: 1,
                                        end: 56,
                                        tooltipContent: "Type: domain 1<br>Range: XYZ1 - XYZ56"
                                    },
                                    {
                                        start: 70,
                                        end: 130,
                                        tooltipContent: "Type: domain 1<br>Range: XYZ70 - XYZ130"
                                    }
                                    ]
                                }
                                ]
                            }
                        ]

                    },
                    {
                        label: "Annotation shapes",
                        data: [
                            {
                                accession: "s1",
                                type: "UniProt range",
                                label: "Circle",
                                color: "rgb(249,166,2)",
                                shape: 'circle', // supported shapes rectangle|bridge|diamond|chevron|catFace|triangle|wave|hexagon|pentagon|circle|arrow|doubleBar,
                                locations: [
                                    {
                                        fragments : [
                                            {
                                                start: 5,
                                                end: 5,
                                                tooltipContent: "Type: domain 1<br>Range: XYZ1 - XYZ56",
                                            },
                                            {
                                                start: 9,
                                                end: 9,
                                                tooltipContent: "Type: domain 1<br>Range: XYZ70 - XYZ130"
                                            }
                                        ]
                                    }
                                ]
                            },
                            {
                                accession: "s2",
                                type: "UniProt range",
                                label: "Diamond",
                                shape: 'diamond',
                                color: "rgb(255,99,163)", // Default colour value for all fragments in this track
                                locations: [
                                    {
                                        fragments : [
                                            {
                                                start: 5,
                                                end: 5,
                                                tooltipContent: "Type: domain 1<br>Range: XYZ1 - XYZ56"
                                            },
                                            {
                                                start: 9,
                                                end: 9,
                                                color: "rgb(0,128,129)", // Set colour here for individual shape fragment. This will override the track default colour.
                                                tooltipContent: "Type: domain 1<br>Range: XYZ70 - XYZ130"
                                            },
                                            {
                                                start: 20,
                                                end: 20,
                                                tooltipContent: "Type: domain 1<br>Range: XYZ70 - XYZ130"
                                            },
                                            {
                                                start: 22,
                                                end: 22,
                                                tooltipContent: "Type: domain 1<br>Range: XYZ70 - XYZ130"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]

                    }
                ],
                sequenceConservation: seqConservationData, // Set this property to display your own sequence conservation data. Refer comments at the top for data structure.
                variants: variationData, // Set this property to display your own variation data. Refer comments at the top for data structure.
                legends: {
                    alignment: 'right', // expected values 'left', 'right' or 'center'
                    data: { // Legend Row, key is used as the row label
                        "Domains": [ // legends for Domains row
                            {
                                color: ["rgb(135,158,247)", "rgb(160,174,232)"], // legend color, supported rgb and hex code value
                                text: "Domains 1" // legend text
                            },
                            {
                                color: ["rgb(107,119,39)", "rgb(90,102,23)"],
                                text: "Domains 2"
                            }
                        ],
                        "Annotations": [ // legends for Annotation row row
                            {
                                color: ["rgb(255,99,163)"],
                                text: "Custom Annotations"
                            }
                        ]
                    }
                }
            };

            // Assign custom data object to instance viewerdata property
            pvInstance.viewerdata = customData;
        
        })();
        
    });
    </script>
    
    
  </body>

</html>