added chem drawer

This commit is contained in:
Navan Chauhan 2020-08-06 12:16:50 +05:30
parent bd877cc2e9
commit a4619c59d9
4 changed files with 26 additions and 4 deletions

View File

@ -1,6 +1,6 @@
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileRequired, FileAllowed from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import StringField, DecimalField, IntegerField from wtforms import StringField, DecimalField, IntegerField, SelectField
from wtforms.validators import DataRequired, Email from wtforms.validators import DataRequired, Email
@ -36,3 +36,4 @@ class statusForm(FlaskForm):
class generateSMILES(FlaskForm): class generateSMILES(FlaskForm):
n = IntegerField('Number of Molecules to Generate',default=1,validators=[DataRequired()]) n = IntegerField('Number of Molecules to Generate',default=1,validators=[DataRequired()])
#modelSelection = SelectField('Model',choices=[("alpha","Alpha"),("beta","Beta")])

View File

@ -10,6 +10,10 @@
{{ form.n.label }} {{ form.n.label }}
{{ form.n(class="form-control")}} {{ form.n(class="form-control")}}
</div> </div>
<!--<div class="form-row">
{\{ form.modelSelection.label }}
{\{ form.modelSelection(class="form-control")}}
</div>-->
<br> <br>
<div class="form-row"> <div class="form-row">
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">Submit</button>
@ -17,8 +21,23 @@
</form> </form>
{% if result %} {% if result %}
</b>what the frick</b> </b>Generated Compounds</b>
<i>{{result}}</i> <script src="https://unpkg.com/smiles-drawer@1.0.10/dist/smiles-drawer.min.js"></script>
<script>
let options = {};
let smilesDrawer = new SmilesDrawer.Drawer(options);
</script>
{% for x in range(result|length) %}
<!--<i>{\{result}}</i>-->
<p>{{result[x]}}</p>
<canvas id="canvas-{{x}}" width="500" height="500"></canvas>
<script>
SmilesDrawer.parse('{{result[0]}}', function(tree) {
smilesDrawer.draw(tree, "canvas-{{x}}", "dark", false);
console.log(smilesDrawer.draw(tree, "canvas-{{x}}", "light", false))
});
</script>
{% endfor %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -6,6 +6,7 @@
<ul> <ul>
<li><a href="{{ url_for('dock_upload') }}">Dock and Report</a></li> <li><a href="{{ url_for('dock_upload') }}">Dock and Report</a></li>
<li><a href="{{ url_for('status')}}">Job Status</a></li> <li><a href="{{ url_for('status')}}">Job Status</a></li>
<li><a href="{{ url_for('generate') }}">Generate</a></li>
</ul> </ul>
<img src="{{url_for('static',filename='assets/workingInALaboratory.svg')}}" /> <img src="{{url_for('static',filename='assets/workingInALaboratory.svg')}}" />

View File

@ -142,6 +142,7 @@ def generate():
if request.method == 'POST' and form.validate_on_submit(): if request.method == 'POST' and form.validate_on_submit():
result = gen.sample(form.n.data) result = gen.sample(form.n.data)
print(tfWorking)
if tfWorking == 0: if tfWorking == 0:
flash("Failed to initialise the model!","danger") flash("Failed to initialise the model!","danger")
else: else: