tutorial update, d-amino correction
[django_unres.git] / django_simple / todo / templates / details.html
index b567e6e..06ae3db 100644 (file)
@@ -236,6 +236,12 @@ Created {{ task.created_date  }}
                            <div class="col-md-6"> pdbref </div>
                            <div class="col-md-6">{{ task.md_pdbref}}</div>
                        </li>           
+                       {% if task.md_start == "pdbstart" %}
+                       <li class="list-group-item task-item">
+                           <div class="col-md-6"> preminim maxfun </div>
+                           <div class="col-md-6">{{ task.min_maxfun }}</div>
+                       </li>           
+                       {% endif %}
                        <li class="list-group-item task-item">
                            <div class="col-md-6"> respa </div>
                            <div class="col-md-6">{{ task.md_respa}}</div>
@@ -355,15 +361,26 @@ Created {{ task.created_date  }}
                          width="500"></a> </div>
                        </li>
 
-
+<!--
                        <li class="list-group-item task-item">
                          <div class="col-md-2"> Structure overlap </div>
                          <div class="col-md-10"> <img 
                          src="/myfiles/download-file/{{task.jobdirname}}/unres_overlap.png"
                          width="500"> </div>
                        </li>
-
-
+-->
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> Structure overlap NGL viewer</div>
+                         <div class="col-md-10" id="viewport_min"
+                         style="width:500px;height:500px;"> 
+                         </div>
+                       </li>
+                        <li class="list-group-item task-item">
+               <div class="col-md-12">
+               <button id="toggleAllatom">Input structure on/off</button>
+               <button id="toggleSidechains2">Side-chains on/off</button>
+               </div>
+                        </li>
                         {% endif %}
 
                        <li class="list-group-item task-item">
@@ -399,6 +416,25 @@ Created {{ task.created_date  }}
                          
                            </div>
                            </li>
+
+{% if task.md_mdpdb %}
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> Trajectory NGL viewer</div>
+                         <div class="col-md-10" id="viewport_traj"
+                         style="width:500px;height:500px;"> 
+                         </div>
+                       </li>
+                        <li class="list-group-item task-item">
+               <div class="col-md-6">
+<input id="clipRange" type="range" value=0 min=0 max= {% widthratio task.md_nstep task.md_ntwx 1 %} step=1 ></input><span id="clipRange_val">0</span> frame
+</div>
+<div class="col-md-6">
+<button id="toggleRunMDs">run/pause MD</button>  
+<button id="toggleSidechains1">side-chains on/off</button>                       
+</div>
+                        </li>
+
+{% endif %}
                            
                        <li class="list-group-item task-item">
                          <div class="col-md-2"> Radius of gyration based
@@ -435,7 +471,7 @@ Created {{ task.created_date  }}
                          src="/myfiles/download-file/{{task.jobdirname}}/fluct_plot.png"
                          width="500"> </div>
                        </li>
-
+<!--
                        <li class="list-group-item task-item">
                          <div class="col-md-2"> fluctuations putty on
                          starting structure</div>
@@ -446,6 +482,15 @@ Created {{ task.created_date  }}
                          src="/myfiles/download-file/{{task.jobdirname}}/fluct.png"
                          width="500"></a> </div>
                        </li>
+-->
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> fluctuations putty on
+                         starting structure NGL viewer</div>
+                         <div class="col-md-10" id="viewport_putty"
+                         style="width:500px;height:500px;"> 
+                         </div>
+                       </li>
+
                        
                           {% endif %}
 
@@ -513,7 +558,7 @@ Created {{ task.created_date  }}
                           {% if task.saxs_data != "" %}
                        <li class="list-group-item task-item">
                          <div class="col-md-2"> P(r) of input SAXS data and
-                         calculated for 5 models </div>
+                         calculated for 5 models and the input pdb</div>
                          <div class="col-md-10"> <img 
                          src="/myfiles/download-file/{{task.jobdirname}}/saxs.png"
                          width="500"> </div>
@@ -533,7 +578,7 @@ Created {{ task.created_date  }}
        </li>           
                        
                         <div class="model">
-                       <li class="list-group-item task-item">
+<!--                   <li class="list-group-item task-item">
                          <div class="col-md-2"> model1 after conversion
                          to allatom 
                          {{ task.remd_model1|linebreaks }}
@@ -544,10 +589,29 @@ Created {{ task.created_date  }}
                          <img
                          src="/myfiles/download-file/{{task.jobdirname}}/model1.png" width="500">
                          </a></div>
+                       </li> -->                       
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> model1 after conversion 
+                         to allatom {{ task.remd_model1|linebreaks }}
+                         NGL viewer</div>
+                         <div class="col-md-10" id="viewport_M1"
+                         style="width:500px;height:500px;"> 
+                         </div>
                        </li>
+                        <li class="list-group-item task-item">
+               <div class="col-md-12">
+               {% if task.md_pdbref %}
+               <button id="toggleRefM1">Reference structure on/off</button>
+               {% endif %}
+               <button id="toggleSidechainsM1">Side-chains on/off</button>
+               <a class="btn btn-default"
+               href="/myfiles/download-file/{{task.jobdirname}}/MODEL1.pdb">Download</a>               
+               </div>
+                        </li>
+                       
                        </div>
                        <div class="model">
-                       <li class="list-group-item task-item">
+<!--                   <li class="list-group-item task-item">
                          <div class="col-md-2"> model2 after conversion
                          to allatom 
                          {{ task.remd_model2|linebreaks }}
@@ -558,10 +622,30 @@ Created {{ task.created_date  }}
                          <img
                          src="/myfiles/download-file/{{task.jobdirname}}/model2.png" width="500">
                          </a></div>
+                       </li> -->
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> model2 after conversion 
+                         to allatom {{ task.remd_model2|linebreaks }}
+                         NGL viewer</div>
+                         <div class="col-md-10" id="viewport_M2"
+                         style="width:500px;height:500px;"> 
+                         </div>
                        </li>
+                        <li class="list-group-item task-item">
+               <div class="col-md-12">
+               {% if task.md_pdbref %}
+               <button id="toggleRefM2">Reference structure on/off</button>
+               {% endif %}
+               <button id="toggleSidechainsM2">Side-chains on/off</button>
+               <a class="btn btn-default"
+               href="/myfiles/download-file/{{task.jobdirname}}/MODEL2.pdb">Download</a>               
+               </div>
+                        </li>
+                       
+                       
                        </div>
                        <div class="model">
-                       <li class="list-group-item task-item">
+<!--                   <li class="list-group-item task-item">
                          <div class="col-md-2"> model3 after conversion
                          to allatom 
                          {{ task.remd_model3|linebreaks }}
@@ -572,10 +656,29 @@ Created {{ task.created_date  }}
                          <img
                          src="/myfiles/download-file/{{task.jobdirname}}/model3.png" width="500">
                          </a></div>
+                       </li>-->
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> model3 after conversion 
+                         to allatom {{ task.remd_model3|linebreaks }}
+                         NGL viewer</div>
+                         <div class="col-md-10" id="viewport_M3"
+                         style="width:500px;height:500px;"> 
+                         </div>
                        </li>
+                        <li class="list-group-item task-item">
+               <div class="col-md-12">
+               {% if task.md_pdbref %}
+               <button id="toggleRefM3">Reference structure on/off</button>
+               {% endif %}
+               <button id="toggleSidechainsM3">Side-chains on/off</button>
+               <a class="btn btn-default"
+               href="/myfiles/download-file/{{task.jobdirname}}/MODEL3.pdb">Download</a>               
+               </div>
+                        </li>
+                       
                        </div>
                        <div class="model">
-                       <li class="list-group-item task-item">
+<!--                   <li class="list-group-item task-item">
                          <div class="col-md-2"> model4 after conversion
                          to allatom 
                          {{ task.remd_model4|linebreaks }}
@@ -586,10 +689,29 @@ Created {{ task.created_date  }}
                          <img
                          src="/myfiles/download-file/{{task.jobdirname}}/model4.png" width="500">
                          </a></div>
+                       </li>-->
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> model4 after conversion 
+                         to allatom {{ task.remd_model4|linebreaks }}
+                         NGL viewer</div>
+                         <div class="col-md-10" id="viewport_M4"
+                         style="width:500px;height:500px;"> 
+                         </div>
                        </li>
+                        <li class="list-group-item task-item">
+               <div class="col-md-12">
+               {% if task.md_pdbref %}
+               <button id="toggleRefM4">Reference structure on/off</button>
+               {% endif %}
+               <button id="toggleSidechainsM4">Side-chains on/off</button>
+               <a class="btn btn-default"
+               href="/myfiles/download-file/{{task.jobdirname}}/MODEL4.pdb">Download</a>               
+               </div>
+                        </li>
+                       
                        </div>
                        <div class="model">
-                       <li class="list-group-item task-item">
+<!--                   <li class="list-group-item task-item">
                          <div class="col-md-2"> model5 after conversion
                          to allatom 
                          {{ task.remd_model5|linebreaks }}
@@ -600,7 +722,26 @@ Created {{ task.created_date  }}
                          <img
                          src="/myfiles/download-file/{{task.jobdirname}}/model5.png" width="500">
                          </a></div>
+                       </li>-->
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> model5 after conversion 
+                         to allatom {{ task.remd_model5|linebreaks }}
+                         NGL viewer</div>
+                         <div class="col-md-10" id="viewport_M5"
+                         style="width:500px;height:500px;"> 
+                         </div>
                        </li>
+                        <li class="list-group-item task-item">
+               <div class="col-md-12">
+               {% if task.md_pdbref %}
+               <button id="toggleRefM5">Reference structure on/off</button>
+               {% endif %}
+               <button id="toggleSidechainsM5">Side-chains on/off</button>
+               <a class="btn btn-default"
+               href="/myfiles/download-file/{{task.jobdirname}}/MODEL5.pdb">Download</a>               
+               </div>
+                        </li>
+                       
                        </div>
                        {% endif %}
 
@@ -609,6 +750,7 @@ Created {{ task.created_date  }}
        </ul>
        
 <script src="/static/jquery.min.js"></script>
+<script src="https://unpkg.com/ngl"></script>
 
 <script>
 $('.majorpointslegend').click(function(){
@@ -621,8 +763,130 @@ $('.majorpointslegend').click(function(){
 });
 </script>
 
+{% if task.type == "remd" %}
 <script>
+function display_model(numstr){
+
+{% if task.md_pdbref %}
+  var stage = new NGL.Stage("viewport_M"+numstr);
+  stage.setParameters( { backgroundColor: "white",fogFar: 60, fogNear: 45 } );
+  Promise.all([
+      stage.loadFile( "/myfiles/download-file/{{task.jobdirname}}/plik1.pdb" ,{defaultRepresentation: false}) .then( function( o ){
+        o.addRepresentation( "cartoon",{ name:"ref", color:"grey"
+        })
+        o.addRepresentation( "line", {name:"refsc",visible: false,
+         sele:"not hydrogen and sidechainAttached"
+        })    
+        return o
+      }),
+      stage.loadFile(
+      "/myfiles/download-file/{{task.jobdirname}}/MODEL"+numstr+".pdb",{defaultRepresentation: false}) .then( function( o ){
+ {% if task.damino %}
+        o.addRepresentation( "licorice",{ name: "unres", color:
+               "residueindex",colorScale:["blue","cyan", "green",
+               "yellow","orange", "red"], sele:".CA"
+                       })
+        o.addRepresentation( "licorice",{ name: "unressc", visible: false, color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange", "red"]
+        , sele:"*" })    
+ {% else %}
+        o.addRepresentation( "cartoon",{ name: "unres", color:
+               "residueindex",colorScale:["blue","cyan", "green",
+               "yellow","orange", "red"]
+                       })
+        o.addRepresentation( "line",{ name: "unressc", visible: false, color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange", "red"]
+        , sele:"not hydrogen and sidechainAttached" })    
+ {% endif %}
+        return o
+      })
+  ]).then(function (ol1) {
+   ol1[ 0 ].superpose(ol1[ 1 ], false, ".CA")
+   ol1[ 0 ].autoView()
+  })             
+            var ref=true;
+            var side=false;
+            var toggleAll = document.getElementById( "toggleRefM"+numstr );
+            toggleAll.addEventListener( "click", function(){
+                        ref=! ref;                                
+                       stage.getRepresentationsByName(
+                               "ref" ).list.forEach( function( repre ){
+                               repre.setVisibility( !repre.visible );
+                       } );
+               if (side) {
+                       stage.getRepresentationsByName(
+                               "refsc" ).list.forEach( function( repre ){
+                               repre.setVisibility( !repre.visible );
+                       } );
+               }
+
+            } );
+     var toggleSidechains =document.getElementById("toggleSidechainsM"+numstr );
+     toggleSidechains.addEventListener( "click", function(){
+             side=!side;
+             if (ref) {
+                stage.getRepresentationsByName(
+                       "refsc" ).list.forEach( function( repre ){
+                       repre.setVisibility( !repre.visible );
+            } );
+      }
+      stage.getRepresentationsByName("unressc").list.forEach( function( repre ){
+                       repre.setVisibility( !repre.visible );
+       } );
+
+      } );
+{% else %}
+  var stage = new NGL.Stage("viewport_M"+numstr);
+  stage.setParameters( { backgroundColor: "white",fogFar: 60, fogNear: 45 } );
+  stage.loadFile( "/myfiles/download-file/{{task.jobdirname}}/MODEL"+numstr+".pdb",{defaultRepresentation: false}) .then( function( o ){
+ {% if task.damino %}
+        o.addRepresentation( "licorice",{ name: "unres", color:
+               "residueindex",colorScale:["blue","cyan", "green",
+               "yellow","orange", "red"],sele:".CA"
+                       });
+        o.addRepresentation( "licorice",{ name: "unressc", visible: false, color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange", "red"]
+        , sele:"*" });
+ {% else %}
+        o.addRepresentation( "cartoon",{ name: "unres", color:
+               "residueindex",colorScale:["blue","cyan", "green",
+               "yellow","orange", "red"]
+                       });
+        o.addRepresentation( "line",{ name: "unressc", visible: false, color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange", "red"]
+        , sele:"not hydrogen and sidechainAttached" });
+ {% endif %}
+        o.autoView();
+  })             
+     var toggleSidechains =document.getElementById("toggleSidechainsM"+numstr );
+     toggleSidechains.addEventListener( "click", function(){
+      stage.getRepresentationsByName("unressc").list.forEach( function( repre ){
+                       repre.setVisibility( !repre.visible );
+       } );
+
+      } );
+
+{% endif %}
+}
+
+
+window.addEventListener("resize", 
+function (event) {
+      stage.handleResize();
+},false);
+
+
+display_model("1")
+
+
 var slideIndex = 1;
+var y = document.getElementsByClassName("model");
+var lista=[];
+var ii;
+for (ii = 0; ii < y.length; ii++) {
+ lista.push(0)
+}
+lista[0]=1;
 showDivs(slideIndex);
 
 function plusDivs(n) {
@@ -638,8 +902,28 @@ function showDivs(n) {
      x[i].style.display = "none";
   }
   x[slideIndex-1].style.display = "block";
+  
+  if (lista[slideIndex-1] == 0 && slideIndex == 2) {
+    display_model("2")  
+  }
+  
+  if (lista[slideIndex-1] == 0 && slideIndex == 3) {
+     display_model("3")  
+  }
+
+  if (lista[slideIndex-1] == 0 && slideIndex == 4) {
+     display_model("4")  
+  }
+
+  if (lista[slideIndex-1] == 0 && slideIndex == 5) {
+     display_model("5")  
+  }
+    
+  
+  if (lista[slideIndex-1] == 0) {lista[slideIndex-1]=1}
 }
 </script>
+{% endif %}
 
 {% if not task.done %}
 <script>
@@ -664,5 +948,195 @@ $(document).ready(function() {
 </script>
 {% endif %} 
        
-       
+
+{% if task.type == "min" %}
+<script>
+window.addEventListener("resize",
+     function (event) {
+     stage.handleResize();
+     },false);
+               
+var stage = new NGL.Stage("viewport_min");
+stage.setParameters( { backgroundColor: "white" } );
+Promise.all([
+  stage.loadFile( "/myfiles/download-file/{{task.jobdirname}}/file_GB000.pdb" ,{defaultRepresentation: false}) .then( function( o ){
+     o.addRepresentation( "backbone",{ color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange", "red"]
+     })
+     o.addRepresentation( "licorice",{ color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange","red"]
+     })    
+     return o
+  }),
+      
+  stage.loadFile("/myfiles/download-file/{{task.jobdirname}}/plik.pdb",{defaultRepresentation: false}) .then( function( o ){
+     o.addRepresentation( "backbone",{ name: "allatom", color:
+       "residueindex",colorScale:["blue","cyan", "green","yellow","orange", "red"]
+     })
+     o.addRepresentation( "line",{ name: "allatomsc", color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange", "red"]
+       ,sele:"not hydrogen and sidechainAttached" 
+     })    
+     return o
+  })
+]).then(function (ol) {
+   ol[ 0 ].superpose(ol[ 1 ], false, ".CA")
+   ol[ 0 ].autoView()
+})             
+
+var allatom=true;
+var side=true;
+var toggleAll = document.getElementById( "toggleAllatom" );
+toggleAll.addEventListener( "click", function(){
+                        allatom=! allatom;                                
+                       stage.getRepresentationsByName(
+                               "allatom" ).list.forEach( function( repre ){
+                               repre.setVisibility( !repre.visible );
+                       } );
+            if (side) {
+                       stage.getRepresentationsByName(
+                               "allatomsc" ).list.forEach( function( repre ){
+                               repre.setVisibility( !repre.visible );
+                       } );
+            }
+} );
+var toggleSidechains = document.getElementById("toggleSidechains2" );
+toggleSidechains.addEventListener( "click", function(){
+          side=!side;
+          if (allatom) {
+               stage.getRepresentationsByName(
+                       "allatomsc" ).list.forEach( function( repre ){
+                               repre.setVisibility( !repre.visible );
+               } );
+                                                     
+         }
+         stage.getRepresentationsByName("licorice").list.forEach( function( repre ){
+               repre.setVisibility( !repre.visible );
+         } );
+
+} );
+</script>
+{% endif %}
+
+{% if task.type == "md" and task.md_start == "pdbstart" %}
+<script>
+window.addEventListener("resize",
+     function (event) {
+     stage.handleResize();
+     },false);
+
+var stage = new NGL.Stage("viewport_putty");
+stage.setParameters( { backgroundColor: "white" } );
+
+var tooltip = document.createElement("div")
+Object.assign(tooltip.style, {
+  display: "none",
+  position: "fixed",
+  zIndex: 10,
+  pointerEvents: "none",
+  backgroundColor: "rgba( 0, 0, 0, 0.6 )",
+  color: "lightgrey",
+  padding: "8px",
+  fontFamily: "sans-serif"
+})
+document.body.appendChild(tooltip)
+
+stage.loadFile("/myfiles/download-file/{{task.jobdirname}}/plik_bf.pdb", {defaultRepresentation: false}).then 
+       (function ( o ){
+       o.addRepresentation("tube",{ color: "bfactor" , scale: 0.25,
+       sele: "backbone",
+       radius:"bfactor",
+       colorScale:["blue","cyan", "green", "yellow","orange", "red"] });
+       o.addRepresentation("licorice",{sele:"sidechainAttached and CYS and not hydrogen"});
+       o.autoView();
+})
+
+// remove default hoverPick mouse action
+stage.mouseControls.remove("hoverPick")
+
+stage.signals.hovered.add(function (pickingProxy) {
+  if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {
+    var atom = pickingProxy.atom || pickingProxy.closestBondAtom
+    var mp = pickingProxy.mouse.position
+    var bf= atom.bfactor.toFixed(2)
+    tooltip.innerText = atom.qualifiedName()+" Fluctuation="+ bf
+    tooltip.style.bottom = window.innerHeight - mp.y + 3 + "px"
+    tooltip.style.left = mp.x + 3 + "px"
+    tooltip.style.display = "block"
+  } else {
+    tooltip.style.display = "none"
+  }
+})
+</script>
+{% endif %}    
+
+{% if task.type == "md" and task.md_mdpdb %}
+<script>
+window.addEventListener("resize",
+     function (event) {
+     stage.handleResize();
+     },false);
+
+      var stage = new NGL.Stage("viewport_traj");
+      stage.setParameters( { backgroundColor: "white" } );
+      stage.setParameters( { cameraType: "orthographic" } ); 
+      var traj;
+      var player;
+      stage.loadFile( "/myfiles/download-file/{{task.jobdirname}}/file_MD000.pdb", { 
+       asTrajectory: true } ) .then( function( o ){
+        o.setName ("unres_md");
+        o.addRepresentation( "backbone",{ color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange", "red"]
+        });
+        o.addRepresentation( "licorice",{ color:
+       "residueindex",colorScale:["blue","cyan", "green", "yellow","orange", "red"]
+        });        
+        o.autoView();
+        o.addTrajectory();
+      });
+
+            var toggleSidechains = document.getElementById( "toggleSidechains1" );
+            toggleSidechains.addEventListener( "click", function(){
+                                                       stage.getRepresentationsByName( "licorice" ).list.forEach( function( repre ){
+                                                                       repre.setVisibility( !repre.visible );
+                                                       } );
+            } );
+
+
+      function numberWithCommas(x) {
+                return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
+      }
+      var toggleRunMDs = document.getElementById( "toggleRunMDs" );
+      var isRunning = false;
+      toggleRunMDs.addEventListener( "click", function(){
+         var trajComp = stage.getComponentsByName("unres_md").list[0].trajList[0];
+         var player = new NGL.TrajectoryPlayer(trajComp.trajectory, {timeout: 10, mode: "once"});
+                               if( !isRunning ){
+                                       player.play();
+                                       isRunning = true;
+
+                    trajComp.signals.frameChanged.add(function(){
+                      var fnum=trajComp.trajectory.currentFrame;                   
+                      clipRange.value = fnum;
+                      clipRange_val.innerHTML = numberWithCommas(parseInt(clipRange.value*1));
+                    });
+
+                               }else{
+                                       player.play();
+                                       player.pause();
+                                       isRunning = false;
+                               }
+      } );      
+      var clipRange = document.getElementById( "clipRange" );
+      var clipRange_val = document.getElementById( "clipRange_val" );
+      clipRange.oninput = function( e ){
+                var trajComp = stage.getComponentsByName("unres_md").list[0].trajList[0];
+                trajComp.setFrame(e.target.value)
+                clipRange_val.innerHTML = numberWithCommas(parseInt(e.target.value*1));
+      };      
+
+</script>
+{% endif %}    
+
+
 {% endblock %}