Giter VIP home page Giter VIP logo

rexgen_direct's People

Contributors

bobbyjudd avatar connorcoley avatar

rexgen_direct's Issues

Fix mol_graph.py bug when loading custom dataset

In rexgen_direct/core_wln_global/nntest_direct.py the line:
smiles2graph_batch = partial(_s2g, idxfunc=lambda x:x.GetIntProp('molAtomMapNumber') - 1)

The lambda body x.GetIntProp('molAtomMapNumber') tries to reference an integer property for and Atom object. See the RDKit docs about this property: https://www.rdkit.org/docs/RDKit_Book.html?highlight=molatommapnumber#magic-property-values

When running the custom Patent DB dataset, this code generates a KeyError:

File "nntest_direct.py", line 191, in
bindex_to_o = {val:key for key, val in bo_to_index.iteritems()}
AttributeError: 'dict' object has no attribute 'iteritems'
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/bobby/anaconda3/envs/my-rdkit-env/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/home/bobby/anaconda3/envs/my-rdkit-env/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "nntest_direct.py", line 168, in read_data
src_tuple = smiles2graph_batch(src_batch)
File "/home/bobby/projects/ucla/cs260/final_proj/rexgen_direct/rexgen_direct/core_wln_global/mol_graph.py", line 143, in smiles2graph_list
res = list(map(lambda x:smiles2graph(x,idxfunc), smiles_list))
File "/home/bobby/projects/ucla/cs260/final_proj/rexgen_direct/rexgen_direct/core_wln_global/mol_graph.py", line 143, in
res = list(map(lambda x:smiles2graph(x,idxfunc), smiles_list))
File "/home/bobby/projects/ucla/cs260/final_proj/rexgen_direct/rexgen_direct/core_wln_global/mol_graph.py", line 81, in smiles2graph
idx = idxfunc(atom)
File "nntest_direct.py", line 52, in
smiles2graph_batch = partial(_s2g, idxfunc=lambda x:x.GetIntProp('molAtomMapNumber') - 1)
KeyError: 'molAtomMapNumber'

The included preprocessed datasets (train.txt.proc, test.txt.proc, valid.txt.proc) do not generate this error, however both datasets have been preprocessed by the prep_data.py script.

Need to determine what is unique to the custom dataset that is causing that is causing the error.

Add route to webserver for visualizing custom dataset predictions

Add another route to the Django app to host the visualization of the prediction output on the custom dataset. The route should be at http://localhost:8000/visualize/custom.

Start by adding the custom route here:

urlpatterns = [
path('', views.index, name='index'),
path('ajax', views.display, name='display')
]

Then add view functions (index and display) for custom here

def index(request):
return render(request, 'example.html', {})
def display(request):
print('Got request')
data = {'err': False}
index = int(request.GET.get('index', 1))
showmap = json.loads(request.GET.get('showmap', 'true'))
highlight = int(request.GET.get('highlight', 0))
print(index)
atts = [highlight] if highlight else []
img = do_index(index - 1, showmap=showmap, atts=atts)
buffered = BytesIO()
img.save(buffered, format="png")
img_str = base64.b64encode(buffered.getvalue()).decode()
data['img_str'] = img_str
data['index'] = index
return JsonResponse(data)

The index and display functions will be pretty much the same but the display function needs to specify the correct dataset when calling do_index() and also need to add another html template to request the new custom display route.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.