def default_traits_view(self): view = KromView( VGroup( HGroup( Item("model.name", editor=TextEditor(auto_set=True, enter_set=True)), Spring(), Item("model.model_type", style='readonly', label="Type"), Spring(), Item("model.target_product", style='readonly')), VGroup( Item("model.is_kinetic", label="Is Kinetic", editor=BooleanEditor()), VGroup( Item('param_formula_str', style="readonly", show_label=False), Item("component_array", label="Comp. Coeff.", show_label=False, editor=self._tabular_editor), ), label="Parameters", show_border=True, ), ), # Relevant when used as standalone view: resizable=True, buttons=OKCancelButtons, default_button=OKButton, title="Configure {} model".format(self.model.model_type)) return view
def default_traits_view(self): if self.standalone: std_buttons = OKCancelButtons else: std_buttons = [CancelButton] view = KromView( VGroup( make_window_title_group(title="User Preferences", include_blank_spaces=False), Item("instructions", style="readonly", resizable=True, show_label=False), Tabbed( Item("ui_prefs_view", editor=InstanceEditor(), style="custom", label="Interface", show_label=False), Item("file_pref_view", editor=InstanceEditor(), style="custom", label="File loading", show_label=False), Item("app_pref_view", editor=InstanceEditor(), style="custom", # even though the group's label is not shown in the # UI, it needs to be set to set the tab name: label="Application", show_label=False), Item("solver_prefs_view", editor=InstanceEditor(), style="custom", label="Solver", show_label=False), ), ), buttons=[save_button, factory_reset_button] + std_buttons, handler=RevealChromatographyPreferenceViewHandler(), default_button=save_button, width=700, title="Edit Reveal Chromatography Preferences", ) return view
def default_traits_view(self): view = KromView( HGroup( VGroup( Group( Item("select_all_collections", label="All"), UItem('displayed_log_collection_names', editor=CheckListEditor( values=self._all_log_collection_names), style='custom'), HGroup( UItem("color_editor"), ), label='Experiments/Simulations', show_border=True, ), Group( UItem('displayed_log_family_names', editor=CheckListEditor( values=self._all_log_family_names, format_func=lambda a: a), style='custom'), label='Plot Grouping', show_border=True, ), visible_when='_show_control' ), VGroup( UItem('_container', editor=ComponentEditor(), show_label=False), show_border=True, ), ), title="Chromatogram Plot", ) return view
class AppPreferencesView(HasStrictTraits): model = Instance(AppPreferenceGroup) view = KromView( VGroup( Item("object.model.user_ds_folder", label="User data storage"), Item("object.model.python_script_folder", label="Python scripts storage"), ), )
class UIPreferencesView(HasStrictTraits): model = Instance(UIPreferenceGroup) view = KromView( VGroup( VGroup( Label("(Requires restart)"), ), Item("object.model.confirm_on_window_close", label="Confirm on project close?"), Item("object.model.auto_close_empty_windows_on_open", label="Auto close empty projects?", tooltip="Auto close empty projects when opening a new one?"), Item("object.model.app_width", label="Default app window width"), Item("object.model.app_height", label="Default app window height"), ) )
class ProjectFileSelector(HasStrictTraits): path_list = List(Str) selected = Either(Str, List(Str)) view = KromView( Item("path_list", show_label=False, editor=ListStrEditor(title='Project(s) to load', selected="selected", editable=False, multi_select=True)), title="Select the project(s) to load", buttons=OKCancelButtons, width=500 ) def _selected_default(self): return []
def default_traits_view(self): from app_common.traitsui.common_traitsui_groups import \ make_window_title_group title = make_window_title_group("Select Plot Colors") msg = "By default, a simulation and the experiment it was built from "\ "share the same color. Check the box to control the color of " \ "all plots and\nun-check to keep simulation colors the same as" \ " their source experiments." connected_colors = VGroup( Label(msg), HGroup( Spring(), Item("disconnected_plots", label="Control simulation colors") ), show_border=False ) items = [] for i, name in enumerate(self.collection_list): if name not in self.collection_map: continue always_visible = "plot_always_visible_{}".format(i) name_attr = "plot_name_{}".format(i) label = getattr(self, name_attr) items.append( Item("plot_color_{}".format(i), label=label, visible_when="disconnected_plots or " + always_visible), ) view = KromView( VGroup( title, connected_colors, VGroup( *items, show_border=True, label="Experiments/Simulations" ), ), buttons=OKCancelButtons, title="Chromatogram Plot Styles", width=400 ) return view
class ComponentSelector(HasStrictTraits): """ Class to support select a set of experiments from a study """ product = Instance(Product) ignore_strip_by_default = Bool(True) component_selected = List(Str) component_name_available = List(Str) view = KromView(Item("component_name_available", editor=ListStrEditor(title='Component List', selected="component_selected", multi_select=True, editable=False), show_label=False), buttons=OKCancelButtons, title="Select components") # Traits listener methods ------------------------------------------------- def _product_changed(self): self.component_name_available = \ self._component_name_available_default() self.component_selected = self._component_selected_default() # Traits initialization methods ------------------------------------------- def _component_selected_default(self): ignore = [] if self.ignore_strip_by_default: ignore.append(STRIP_COMP_NAME) return [ name for name in self.component_name_available if name not in ignore ] def _component_name_available_default(self): if self.product is None: return [] return self.product.product_component_names
class FilePreferencesView(HasStrictTraits): model = Instance(FilePreferenceGroup) view = KromView( VGroup( HGroup( Item("object.model.max_recent_files", editor=spinner_editor, label="Num. Recent Projects (requires restart)", tooltip="Maximum number of recent project paths to " "remember."), ), HGroup( Item("object.model.exp_importer_mass_threshold", label="Experiment import mass balance threshold", tooltip="Max relative mass difference to warn during " "experiment import"), ), ), )
class ExperimentSelector(HasStrictTraits): """ Class to support select a set of experiments from a study """ study = Instance(Study) experiment_selected = List(Str) experiment_name_available = List(Str) view = KromView(Item("experiment_name_available", editor=ListStrEditor(title='Experiment List', selected="experiment_selected", multi_select=True, editable=False), show_label=False), buttons=OKCancelButtons, title="Select experiments") def _experiment_name_available_default(self): return [exp.name for exp in self.study.experiments]
def default_traits_view(self): view = KromView( Item("model.name", tooltip=COMPONENT_NAME_TOOLTIP, editor=TextEditor(invalid='_invalid_name'), enabled_when='name_editable'), Item("model.target_product", enabled_when="target_product_editable"), Item("model.extinction_coefficient", editor=UnitScalarEditor(), width=200), Item("model.molecular_weight", editor=UnitScalarEditor(), tooltip="Molecular weight of the component in kilo-Daltons " "(1 kDa=1 kg/mol)"), # Relevant when used as standalone view: buttons=OKCancelButtons, title=self.title) return view
def traits_view(self): no_comp_msg = ('No components were found targeting the requested ' 'product ({}). Please create the needed components ' 'first.'.format(self.target_product)) view = KromView( # Embedding the label in a Group to give it space and work around a # traitsui bug with Label and visible_when (traitsui issues #298) HGroup( Label(no_comp_msg), visible_when='component_names == []' ), Item('component_names', editor=ListStrEditor(selected='selected_component_names', multi_select=True), label="Select component(s)"), Item('create_comp_button', show_label=False), title="Select components to build the product.", resizable=True, buttons=OKCancelButtons, ) return view
def traits_view(self): # Build the view such that the SLURM stuff isn't visible if not # available on the machine elements = [ VGroup( Item("object.model.solver_binary_path", label="Cadet executable"), Item("object.model.input_file_location", label="CADET input folder"), Item("object.model.executor_num_worker", editor=spinner_editor, label="Cadet num. workers (requires restart)"), Item("object.model.cadet_num_threads", editor=spinner_editor, label="Cadet num. threads"), Item('object.model.auto_delete_solver_files_on_exit'), ) ] executable = self.model.slurm_binary if check_slurm_installed(executable=executable): elements[0].label = "General" elements.append( VGroup( Item("object.model.use_slurm_scheduler", tooltip="Submit solver run to SLURM scheduler"), Item("object.model.slurm_binary", visible_when="object.model.use_slurm_scheduler", width=300, tooltip="Command to submit SLURM jobs"), Item("object.model.slurm_partition", visible_when="object.model.use_slurm_scheduler", width=300, tooltip="SLURM scheduler partition to submit jobs."), Item("object.model.slurm_job_name", visible_when="object.model.use_slurm_scheduler", width=300, tooltip="SLURM scheduler job name."), label="SLURM scheduler", ) ) elements = [Tabbed(*elements)] return KromView(*elements)
def traits_view(self): visible_when_sma = "binding_model_type == '{}'".format( STERIC_BINDING_MODEL) visible_when_ph_sma = "binding_model_type == '{}'".format( PH_STERIC_BINDING_MODEL) visible_when_langmuir = "binding_model_type == '{}'".format( LANGMUIR_BINDING_MODEL) visible_when_extern_langmuir = "binding_model_type == '{}'".format( PH_LANGMUIR_BINDING_MODEL) view = KromView(VGroup( HGroup(Spring(), Item("binding_model_type"), Spring()), HGroup(Item('_sma_model_view', editor=InstanceEditor(), show_label=False, style="custom", visible_when=visible_when_sma), Item('_ph_sma_model_view', editor=InstanceEditor(), show_label=False, style="custom", visible_when=visible_when_ph_sma), Item('_langmuir_model_view', editor=InstanceEditor(), show_label=False, style="custom", visible_when=visible_when_langmuir), Item('_ext_langmuir_model_view', editor=InstanceEditor(), show_label=False, style="custom", visible_when=visible_when_extern_langmuir), show_border=True, label="Model parameters"), ), buttons=OKCancelButtons, default_button=OKButton, handler=BindingModelBuilderHandler(), title="Configure new binding model") return view
def default_traits_view(self): view_items = [] for i, calc in enumerate(self.fraction_calculators): calc_name = "_calc_view_{}".format(i) self.add_trait(calc_name, Instance(StripFractionCalculatorView)) calc_view = StripFractionCalculatorView(model=calc) self.trait_set(**{calc_name: calc_view}) view_item = VGroup( Item(calc_name, editor=InstanceEditor(), style="custom", show_label=False), label=calc.experim.name ) view_items.append(view_item) view = KromView( Tabbed(*view_items), title="Strip Fraction Estimation Assistant", buttons=[ResetAllButton, ApplyAllButton], handler=MultiExpStripFractionCalculatorHandler(), ) return view
def default_traits_view(self): view = KromView( VGroup( HGroup( Item("model.name"), Spring(), Item("model.target_product", style='readonly'), ), VGroup( HGroup(Item("model.column_porosity", label="Column Porosity", editor=PositiveFloatEditor()), Item("model.bead_porosity", label="Bead Porosity", editor=PositiveFloatEditor(), tooltip="Protein bead porosity"), label="Porosity", show_border=True), ), VGroup( VGroup( Item("model.axial_dispersion", label="Axial Dispersion", editor=PositiveFloatEditor()), ), VGroup( Item("component_array", label="Comp. Coeff.", show_label=False, editor=self._tabular_editor), ), label="Transport Parameters", show_border=True, ), ), # Relevant when used as standalone view: resizable=True, buttons=OKCancelButtons, default_button=OKButton, title="Configure General Rate model") return view
def default_traits_view(self): landing_text = r"Strip contribution estimation for Experiment " \ r"'<i>{}</i>' (load '<i>{}</i>'), from the specified " \ r"load concentration, method step <br>start times and "\ r"estimated product extinction coefficient:" landing_text = landing_text.format(self.model.experim.name, self._load_solution_name) formula = "strip_fraction = 1 - mass_eluting_before_strip / " \ "loaded_mass" view = KromView( VGroup( VGroup(Label(landing_text), HGroup( Spring(), Label(formula), Spring(), ), show_border=True), VGroup(HGroup( VGroup( Item("object.model.load_concentration", editor=UnitScalarEditor()), Item("object.model.loaded_volume", editor=UnitScalarEditor())), Spring(), VGroup( Spring(), Item("object.model.loaded_mass", editor=UnitScalarEditor(), style="readonly"), Spring(), ), ), show_border=True, label="Product loaded into the column"), HGroup(VGroup( Item("object.model.product_ext_coeff", editor=UnitScalarEditor(), label="Est. product extinction coef."), Item("object.model.load_start", label="Load start time", editor=UnitScalarEditor()), Item("object.model.strip_start", label="Strip start time", editor=UnitScalarEditor()), ), Spring(), VGroup( Spring(), Item("object.model.integrated_mass_before_strip", label="Mass eluting before strip", editor=UnitScalarEditor(), style="readonly"), Spring()), show_border=True, label="Product recovered before Strip"), HGroup( Spring(), Item("object.model.strip_mass_fraction", editor=UnitScalarEditor(), label="Proposed Strip Mass Fraction"), Item("_current_strip_mass_fraction", editor=UnitScalarEditor(), style="readonly", label="Current Strip Mass Fraction"), Spring()), ), title="Strip Fraction Estimation Assistant", buttons=[ResetButton, ApplyButton], handler=StripFractionCalculatorHandler(), ) return view
def traits_view(self): view = KromView( Item("plot", editor=ComponentEditor(), show_label=False)) return view
def traits_view(self): col_pattern_editor = build_col_name_editor(self.all_col_names) filename = basename(self.akta_filepath) spinner_editor = RangeEditor(low=5, high=9999, mode='spinner') time_orig = 'AKTA time from which to import AKTA data and name' \ ' of the corresponding step (typically the load).' search_instructions = 'Hit {}-f to search for a word' search_instructions = search_instructions.format(get_ctrl()) view = KromView( Tabbed( VGroup( VGroup( Label(time_orig), HGroup( Item('time_of_origin', editor=UnitScalarEditor(), show_label=False), Item("akta_start_method_step", label="Method step @ t=0"), ), Item('origin_error_msg', emphasized=True, visible_when='origin_error_msg', style='readonly', label="Note"), show_border=True, label="Time of origin" ), VGroup( Item('patterns_as_list', editor=col_pattern_editor, show_label=False, height=200), Item('pattern_error_msg', emphasized=True, visible_when='pattern_error_msg', style='readonly', label="Error"), show_border=True, label="AKTA Column Types" ), label="AKTA File Settings" ), VGroup( Item('file_preview', editor=CodeEditor(), show_label=False, tooltip=search_instructions), VGroup(Item('length_of_preview', editor=spinner_editor)), show_border=True, label="AKTA File Preview".format(filename), ), VGroup( # Information used to evaluate the loaded product mass Item("mass_bal_analyzer", editor=InstanceEditor(), style="custom", show_label=False), VGroup( HGroup( Item("mass_bal_msg", emphasized=True, style='readonly', show_label=False), ), Item("mass_bal_strategy", label="Adjustment strategy", enabled_when="not mass_balanced"), HGroup( Item("mass_bal_strategy_msg", emphasized=True, style='readonly', show_label=False, enabled_when="not mass_balanced"), ), visible_when="target_experiment and pure_protein_exp" ), label="UV and Mass Balance", ), ), buttons=OKCancelButtons, title="Experiment Importer: {}".format(self.experiment_name), width=900, ) return view
def traits_view(self): component_descr_simple_editor = build_component_descr_editor(False) component_descr_expert_editor = build_component_descr_editor(True) known_products = self.datasource.get_object_names_by_type('products') name_editor = TextWithExcludedValuesEditor( forbidden_values=set(known_products) ) expert_mode_tooltip = "Expert mode: customize assay names, and " \ "control concentration expressions." strip_label = 'Strip component, automatically added to account for' \ ' load mass eluting during the Strip step, if any.' view = KromView( VGroup( HGroup( Item('name', editor=name_editor, width=300), Item('product_type'), ), Item("description", style="custom"), Item('pI', editor=UnitScalarEditor(), label="pI"), HGroup( Spring(), Item('expert_mode', tooltip=expert_mode_tooltip), ), VGroup( Item('component_descs', show_label=False, editor=component_descr_simple_editor), Item('_add_comp_button', show_label=False), HGroup( Spring(), Item('add_strip', tooltip=expert_mode_tooltip), ), VGroup( Label(strip_label), HGroup( Item('strip_component_descs', style='readonly', editor=component_descr_simple_editor, show_label=False, height=40), Item('_edit_strip_comp_button', show_label=False), ), visible_when="add_strip" ), label="Product component names", show_border=True, visible_when="not expert_mode" ), VGroup( Item('component_descs', show_label=False, editor=component_descr_expert_editor, visible_when="expert_mode"), Item('_add_comp_button', show_label=False), label="Product components and concentration expressions", show_border=True, visible_when="expert_mode" ), VGroup( Item('component_assay_names', editor=ASSAY_TABLE_EDITOR, show_label=False), Item("_add_assay_button", show_label=False), label="Component assay values", show_border=True, visible_when="expert_mode" ), ), width=600, height=600, title="Specify New Product Characteristics", buttons=OKCancelButtons ) return view
def traits_view(self): additional_param_controls = self._build_additional_param_editors() param_list_with_cost = [ALL_COST_COL_NAME] + self.param_list two_d_plot_shown = "show_cost_data_nd == '2D' and y_axis_param != " \ "'{}'".format(ALL_COST_COL_NAME) weight_range_editor = RangeEditor(low=0., high=MAX_WEIGHT) weight_doc = Label("The following control the relative importance or " "the various components that go into computing the" " cost of a model,\nthat is the difference between " "a simulation with that model and the corresponding" " experiment."), view = KromView(VGroup( VGroup(weight_doc, HGroup( Item("peak_time_weight", label="Peak time"), Item("peak_height_weight", label="Peak height"), Item("peak_slope_weight", label="Peak slope"), ), show_border=True, label="Weights", enabled_when="False", visible_when="not weight_edit_mode"), VGroup(weight_doc, Item("peak_time_weight", label="Peak time", editor=weight_range_editor), Item("peak_height_weight", label="Peak height", editor=weight_range_editor), Item("peak_slope_weight", label="Peak slope", editor=weight_range_editor), show_border=True, label="Weights", visible_when="weight_edit_mode"), HGroup( Spring(), Item("edit_weights_button", show_label=False, enabled_when="can_change_weights")), VGroup(HGroup( Item("show_cost_data_nd", label="Plot type", style="custom", enabled_when="len(param_list) > 1"), Item("x_axis_param", editor=EnumEditor(values=self.param_list)), Item("y_axis_param", editor=EnumEditor(values=param_list_with_cost), enabled_when="show_cost_data_nd != '1D'"), ), Item("plot1_2d_container", editor=ComponentEditor(), show_label=False), HGroup( Spring(), Item('color_bar_max_percentile', editor=RangeEditor(low=1, high=100, mode='spinner'), label='Colorbar high percentile (%)', visible_when=two_d_plot_shown)), VGroup(*additional_param_controls), label="Cost function plot", show_border=True, visible_when="not no_cost_data"), ), buttons=[OKButton], title="View/Edit optimizer cost function") return view