Beispiel #1
0
    def test_load_single_file(self):
        with open(self.fpath, 'rb') as f:
            binary = f.read()

        ctrl = main_app()
        file_input_control = ctrl.control_panels['PeptideFileInputControl']

        file_input_control.input_files = [binary]
        assert file_input_control.fd_state == 'Full deuteration control'
        assert file_input_control.fd_exposure == 0.0

        file_input_control.fd_state = self.control[0]
        file_input_control.fd_exposure = self.control[1]

        file_input_control.exp_state = self.state
        assert file_input_control.exp_exposures == [
            0.0, 0.167, 0.5, 1.0, 5.0, 10.0, 100.000008
        ]
        file_input_control._action_add_dataset()

        assert self.state in ctrl.data_objects
        series = ctrl.data_objects[self.state]

        assert series.Nt == 7
        assert series.Np == 63
        assert series.Nr == 146
        # Py39 result:                              54.054873258574965
        # assert np.nanmean(series.scores_stack) == 54.05487325857497
        assert abs(np.nanmean(series.rfu_residues) - 0.540548732585749) < 1e-6
Beispiel #2
0
    def test_load_files(self):
        with open(self.fpath, 'rb') as f:
            binary = f.read()

        ctrl = main_app()
        file_input_control = ctrl.control_panels['PeptideFileInputControl']

        file_input_control.input_files = [binary]
        file_input_control.norm_mode = 'Theory'
        file_input_control.be_percent = 0.

        file_input_control.exp_state = self.state
        assert file_input_control.exp_exposures == [
            0.167, 0.5, 1.0, 5.0, 10.0, 30., 100.
        ]
        file_input_control._action_add_dataset()

        assert self.state in ctrl.fit_objects
        fit_object = ctrl.fit_objects[self.state]
        series = fit_object.series

        assert series.Nt == 7
        assert series.Np == 7
        assert series.Nr == 38
Beispiel #3
0
    def test_batch_mode(self):

        fpath_1 = directory / 'test_data' / 'ecSecB_apo.csv'
        fpath_2 = directory / 'test_data' / 'ecSecB_dimer.csv'

        fpaths = [fpath_1, fpath_2]
        files = [p.read_bytes() for p in fpaths]

        ctrl = main_app(client=None)
        file_input = ctrl.control_panels['PeptideFileInputControl']

        file_input.input_files = files
        file_input.fd_state = 'Full deuteration control'
        file_input.fd_exposure = 0.167

        file_input.exp_state = 'SecB WT apo'
        file_input.dataset_name = 'testname_123'
        file_input._action_add_dataset()

        #assert ....

        file_input.exp_state = 'SecB his dimer apo'
        file_input.dataset_name = 'SecB his dimer apo'  # todo catch error duplicate name
        file_input._action_add_dataset()

        initial_guess = ctrl.control_panels['InitialGuessControl']
        initial_guess._action_fit()

        # Wait until fitting futures are completed
        while len(ctrl.future_queue) > 0:
            ctrl.check_futures()
            time.sleep(0.1)

        #assert ....

        fit_control = ctrl.control_panels['FitControl']
        fit_control.epochs = 10

        fit_control.fit_name = 'testfit_1'
        fit_control._action_fit()

        # Wait until fitting futures are completed
        while len(ctrl.future_queue) > 0:
            ctrl.check_futures()
            time.sleep(0.1)
        #assert ....

        table = ctrl.sources['dataframe'].get('global_fit')

        # Test classification
        # todo test log space
        # todo probably values should be fixed otherwise tests are co-dependent
        values = table['testfit_1']['testname_123']['deltaG']
        classification = ctrl.control_panels['ClassificationControl']
        classification._action_otsu()

        cmap, norm = classification.get_cmap_and_norm()
        colors = cmap(norm(values), bytes=True)

        assert colors.sum() == 68474
        assert colors.std() == 109.39692637364178

        classification.mode = 'Continuous'
        classification._action_linear()

        cmap, norm = classification.get_cmap_and_norm()
        colors = cmap(norm(values), bytes=True)

        assert colors.sum() == 73090
        assert colors.std() == 89.41501408256475

        value_widget = classification.widgets['value_2']
        value_widget.value = 10e3

        cmap, norm = classification.get_cmap_and_norm()
        colors = cmap(norm(values), bytes=True)

        assert colors.sum() == 73097
        assert colors.std() == 91.9688274382922

        classification.mode = 'Color map'
        classification.library = 'colorcet'
        classification.color_map = 'CET_C1'
        cmap, norm = classification.get_cmap_and_norm()

        colors = cmap(norm(values), bytes=True)

        assert colors.sum() == 117289
        assert colors.std() == 64.90120978241222
Beispiel #4
0
 def test_global_fit(self):
     ctrl = main_app()
Beispiel #5
0
 def test_classification(self):
     ctrl = main_app()
Beispiel #6
0
 def test_initial_guesses(self):
     ctrl = main_app()
Beispiel #7
0
 def test_coverage(self):
     ctrl = main_app()
Beispiel #8
0
 def test_file_download_output(self):
     ctrl = main_app()
Beispiel #9
0
    def test_initial_guesses_and_fit(self):
        ctrl = main_app(client=None)
        ctrl.data_objects[self.series.name] = self.series

        ctrl.control_panels['InitialGuessControl']._action_fit()
Beispiel #10
0
import panel as pn
from pyhdx.panel.apps import main_app  #, diff_app, single_app, folding_app, full_deuteration_app
from pyhdx.panel.base import STATIC_DIR
import numpy as np
import torch

from pyhdx.panel.config import ConfigurationSettings
from pyhdx.support import verify_cluster

import logging
from functools import partial
from pathlib import Path
import datetime

APP_DICT = {
    'main': lambda: main_app().template,
    # 'single': lambda: single_app().template,
    # 'diff': lambda: diff_app().template,
    # 'folding': lambda: folding_app().template,
    # 'full_deuteration': lambda: full_deuteration_app().template
}


def run_main():
    np.random.seed(43)
    torch.manual_seed(43)

    cluster = ConfigurationSettings().cluster
    if verify_cluster(cluster):
        print("Welcome to the PyHDX server!")
Beispiel #11
0
"""

from pyhdx.fileIO import read_dynamx, txt_to_np, csv_to_dataframe
from pyhdx import PeptideMasterTable
import pickle
from pyhdx.panel.apps import main_app
from pyhdx.panel.utils import reload_previous
from pyhdx.panel.base import DEFAULT_COLORS, STATIC_DIR
from pyhdx.panel.sources import DataSource
from pyhdx.batch_processing import load_from_yaml
from pyhdx.fileIO import csv_to_protein
import panel as pn
import numpy as np
from pathlib import Path

ctrl = main_app()
directory = Path(__file__).parent
root_dir = directory.parent.parent
data_dir = root_dir / 'tests' / 'test_data'
test_dir = directory / 'test_data'

fpath_1 = root_dir / 'tests' / 'test_data' / 'ecSecB_apo.csv'
fpath_2 = root_dir / 'tests' / 'test_data' / 'ecSecB_dimer.csv'

fpaths = [fpath_1, fpath_2]
files = [p.read_bytes() for p in fpaths]


d1 = {
    'filenames': ['ecSecB_apo.csv', 'ecSecB_dimer.csv'],
    'd_percentage': 95,