Ejemplo n.º 1
0
    def use_upload(
            contents,
            demostr,
            mol_style,
            color_style,
            mt,
            custom_colors
    ):

        if demostr is not None:
            copy2(demostr, './str.pdb')
            fname = './str.pdb'
        elif contents is not None and demostr is None:
            try:
                content_type, content_string = str(contents).split(',')
                decoded_contents = base64.b64decode(
                    content_string).decode("UTF-8")
                f = tempfile.NamedTemporaryFile(
                    suffix=".pdb", delete=False, mode='w+')
                f.write(decoded_contents)
                fname = f.name
                f.close()
            except AttributeError:
                pass
        else:
            return 'demostr and contents are none'

        # Create the model data from the decoded contents
        modata = parser.create_data(fname)

        fmodel = files_data_style(modata)
        with open(fmodel) as fm:
            mdata = json.load(fm)

        # Create the cartoon style from the decoded contents
        datstyle = sparser.create_style(fname, mol_style, color_style, **custom_colors)

        fstyle = files_data_style(datstyle)
        with open(fstyle) as sf:
            data_style = json.load(sf)

        # Delete all the temporary files that were created
        for x in [fname, fmodel, fstyle]:
            if os.path.isfile(x):
                os.unlink(x)
            else:
                pass

        # Return the new molecule visualization container
        return dash_bio.Molecule3dViewer(
            id='mol-3d',
            selectionType='atom',
            modelData=mdata,
            styles=data_style,
            selectedAtomIds=[],
            backgroundOpacity='0',
            atomLabelsShown=False,
        )
import dash
import dash_bio
import dash_html_components as html
from dash_bio_utils import pdb_parser as parser, styles_parser as sparser

from common_features import simple_app_layout, simple_app_callback

_model_data = None
_styles_data = None

_model_data = json.loads(
    parser.create_data(
        'tests/dashbio_demos/dash-molecule-3d-viewer/data/1bna.pdb'))
_styles_data = json.loads(
    sparser.create_style(
        'tests/dashbio_demos/dash-molecule-3d-viewer/data/1bna.pdb', 'cartoon',
        'atom'))

_COMPONENT_ID = 'test-mol3d'


def test_dbm3001_selection_type(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        simple_app_layout(
            dash_bio.Molecule3dViewer(id=_COMPONENT_ID,
                                      modelData=_model_data,
                                      styles=_styles_data)))
Ejemplo n.º 3
0
    fdat.write(content)
    dataFile = fdat.name
    fdat.close()
    return dataFile

fname = 'data/Figure-To-Manipulate.pdb'
# Create the model data from the decoded contents
modata = parser.create_data(fname)

fmodel = files_data_style(modata)

with open(fmodel) as fm:
    mdata = json.load(fm)

# Create the cartoon style from the decoded contents
datstyle = sparser.create_style(fname, 'cartoon', 'residue', **{})

fstyle = files_data_style(datstyle)
with open(fstyle) as sf:
    data_style = json.load(sf)

pdb = dbc.Card(
    [
        html.H4("Potential allosteric site of IP-10 (CXCL10) oligomer (PDB entry = 1O80).", className="card-title"),
        #html.H6("a subtitle about pdb file", className="card-subtitle"),
        html.P(
            "Our initial network analysis revealed that IP-10/CXCL10 might be a beneficial protein target for reducing cytokine storm in COVID-19 patients if inhibited by a small molecule for example. We have identified a potentially druggable allosteric site for follow-up in silico screening against compound databases (e.g. BindingDB - https://www.bindingdb.org/bind/index.jsp). Please feel free to manipulate the structure to gain more insight. ",
            className="card-text",
        ),
        html.Div(
            [
Ejemplo n.º 4
0
from selenium.webdriver.common.action_chains import ActionChains

import dash
import dash_bio
import dash_html_components as html
from dash_bio_utils import pdb_parser as parser, styles_parser as sparser

from common_features import simple_app_layout, simple_app_callback

_model_data = None
_styles_data = None

_model_data = json.loads(
    parser.create_data('tests/dashbio_demos/sample_data/molecule3d_1bna.pdb'))
_styles_data = json.loads(
    sparser.create_style('tests/dashbio_demos/sample_data/molecule3d_1bna.pdb',
                         'cartoon', 'atom'))

_COMPONENT_ID = 'test-mol3d'


def test_dbm3001_selection_type(dash_duo):

    app = dash.Dash(__name__)

    app.layout = html.Div(
        simple_app_layout(
            dash_bio.Molecule3dViewer(id=_COMPONENT_ID,
                                      modelData=_model_data,
                                      styles=_styles_data)))

    simple_app_callback(app,
Ejemplo n.º 5
0
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'
    )))