1 2// ------------------------------------------------------------ 3// functions to handle the zooms in the NGL/MSA/mutationTable 4// ------------------------------------------------------------ 5 6// updating NGL in order to zoom where the user double-clicked on NGL 7 8var atomSet2; 9var contacts; 10var toggleHydrop = 0; 11var toggleHB = 1; 12var toggleIon = 1; 13var toggleCatPi = 0; 14var togglePiStack = 0; 15var o; 16 17function zoomNGL(myZoom, chainOfSelectedAtom, pdb){ 18 19 if (pdb.length > 50) { 20 var pdb = new Blob( [ pdb ], { type: 'text/plain'} ); 21 } 22 23 stage.loadFile(pdb, { ext: "pdb" } ).then(function(o){ 24 25 // Remove representation of previous selection 26 if (typeof bns !== "undefined") { 27 bns.setVisibility(false) 28 } 29 if (typeof lic !== "undefined") { 30 lic.setVisibility(false) 31 } 32 if (typeof pol !== "undefined") { 33 pol.setVisibility(false) 34 } 35 if (typeof contacts !== "undefined") { 36 contacts.setVisibility(false) 37 } 38 39 // Define ball and stick and licorice representations. 40 var bnsRepr = o.addRepresentation('ball+stick', { sele: 'NONE' }); 41 var licRepr = o.addRepresentation('licorice', { sele: 'NONE' }); 42 var conRepr = o.addRepresentation("contact", { 43 sele: 'NONE', 44 hydrogenBond: true, 45 hydrophobic: false, 46 halogenBond: false, 47 ionicInteraction: true, 48 metalCoordination: false, 49 cationPi: false, 50 piStacking: false, 51 weakHydrogenBond: false, 52 waterHydrogenBond: true, 53 backboneHydrogenBond: true, 54 maxPiStackingDist: 5.5, 55 maxPiStackingOffset: 2.0, 56 maxPiStackingAngle: 45, 57 }); 58 59 // myZoom needs to be a string 60 myZoom = myZoom.toString(); 61 // zooming on the selected amino acid; 62 var center = o.getCenter( myZoom ); 63 var zoom = o.getZoom( myZoom ); 64 stage.animationControls.zoomMove( center, zoom, 1500 ); 65 // label selected amino acid 66 l=o.addRepresentation( "label", { 67 sele: "( " + myZoom + " ) and .CA" , 68 color: "orange", 69 scale: 1.0 70 }); 71 72 // show the selected residue in ball and stick 73 bns=bnsRepr.setSelection(myZoom); 74 75 // show residues around the selected one in licorice 76 var selection = new NGL.Selection( myZoom ); 77 var radius = 5; 78 79 var atomSet = o.structure.getAtomSetWithinSelection( selection, radius ); 80 atomSet2 = o.structure.getAtomSetWithinGroup( atomSet ); 81 atomSet2=atomSet2.toSeleString() + ' AND NOT hydrogen'; 82 lic=licRepr.setSelection(atomSet2); 83 84 // show contacts made by residues around the selected one 85 contacts=conRepr.setSelection(atomSet2); 86 87 // get back selected options regarding displayed interactions 88 if (typeof toggleHB === "undefined" || toggleHB === 0 ) { 89 contacts.setParameters( {hydrogenBond: false} ); 90 contacts.setParameters( {waterHydrogenBond: false} ); 91 contacts.setParameters( {backboneHydrogenBond: false} ); 92 } 93 if (typeof toggleIon === "undefined" || toggleIon === 0 ) { 94 contacts.setParameters( {ionicInteraction: false} ); 95 } 96 if (typeof toggleHydrop === "undefined" || toggleHydrop === 1 ) { 97 contacts.setParameters( {hydrophobic: true} ); 98 } 99 if (typeof toggleCatPi === "undefined" || toggleCatPi === 1 ) { 100 contacts.setParameters( {cationPi: true} ); 101 } 102 if (typeof togglePiStack === "undefined" || togglePiStack === 1 ) { 103 contacts.setParameters( {piStacking: true} ); 104 } 105 }); 106 107} 108 109function zoomOnlyNGL(myZoom, pdb){ 110 111 if (pdb.length > 50) { 112 var pdb = new Blob( [ pdb ], { type: 'text/plain'} ); 113 } 114 115 stage.loadFile(pdb, { ext: "pdb" } ).then(function(o){ 116 117 // myZoom needs to be a string 118 myZoom = myZoom.toString(); 119 // zooming on the selected amino acid; 120 var center = o.getCenter( myZoom ); 121 var zoom = o.getZoom( myZoom ); 122 stage.animationControls.zoomMove( center, zoom, 0 ); 123 // label selected amino acid 124 l=o.addRepresentation( "label", { 125 sele: "( " + myZoom + " ) and .CA" , 126 color: "orange", 127 scale: 1.0 128 }); 129 }); 130} 131 132// Toggle contacts 133 134function toggleHBond(){ 135 if (typeof atomSet2 === "undefined") { 136 alert("You need to select a residue to display molecular interactions.") 137 } 138 if (typeof atomSet2 !== "undefined" && atomSet2 !== "") { 139 if (typeof toggleHB === "undefined" || toggleHB === 0 ) { 140 toggleHB=1; 141 contacts.setParameters( {hydrogenBond: true} ); 142 contacts.setParameters( {waterHydrogenBond: true} ); 143 contacts.setParameters( {backboneHydrogenBond: true} ); 144 document.getElementById( 'hydrogenBondToggle' ).style.backgroundColor="#3498DB"; 145 document.getElementById( 'hydrogenBondToggle' ).style.color="white"; 146 } else { 147 toggleHB=0; 148 contacts.setParameters( {hydrogenBond: false} ); 149 contacts.setParameters( {waterHydrogenBond: false} ); 150 contacts.setParameters( {backboneHydrogenBond: false} ); 151 document.getElementById( 'hydrogenBondToggle' ).style.backgroundColor="#F8F8F8"; 152 document.getElementById( 'hydrogenBondToggle' ).style.color="black"; 153 } 154 } 155} 156 157function toggleIonic(){ 158 if (typeof atomSet2 === "undefined") { 159 alert("You need to select a residue to display molecular interactions.") 160 } 161 if (typeof atomSet2 !== "undefined" && atomSet2 !== "") { 162 if (typeof toggleIon === "undefined" || toggleIon === 0 ) { 163 toggleIon=1; 164 contacts.setParameters( {ionicInteraction: true} ); 165 document.getElementById( 'ionToggle' ).style.backgroundColor="#FFFC33";
166 document.getElementById( 'ionToggle' ).style.color="black"; 167 } else { 168 toggleIon=0; 169 contacts.setParameters( {ionicInteraction: false} ); 170 document.getElementById( 'ionToggle' ).style.backgroundColor="#F8F8F8"; 171 document.getElementById( 'ionToggle' ).style.color="black"; 172 } 173 } 174} 175 176function toggleCationPi(){ 177 if (typeof atomSet2 === "undefined") { 178 alert("You need to select a residue to display molecular interactions.") 179 } 180 if (typeof atomSet2 !== "undefined" && atomSet2 !== "") { 181 if (typeof toggleCatPi === "undefined" || toggleCatPi === 0 ) { 182 toggleCatPi=1; 183 contacts.setParameters( {cationPi: true} ); 184 document.getElementById( 'cationPiToggle' ).style.backgroundColor="#F39C12"; 185 document.getElementById( 'cationPiToggle' ).style.color="white"; 186 } else { 187 toggleCatPi=0; 188 contacts.setParameters( {cationPi: false} ); 189 document.getElementById( 'cationPiToggle' ).style.backgroundColor="#F8F8F8"; 190 document.getElementById( 'cationPiToggle' ).style.color="black"; 191 } 192 } 193} 194 195function toggleHydrophobic(){ 196 if (typeof atomSet2 === "undefined") { 197 alert("You need to select a residue to display molecular interactions.") 198 } 199 if (typeof atomSet2 !== "undefined" && atomSet2 !== "") { 200 if (typeof toggleHydrop === "undefined" || toggleHydrop === 0 ) { 201 toggleHydrop=1; 202 contacts.setParameters( {hydrophobic: true} ); 203 document.getElementById( 'hydrophobicToggle' ).style.backgroundColor="#626567"; 204 document.getElementById( 'hydrophobicToggle' ).style.color="white"; 205 } else { 206 toggleHydrop=0; 207 contacts.setParameters( {hydrophobic: false} ); 208 document.getElementById( 'hydrophobicToggle' ).style.backgroundColor="#F8F8F8"; 209 document.getElementById( 'hydrophobicToggle' ).style.color="black"; 210 } 211 } 212} 213 214function togglePiStacking(){ 215 if (typeof atomSet2 === "undefined") { 216 alert("You need to select a residue to display molecular interactions.") 217 } 218 if (typeof atomSet2 !== "undefined" && atomSet2 !== "") { 219 if (typeof togglePiStack === "undefined" || togglePiStack === 0 ) { 220 togglePiStack=1; 221 contacts.setParameters( {piStacking: true} ); 222 document.getElementById( 'piStackingToggle' ).style.backgroundColor="#7DCEA0"; 223 document.getElementById( 'piStackingToggle' ).style.color="white"; 224 } else { 225 togglePiStack=0; 226 contacts.setParameters( {piStacking: false} ); 227 document.getElementById( 'piStackingToggle' ).style.backgroundColor="#F8F8F8"; 228 document.getElementById( 'piStackingToggle' ).style.color="black"; 229 } 230 } 231} 232 233 234 235 236 237 238 239// select the correct mutation in selectMutation 240function zoomSelectMutation(index){ 241 var theselect = document.getElementById("selectMutation"); 242 $("#selectMutation").prop('selectedIndex', index); 243} 244 245 246// "zoom" in table on the closest variant for the selected residue 247function zoomTable(rows,index,residueNumber,doBold){ 248 249 if (!rows){ 250 rows = $('#mutationFill_tbody').find('tr'); 251 } 252 253 var scrollTo; 254 255 // unbold selected variant 256 resetSelectedVariant(); 257 258 // if index, use it 259 if ($.isNumeric(index)){ 260 scrollTo = $(rows[index]); 261 // bold it 262 if (doBold){ 263 scrollTo.children()[0].style.fontWeight = "bold"; 264 } 265 } 266 // else if residueNumber (when manual research) 267 else{ 268 269 // find larger value of residue 270 imax = findLargestResidue(rows); 271 // look for the closest value to residueNumber, by dichotomy 272 var [iclosest,exact] = findClosest(imax,rows,residueNumber); 273 scrollTo = $('#' + rows[iclosest].id); 274 // take care of the bolding of the variant in the table 275 if (doBold){ 276 resetSelectedVariant(); 277 if (exact){ 278 scrollTo.children()[0].style.fontWeight = "bold"; 279 } 280 } 281 } 282 283 284 // scroll the table 285 var container = $('#mutationFill_div'); 286 // height to let on top of scroll zone above selected cell 287 var htop = 0.5*(container.height()-scrollTo.height()); 288 container.animate({ 289 scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() -htop 290 }); 291 292 // select the mutation in selectMutation 293 zoomSelectMutation(scrollTo.index()); 294 295 // function: find the largest residue in the table 296 function findLargestResidue(){ 297 var imax = rows.length-1; 298 while (rows[imax].id=="0"){ 299 imax -= 1; 300 } 301 return imax; 302 } 303 // function: find the closest value to rnu in ro[0:imaxi].id, by dichotomy (values are sorted) 304 function findClosest(imaxi,ro,rnu){ 305 306 var ia = 0; 307 var ic = imaxi;
308 var ib = Math.ceil(imaxi/2); 309 while (Math.abs(ic-ia)>1){ 310 if (rnu<=ro[ib].id){ 311 ic = ib; 312 ib = ia + Math.ceil((ib-ia)/2); 313 } 314 else{ 315 ia = ib; 316 ib = ib + Math.ceil((ic-ib)/2); 317 } 318 } 319// console.log("ia: " + ia + " ib: " + ib + " ic: " +ic ); 320 var iclos; 321 if ( Math.abs(rnu-ro[ia].id) <= Math.abs(rnu-ro[ic].id) ){ 322 iclos = ia; 323 } 324 else{ 325 iclos = ic; 326 } 327 var exact = (ro[iclos].id==rnu); 328// console.log("closest: " + ro[iclos].id ); 329 330 return [iclos,exact]; 331 } 332} 333 334// zoom in msa 335function zoomMSA(zoomNbMSA,doBold){ 336 // zooming MSA, to have the index we want in the center, we need to substract 26 as MSA displays about 52 columns at once 337 m.g.zoomer.setLeftOffset((zoomNbMSA-26)); 338 // clean highlights 339 cleanHighlight(); 340 cleanCellHighlight(); 341 // Highlighting the correct caption on MSA 342 if (doBold){ 343 highlightZoom(zoomNbMSA); 344 } 345 346} 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.