restart for md and remd
[django_unres.git] / django_simple / todo / templates / details.html
index 44f5e62..d32f9fe 100644 (file)
@@ -43,6 +43,18 @@ Created {{ task.created_date  }}
                                <div class="col-md-8">
                                        {% if task.done %}
                                                <span class="fa fa-check-square-o"></span>
+                                           {% if task.type == "md" or task.type == "remd" %}
+                                             <form action="restart/"
+                                               method="get"
+                                               style="text-align;float:right;">
+                                               {% csrf_token %}
+                                                <input type="submit" 
+                                                class="btn btn-default" 
+                                                value="Restart"
+                                                name="restartbtn">
+                                                </button>
+                                              </form>
+                                            {% endif %}  
                                        {% else %}
                                          {% if task.running > 0  %}
                                                <span class="fa fa-spinner
@@ -165,6 +177,10 @@ Created {{ task.created_date  }}
                            <div class="col-md-6">{{ task.md_nstep}}</div>
                        </li>           
                        <li class="list-group-item task-item">
+                           <div class="col-md-6"> total steps (with restarts) </div>
+                           <div class="col-md-6">{{ task.md_total_steps}}</div>
+                       </li>           
+                       <li class="list-group-item task-item">
                            <div class="col-md-6"> ntwe </div>
                            <div class="col-md-6">{{ task.md_ntwe}}</div>
                        </li>           
@@ -209,7 +225,7 @@ Created {{ task.created_date  }}
                        
         {% endif %}
 
-        {% if task.type == "remd" %}
+        {% if task.type == "remd" or task.type == "dock" %}
 
                        <li class="list-group-item task-item">
                            <div class="col-md-6"> nrep </div>
@@ -228,6 +244,17 @@ Created {{ task.created_date  }}
                            <div class="col-md-6"> pdb code</div>
                            <div class="col-md-6">{{ task.pdbcode }}</div>
                        </li>           
+                       {% if task.type == "dock" %}
+                       <li class="list-group-item task-item">
+                           <div class="col-md-6"> input pdb2 </div>
+                           <div class="col-md-6">{{ task.myfile2 }}</div>
+                       </li>           
+                       <li class="list-group-item task-item">
+                           <div class="col-md-6"> pdb code2</div>
+                           <div class="col-md-6">{{ task.pdbcode2 }}</div>
+                       </li>           
+                       
+                       {% endif %}
                        <li class="list-group-item task-item">
                            <div class="col-md-6"> seed </div>
                            <div class="col-md-6">{{ task.md_seed}}</div>
@@ -236,6 +263,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>
@@ -245,6 +278,10 @@ Created {{ task.created_date  }}
                            <div class="col-md-6">{{ task.md_nstep}}</div>
                        </li>           
                        <li class="list-group-item task-item">
+                           <div class="col-md-6"> total steps (with restarts) </div>
+                           <div class="col-md-6">{{ task.md_total_steps}}</div>
+                       </li>           
+                       <li class="list-group-item task-item">
                            <div class="col-md-6"> ntwe </div>
                            <div class="col-md-6">{{ task.md_ntwe}}</div>
                        </li>           
@@ -344,7 +381,7 @@ Created {{ task.created_date  }}
                            <div class="col-md-2"> Etot </div>
                            <div class="col-md-10">{{ task.etot }}</div>
                        </li>           
-                       
+<!--                   
                        <li class="list-group-item task-item">
                          <div class="col-md-2"> UNRES model </div>
                          <div class="col-md-10"> 
@@ -354,6 +391,14 @@ Created {{ task.created_date  }}
                          src="/myfiles/download-file/{{task.jobdirname}}/unres.png"
                          width="500"></a> </div>
                        </li>
+-->
+                       <li class="list-group-item task-item">
+                         <div class="col-md-2"> UNRES model NGL viewer</div>
+                         <div class="col-md-10" id="viewport_unres"
+                         style="width:500px;height:500px;"> 
+                         </div>
+                       </li>
+
 
 <!--
                        <li class="list-group-item task-item">
@@ -402,7 +447,8 @@ Created {{ task.created_date  }}
                            <div class="col-md-2"> Movie </div>
                            <div class="col-md-10"> 
 
-                            <video width="500" height="400" preload controls>
+                            <video width="500" height="400"
+                            preload="auto" controls="controls">
                             <source
                             src="/myfiles/download-file/{{task.jobdirname}}/md.ogv"
                             type="video/ogg; codecs=theora"> </source>
@@ -420,7 +466,7 @@ Created {{ task.created_date  }}
                        </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
