Difference between revisions of "Team:Heidelberg/internal tools"

(Prevents NaN for numbers to seq)
Line 482: Line 482:
 
                   
 
                   
  
<div style="padding-top: 80px; background-color:white;">
+
<div style="padding-top: 80px; background-color:white;">
<div class="t-container">
+
        <div class="t-container">
<div class="t-col t-col_12">
+
            <div class="t-col t-col_12">
                                                        <div class="container-fluid" style="margin-top: 10px;" id="container1">
+
                <div class="container-fluid" style="margin-top: 10px;" id="container1">
                                                                <h1>Internal Tools</h1>
+
                    <h1>Internal Tools</h1>
                                                                    <h2>Number of mutations and mutated sequences</h2>
+
                        <h2>Number of mutations and mutated sequences</h2>
                                                                    <p>Expected number of mutations in a single sequence:  
+
                        <p>Expected number of mutations in a single sequence:  
                                                                        $$p_{m} = \frac{N_{mutations}}{L_{Sequence}} = N_{generations} \cdot r_{mutation} = t_{total} \cdot \Phi \cdot r_{mutation}$$
+
                            $$p_{m} = \frac{N_{mutations}}{L_{Sequence}} = N_{generations} \cdot r_{mutation} = t_{total} \cdot \Phi \cdot r_{mutation}$$
                                                                    </p>
+
                        </p>
                                                                    <p>The expected share of sequences that shows at least one mutation in \(L_{Sequence}\) bp is the probability that \(L_{sequence}\) basepairs stay unchanged when \(\frac{N_{mutations}}{L_{Sequence}}\) mutations are expected:
+
                        <p>The expected share of sequences that shows at least one mutation in \(L_{Sequence}\) bp is the probability that \(L_{sequence}\) basepairs stay unchanged when \(\frac{N_{mutations}}{L_{Sequence}}\) mutations are expected:
                                                                    $$p_{M} = \frac{N_{mutated}}{N_{Sequences}} = 1 - p(N_{mutations}=0) = 1 - (1-p_{m})^{L_{Sequence}} $$
+
                        $$p_{M} = \frac{N_{mutated}}{N_{Sequences}} = 1 - p(N_{mutations}=0) = 1 - (1-p_{m})^{L_{Sequence}} $$
                                                                    </p>
+
                        </p>
                                                                    <p>With this equation we can also calculate the number of sequences \(N_{Sequences}\) that have to be sequenced in order to find a mutated one with a probability of \(p(N_{mutated} > 0)\).
+
                        <p>With this equation we can also calculate the number of sequences \(N_{Sequences}\) that have to be sequenced in order to find a mutated one with a probability of \(p(N_{mutated} > 0)\).
                                                                    $$ N_{Sequences} = \frac{p(N_{mutated} > 0)}{p_{M}} $$
+
                        $$ N_{Sequences} = \frac{p(N_{mutated} > 0)}{p_{M}} $$
                                                                    </p>
+
                        </p>
                                                                    <p>The probability to find at least one mutated sequence under the given conditions is
+
                        <p>The probability to find at least one mutated sequence under the given conditions is
                                                                    $$p(N_{mutated}>0) = 1 - (1-p_{M})^{N_{sequences}}$$
+
                        $$p(N_{mutated}>0) = 1 - (1-p_{M})^{N_{sequences}}$$
                                                                    which gives  
+
                        which gives  
                                                                    $$N_{Sequences} = \frac{ln(1-p(N_{mutated}>0))}{ln(1-p_{M})}$$
+
                        $$N_{Sequences} = \frac{ln(1-p(N_{mutated}>0))}{ln(1-p_{M})}$$
                                                                    </p>
+
                        </p>
                                                                    <p>Set \(\Phi\) to zero to use the number of generations for the calculation. If \(\Phi\) and the number of generations are given, \(\Phi\) is used.</p>
+
                        <p>Set \(\Phi\) to zero to use the number of generations for the calculation. If \(\Phi\) and the number of generations are given, \(\Phi\) is used.</p>
                                                                    <p>Consider \(L_{Sequence}\) as the number of basepairs that is expected to be mutated. If half of the sequence you are interested in, is highly conserved choose a lower \(L_{Sequence}\).</p>
+
                        <p>Consider \(L_{Sequence}\) as the number of basepairs that is expected to be mutated. If half of the sequence you are interested in, is highly conserved choose a lower \(L_{Sequence}\).</p>
  
                                                       
+
 
                                                      <form action="" id="form1">
+
              <form action="" id="form1">
                                                        <section>
+
                <section>
                                                        <h2>Get your mutations</h2>
+
                <h2>Get your mutations</h2>
                                                        <ul class="input-list style-1 clearfix">
+
                <ul class="input-list style-1 clearfix">
                                                          <li>
+
                  <li>
                                                            <label>
+
                    <label>
                                                                  Mutation rate \(r_{mutation} [bp/generation]\)   
+
                          Mutation rate \(r_{mutation} [bp/generation]\)   
                                                                <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="mr" value="0" lang='en-150' step="any">
+
                        <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="mr" value="0" lang='en-150' step="any">
                                                                </label>
