def show_struc(click_data, stage): if stage == len(GPARAMS.Esoinn_setting.Model.learn_history_edge): speckdata = xyz_reader.read_xyz(datapath_or_datastring=representstruc[ click_data['points'][0]['pointIndex']], is_datafile=False) else: speckdata = xyz_reader.read_xyz( datapath_or_datastring=representstruc[0], is_datafile=False) return speckdata
def update_molecule(molecule_fname, upload_contents): data = {} if upload_contents is not None and molecule_fname is None: try: content_type, content_string = upload_contents.split(',') data = base64.b64decode(content_string).decode('UTF-8') except AttributeError: pass data = read_xyz(data, is_datafile=False) elif molecule_fname is not None: data = read_xyz(molecule_fname) return data
def tab_content(active_tab, memory): if 'point' not in memory: raise PreventUpdate mol_name = DATA.iloc[memory['point']].xyz_file_name path = structures_dir + '/' + mol_name if active_tab == 'tab-speck': mol = xyz_reader.read_xyz(datapath_or_datastring=path, is_datafile=True) mol_plot = dashbio.Speck( id='my-speck', data=mol, view={ 'zoom': 0.06, 'resolution': 450, # 'ao': 0.1, 'outline': 0.001, 'atomScale': 0.15, 'relativeAtomScale': 0.33, 'bonds': True }, presetView='stickball', ) else: mol = aio.read(path) model_data = xyz_to_json(mol) mol = xyz_reader.read_xyz(datapath_or_datastring=path, is_datafile=True) mol_plot = html.Div([ dashbio.Molecule2dViewer( id='my-dashbio-molecule2d', modelData=model_data, width=450, height=400, ), # html.Hr(style={'padding-top': '0pt'}), html.Div(id='molecule2d-output') ]) return mol_plot
def display_click_data(clickData): input_in = json.dumps(clickData, indent=2) #print(elements) curveNumber = json.loads(input_in)['points'][0]['curveNumber'] Index = json.loads(input_in)['points'][0]['pointIndex'] + 1 print(curveNumber) if curveNumber == 3: data_in = f'./test_out/{Index}.xyz' molecule = xyz_reader.read_xyz(datapath_or_datastring=data_in, is_datafile=True) return speck_component(Index, molecule) #print(f'notebooks/test_out/{Index}.xyz') elif curveNumber == 2: pass else: pass return json.dumps(clickData, indent=2)
def update_output(n_clicks,value): smile=str(value) slist=[] slist.append(smile) ##mol = [Chem.MolFromSmiles(s) for s in slist] ##img = Draw.MolsToGridImage(mol, molsPerRow=1,subImgSize=(250, 200),) ## plogp = [env.penalized_logp(m) for m in mol] #run model optimization property_name='plogp' debug=True src,new_smiles=constrain_optimization_smiles_input(smile,model, property_model,device, data_name, property_name, atomic_num_list, debug, sim_cutoff=0.0) mol_optm = Molecule.from_file("dash_output/constr_opt_input.sdf") mol_optm.write_to_file("dash_output/constr_opt_input.xyz") data=xyz_reader.read_xyz('dash_output/constr_opt_input.xyz') return data,src,"Optimized SMILES: {}".format(new_smiles)
import dash_html_components as html import dash_core_components as dcc from dash_bio_utils import xyz_reader external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) data = urlreq.urlopen( 'https://raw.githubusercontent.com/plotly/dash-bio-docs-files/master/' + 'speck_methane.xyz').read() if PY3: data = data.decode('utf-8') data = xyz_reader.read_xyz(data_string=data) app.layout = html.Div([ dcc.Dropdown(id='speck-preset-views', options=[{ 'label': 'Default', 'value': 'default' }, { 'label': 'Ball and stick', 'value': 'stickball' }], value='default'), dashbio.Speck(id='my-speck', data=data), ])
Refset.Load() try: representid = GPARAMS.Esoinn_setting.Model.represent_strucid except: signallist = np.array([i.EGCM for i in Refset.mols]) signallist = (signallist - GPARAMS.Esoinn_setting.scalemin) / ( GPARAMS.Esoinn_setting.scalemax - GPARAMS.Esoinn_setting.scalemin) signallist[~np.isfinite(signallist)] = 0 representid = GPARAMS.Esoinn_setting.Model.select_represent_struc( signallist) GPARAMS.Esoinn_setting.Model.Save() representstruc = [] for i in range(len(representid)): xyzstr = Refset.mols[representid[i]].transstr() representstruc.append(xyzstr) speckdata = xyz_reader.read_xyz(datapath_or_datastring=representstruc[0], is_datafile=False) moddevlist = [[[] for j in range(GPARAMS.Train_setting.Trainstage)] for i in range(len(GPARAMS.MD_setting))] templist = [[[] for j in range(GPARAMS.Train_setting.Trainstage)] for i in range(len(GPARAMS.MD_setting))] timelist = [[[] for j in range(GPARAMS.Train_setting.Trainstage)] for i in range(len(GPARAMS.MD_setting))] graphlist = [] modeldev = [[] for j in range(GPARAMS.Train_setting.Trainstage)] for i in range(len(GPARAMS.MD_setting)): timemask = 0 moddevdatlist = [] tempdatlist = [] for j in range(GPARAMS.Train_setting.Trainstage): MDout = '%s/%s_%d' % (GPARAMS.MD_setting[i].Name, GPARAMS.MD_setting[i].Name, j)
import json from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.keys import Keys import dash import dash_bio import dash_html_components as html from dash_bio_utils import xyz_reader from common_features import simple_app_layout, simple_app_callback _data = None with open('tests/dashbio_demos/sample_data/speck_methane.xyz', 'r') as f: _data = xyz_reader.read_xyz(datapath_or_datastring=f.read(), is_datafile=False) _COMPONENT_ID = 'test-speck' def test_dbsp001_rotate(dash_duo): app = dash.Dash(__name__) app.layout = html.Div(dash_bio.Speck(id=_COMPONENT_ID, data=_data)) dash_duo.start_server(app) dash_duo.wait_for_element('#' + _COMPONENT_ID) speck = dash_duo.find_element('#' + _COMPONENT_ID + ' canvas') ac = ActionChains(dash_duo.driver)
import json from dash_bio_utils import pdb_parser, protein_reader, \ styles_parser, xyz_reader with open('mol3d_model_data.json', 'w+') as f: f.write( pdb_parser.create_data( '../dashbio_demos/dash-molecule-3d-viewer/data/1bna.pdb')) with open('mol3d_styles_data.json', 'w+') as f: f.write( styles_parser.create_style( '../dashbio_demos/dash-molecule-3d-viewer/data/1bna.pdb', 'cartoon', 'atom')) with open('sequence_viewer_data.json', 'w+') as f: f.write( json.dumps( protein_reader.read_fasta( datapath_or_datastring= '../dashbio_demos/dash-sequence-viewer/data/P01308.fasta.txt') [0])) with open('speck_data.json', 'w+') as f: f.write( json.dumps( xyz_reader.read_xyz( datapath_or_datastring= '../dashbio_demos/dash-speck/data/methane.xyz')))
from dash.dependencies import Input, Output import dash_html_components as html import dash_bio as dashbio import urllib.request as urlreq import base64 import dash_bio_utils.xyz_reader as xyz_reader data = urlreq.urlopen("https://raw.githubusercontent.com/plotly/dash-bio/master/tests/dashbio_demos/dash-speck/data/methane.xyz").read().decode("utf-8") data = xyz_reader.read_xyz(data, is_datafile=False) component = html.Div(dashbio.Speck( data=data, id='speck', presetView='default', scrollZoom=True ), style={'transform': 'scale(0.5)', 'margin-top': '-190px'}) component_image = html.Div(html.Img( src='data:image/png;base64,{}'.format( base64.b64encode( open( './images/pic_speck.png', 'rb' ).read() ).decode() ), style={'width': '768px', 'margin-left': '0px', 'float': 'left'} ), style={'transform': 'scale(0.5)'})
import json from dash_bio_utils import pdb_parser, protein_reader, \ styles_parser, xyz_reader with open('mol3d_model_data.json', 'w+') as f: f.write(pdb_parser.create_data( '../dashbio_demos/sample_data/molecule3d_1bna.pdb' )) with open('mol3d_styles_data.json', 'w+') as f: f.write(styles_parser.create_style( '../dashbio_demos/sample_data/molecule3d_1bna.pdb', 'cartoon', 'atom' )) with open('sequence_viewer_data.json', 'w+') as f: f.write(json.dumps(protein_reader.read_fasta( datapath_or_datastring='../dashbio_demos/sample_data/sequence_viewer_P01308.fasta.txt' )[0])) with open('speck_data.json', 'w+') as f: f.write(json.dumps(xyz_reader.read_xyz( datapath_or_datastring='../dashbio_demos/sample_data/speck_methane.xyz' )))