+<input id="clipRange" type="range" value=0 min=0 max= {% widthratio task.md_total_steps 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>  
@@ -492,7 +538,7 @@ Created {{ task.created_date  }}
 
                        {% endif %}
                        
-                       {% if task.type == "remd" %}
+                       {% if task.type == "remd" or task.type == "dock" %}
                        
                        <li class="list-group-item task-item">
                          <div class="col-md-2"> Energy histogram </div>
@@ -572,7 +618,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 }}
@@ -583,10 +629,32 @@ 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 
+                         {% if not task.damino %}
+                         after conversion to allatom 
+                         {% endif %}
+                         {{ 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 }}
@@ -597,10 +665,33 @@ 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 
+                         {% if not task.damino %}
+                         after conversion to allatom
+                         {% endif %}
+                         {{ 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 }}
@@ -611,10 +702,32 @@ 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 
+                         {% if not task.damino %}
+                         after conversion to allatom
+                         {% endif %}
+                         {{ 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 }}
@@ -625,10 +738,32 @@ 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 
+                         {% if not task.damino %}
+                         after conversion to allatom
+                         {% endif %}
+                         {{ 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 }}
@@ -639,7 +774,29 @@ 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 
+                         {% if not task.damino %}
+                         after conversion to allatom 
+                         {% endif %}
+                         {{ 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 %}
 
@@ -648,6 +805,7 @@ Created {{ task.created_date  }}
        </ul>
        
 <script src="/static/jquery.min.js"></script>
+<script src="https://unpkg.com/ngl"></script>
 
 <script>
 $('.majorpointslegend').click(function(){
@@ -660,9 +818,130 @@ $('.majorpointslegend').click(function(){
 });
 </script>
 
-{% if task.type == "remd" %}
+{% if task.type == "remd" or task.type == "dock" %}
 <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[ 1 ].superpose(ol1[ 0 ], 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) {
@@ -678,6 +957,25 @@ 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 %}
@@ -703,9 +1001,8 @@ $(document).ready(function() {
   setTimeout(worker, 30000);
 });
 </script>
-{% endif %} 
-       
-<script src="https://unpkg.com/ngl"></script>
+{% endif %}    
+
 {% if task.type == "min" %}
 <script>
 window.addEventListener("resize",
@@ -713,6 +1010,74 @@ window.addEventListener("resize",
      stage.handleResize();
      },false);
                
+var stage_unres = new NGL.Stage("viewport_unres");
+stage_unres.setParameters( { backgroundColor: "white" } );
+/**
+[color_Red, color_Green, color_Blue, ellipsoid_width, ellipsoid_length ]
+*/
+var resdb = {   'CYS': [1.000, 1.000, 0.000, 1.33741, 2.96868],
+                'MET': [0.000, 1.000, 0.000, 1.36694, 3.08863],
+                'PHE': [0.000, 0.392, 0.000, 1.48323, 3.04238],
+                'ILE': [0.000, 1.000, 0.000, 1.44098, 3.17389],
+                'LEU': [0.000, 1.000, 0.000, 1.51054, 2.52078],
+                'VAL': [0.000, 1.000, 0.000, 1.42072, 2.68924],
+                'TRP': [0.000, 0.392, 0.000, 1.23867, 3.47403],
+                'TYR': [0.596, 0.984, 0.596, 1.23060, 3.35434],
+                'ALA': [0.000, 1.000, 0.000, 1.23266, 1.72686],
+                'GLY': [1.000, 1.000, 1.000, 1.24626, 1.11383],
+                'THR': [1.000, 0.000, 1.000, 1.28674, 2.59210],
+                'SER': [1.000, 0.000, 1.000, 1.22820, 1.68800],
+                'GLN': [1.000, 0.000, 1.000, 1.24239, 2.22201],
+                'ASN': [1.000, 0.000, 1.000, 1.24447, 2.24946],
+                'GLU': [1.000, 0.000, 0.000, 1.25448, 2.05551],
+                'ASP': [1.000, 0.000, 0.000, 1.25417, 1.77556],
+                'HIS': [1.000, 0.000, 1.000, 1.21103, 3.02627],
+                'ARG': [0.000, 0.000, 1.000, 1.13573, 3.25143],
+                'LYS': [0.000, 0.000, 1.000, 1.22604, 4.50054],
+                'PRO': [0.000, 1.000, 1.000, 1.35131, 2.20525]
+                        };
+stage_unres.loadFile("/myfiles/download-file/{{task.jobdirname}}/file_GB000.pdb", {defaultRepresentation: false}).then
+       (function ( o ){
+       var shape = new NGL.Shape("shape")
+       var chain = ""
+       o.addRepresentation("licorice");
+       o.structure.eachAtom(function(atom){
+         if (atom.atomname == "CA" && atom.chainname == chain) {
+          px=CAx+(atom.x-CAx)/2;
+          py=CAy+(atom.y-CAy)/2;
+          pz=CAz+(atom.z-CAz)/2;
+          shape.addSphere([px,py,pz],[0.643, 0.933, 0.960],0.6,"p");
+         }
+         if (atom.atomname == "CA") {
+         chain= atom.chainname
+         CAx= atom.x;
+         CAy= atom.y
+         CAz= atom.z
+         }
+         if (atom.atomname == "CB") {
+          mx = (atom.x-CAx);
+          my = (atom.y-CAy);
+          mz = (atom.z-CAz);
+          norm=Math.sqrt(mx*mx+my*my+mz*mz);
+          res=atom.resname;
+          var longaxis=resdb[res][4]
+          var shortaxis=resdb[res][3]
+          mx = mx /norm*longaxis;
+          my = my /norm*longaxis;
+          mz = mz /norm*longaxis;
+          resn=res+atom.resno
+          shape.addEllipsoid([ atom.x, atom.y, atom.z ], 
+              [ resdb[res][0], resdb[res][1], resdb[res][2]], 
+              shortaxis, [ mx, my, mz ], [ 0, shortaxis, 0 ],resn);
+         }
+       });
+       var shapeComp = stage_unres.addComponentFromObject(shape)
+       shapeComp.addRepresentation("buffer")
+       o.autoView();
+});
+
+
+
 var stage = new NGL.Stage("viewport_min");
 stage.setParameters( { backgroundColor: "white" } );
 Promise.all([