+
                        </label>
                                                          </li>
+
                  </li>
                                                        <li>
+
                <li>
                                                                <label>
+
                        <label>
                                                                Flow troughLagoon \(\Phi_{lagoon} [Volumes/h]\)
+
                        Flow troughLagoon \(\Phi_{lagoon} [Volumes/h]\)
                                                                <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="phi" value="0" lang='en-150' step="any">
+
                        <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="phi" value="0" lang='en-150' step="any">
                                                                </label>
+
                        </label>
                                                            </li>
+
                    </li>
                                                        <li>
+
                <li>
                                                                <label>
+
                        <label>
                                                                  Total time<br> in lagoon \(t_{total} [h]\)
+
                          Total time<br> in lagoon \(t_{total} [h]\)
                                                                <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="tt" value="0" lang='en-150' step="any">
+
                        <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="tt" value="0" lang='en-150' step="any">
                                                                </label>
+
                        </label>
                                                            </li>
+
                    </li>
                                                        <li>
+
                <li>
                                                                <label>
+
                        <label>
                                                                  Number<br> of generations  \(N_{generations}\)
+
                          Number<br> of generations  \(N_{generations}\)
                                                                <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="ng" value="0" lang='en-150' step="any">
+
                        <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="ng" value="0" lang='en-150' step="any">
                                                                </label>
+
                        </label>
                                                            </li>
+
                    </li>
                                                            <li>
+
                    <li>
                                                                <label>
+
                        <label>
                                                                  Length of sequence that can mutate \(L_{Sequence} [bp]\)<br>
+
                          Length of sequence that can mutate \(L_{Sequence} [bp]\)<br>
                                                                <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="ls" value="0" lang='en-150' step="any">
+
                        <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="ls" value="0" lang='en-150' step="any">
                                                                </label>  
+
                        </label>  
                                                            </li>
+
                    </li>
                                                            <li>
+
                    <li>
                                                                <label>
+
                        <label>
                                                                Number of sequences that are sequenced \(N_{Sequences}\)<br>
+
                        Number of sequences that are sequenced \(N_{Sequences}\)<br>
                                                                <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="ns" value="0" lang='en-150' step="any">
+
                        <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="ns" value="0" lang='en-150' step="any">
                                                                </label>
+
                        </label>
                                                            </li>
+
                    </li>
                                                            <li>
+
                    <li>
                                                              <label>
+
                      <label>
                                                                Probability to get at least one mutated result  \(p(N_{mutated}>0) \)
+
                        Probability to get at least one mutated result  \(p(N_{mutated}>0) \)
                                                                <br>
+
                        <br>
                                                                <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="pm" value="0.9" lang='en-150' step="any">
+
                        <input type="number" pattern="[0-9]+([,\.][0-9]+)?" id="pm" value="0.9" lang='en-150' step="any">
                                                                </label>  
+
                        </label>  
                                                            </li>
+
                    </li>
                                                            <li>
+
                    <li>
                                                            <div style="padding-top: 30px;">
+
                    <div style="padding-top: 30px;">
                                                              <input type="button" value="Submit" id="input_form" onclick="return number_mutations();">     
+
                      <input type="button" value="Submit" id="input_form" onclick="return number_mutations();">     
                                                                </div>
+
                        </div>
                                                            </li>
+
                    </li>
                                                        </ul>
+
                </ul>
                                                      </section>  
+
              </section>  
                                                        </form>
+
                </form>
                                                      </div>
+
              </div>
                                                        <div class="container-fluid" style="margin-top: 10px;" id="container2">
+
                <div class="container-fluid" style="margin-top: 10px;" id="container2">
                                                                    <p id="warnings_mutations"></p>
+
                            <p id="warnings_mutations"></p>
                                                                    <br>
+
                            <br>
                                                                    <p id="number_generations"></p>
+
                            <p id="number_generations"></p>
                                                                    <p>\(p_{m} =\) <span id="amount_mutations"></span> %(bp/bp).</p>
+
                            <p>\(p_{m} =\) <span id="amount_mutations"></span> %(bp/bp).</p>
                                                                    <p>\(N_{mutations} =\) <span id="number_mutations"></span> bp per sequence.</p>
+
                            <p>\(N_{mutations} =\) <span id="number_mutations"></span> bp per sequence.</p>
                                                                    <p>The share of sequences that shows at least one mutation in \(L_{Sequence}\) bp is \(p_{M}=\) <span id="amount_mutated"></span> % of sequences</p>
+
                            <p>The share of sequences that shows at least one mutation in \(L_{Sequence}\) bp is \(p_{M}=\) <span id="amount_mutated"></span> % of sequences</p>
                                                                    <p id="probability_positive_sequencing"></p>
+
                            <p id="probability_positive_sequencing"></p>
                                                                    <p id="number_to_seq"></p>
+
                            <p id="number_to_seq"></p>
                                                                   
+
                   
                                                    </div>
+
                   
                                                </div>
+
                <div class="container-fluid" style="margin-top: 10px;" id="container1">
                                            </div>
+
                    <h2>Diff tool</h2>
 +
                        <p>Marks differences in two strings.
 +
                    </p>
 +
 
 +
 
 +
              <form action="" id="form2">
 +
                <section>
 +
                <ul class="input-list style-1 clearfix">
 +
                  <li>
 +
                    <label>
 +
                        String 1
 +
                        <br>
 +
                        <textarea id="str1" lang='en-150' rows=8 cols=50></textarea>
 +
                        </label>
 +
                  </li>
 +
                <li>
 +
                        <label>
 +
                        String 2
 +
                        <br>
 +
                            <textarea id="str2" lang='en-150' rows=8 cols=50></textarea>
 +
                        </label>
 +
                    </li>
 +
               
 +
                    <li>
 +
                    <div style="padding-top: 30px;">
 +
                      <input type="button" value="Submit" id="input_form2" onclick="return differences();">   
 
                         </div>
 
                         </div>
 +
                    </li>
 +
                </ul>
 +
              </section>
 +
                </form>
 +
                    </div>
 +
                    <div style="overflow:scroll !important; height:200px !important;">
 +
                        <p>Comparison:</p>
 +
                        <span id="outstr1" style="display:inline !important"></span>
 +
                        <br>
 +
                        <span id="outstr2" style="display:inline !important"></span>
 +
                    </div>
 +
                    <p id="diffinfo"></p>
 +
              </div>
 +
            </div>
 +
        </div>
 +
    </div>
 +
</div>
  
 
                                            
 
                                            
Line 719: Line 761:
 
}   
 
}   
 
      
 
      
 +
function differences(){
 +
    //get the values
 +
    var str1 = document.getElementById('str1').value;
 +
    var str2 = document.getElementById('str2').value;
 +
   
 +
    //initialise variables
 +
    var diff = [];
 +
    var outstr1 = "";
 +
    var outstr2 = "";
 +
    var diffs = 0;
 +
    var lendiffs = 0;
 +
    var diffinfo = "";
 +
    //calculate
 +
    var i = 0;
 +
    while((i < str1.length) && (i < str2.length)){
 +
        if(str1[i]==str2[i]){
 +
            outstr1 += str1[i];
 +
            outstr2 += str2[i];
 +
        }
 +
        else{
 +
            diffs += 1;
 +
            outstr1 += '<span style="color: red">' + str1[i] + '</span>';
 +
            outstr2 += '<span style="color: red">' + str2[i] + '</span>';
 +
        }
 +
        i++;
 +
    }
 +
    while(i < str1.length){
 +
        outstr1 = outstr1 + '<span style="color: blue">' + str1[i] + '</span>';
 +
        i++;
 +
        lendiffs++;
 +
    }
 +
    while(i < str2.length){
 +
        outstr2 = outstr2 + '<span style="color: blue">' + str2[i] + '</span>';
 +
        i++;
 +
        lendiffs++;
 +
    }
 +
    diffinfo = "The strings are different for " + diffs + "positions and their length differs by " + lendiffs + " positions.";
 +
   
 +
    //return the results
 +
    $("#outstr1").html(outstr1);
 +
    $("#outstr2").html(outstr2);
 +
    $("#diffinfo").html(diffinfo);
  
 +
    //end the function
 +
    return false;
 +
}
  
  

Revision as of 20:28, 21 September 2017

WikitemplateA home - 2014.igem.org

 

WikitemplateA home

From 2014.igem.org

Internal Tools

Number of mutations and mutated sequences

Expected number of mutations in a single sequence: $$p_{m} = \frac{N_{mutations}}{L_{Sequence}} = N_{generations} \cdot r_{mutation} = t_{total} \cdot \Phi \cdot r_{mutation}$$

The expected share of sequences that shows at least one mutation in \(L_{Sequence}\) bp is the probability that \(L_{sequence}\) basepairs stay unchanged when \(\frac{N_{mutations}}{L_{Sequence}}\) mutations are expected: $$p_{M} = \frac{N_{mutated}}{N_{Sequences}} = 1 - p(N_{mutations}=0) = 1 - (1-p_{m})^{L_{Sequence}} $$

With this equation we can also calculate the number of sequences \(N_{Sequences}\) that have to be sequenced in order to find a mutated one with a probability of \(p(N_{mutated} > 0)\). $$ N_{Sequences} = \frac{p(N_{mutated} > 0)}{p_{M}} $$

The probability to find at least one mutated sequence under the given conditions is $$p(N_{mutated}>0) = 1 - (1-p_{M})^{N_{sequences}}$$ which gives $$N_{Sequences} = \frac{ln(1-p(N_{mutated}>0))}{ln(1-p_{M})}$$

Set \(\Phi\) to zero to use the number of generations for the calculation. If \(\Phi\) and the number of generations are given, \(\Phi\) is used.

Consider \(L_{Sequence}\) as the number of basepairs that is expected to be mutated. If half of the sequence you are interested in, is highly conserved choose a lower \(L_{Sequence}\).

Get your mutations


\(p_{m} =\) %(bp/bp).

\(N_{mutations} =\) bp per sequence.

The share of sequences that shows at least one mutation in \(L_{Sequence}\) bp is \(p_{M}=\) % of sequences

Diff tool

Marks differences in two strings.

Comparison: