def load_from_yaml(yaml_dict, data_dir=None): #name: load what from yaml? """ Creates a :class:`~pyhdx.fitting.KineticsFitting` object from dictionary input. Dictionary can be generated from .yaml format and should specifiy Parameters ---------- yaml_dict : :obj:`dict` Input dictionary specifying metadata and file location to load data_dir : :obj:`str` or pathlib.Path object Returns ------- kf : :class:`~pyhdx.fititng.KineticsFitting` :class:`~pyhdx.fititng.KineticsFitting` class as specified by input dict. """ if data_dir is not None: input_files = [Path(data_dir) / fname for fname in yaml_dict['filenames']] else: input_files = yaml_dict['filenames'] data = read_dynamx(*input_files) pmt = PeptideMasterTable(data, d_percentage=yaml_dict['d_percentage']) #todo add proline, n_term options if 'control' in yaml_dict.keys(): # Use a FD control for back exchange correction pmt.set_control(tuple(yaml_dict['control'])) elif 'be_percent' in yaml_dict.keys(): # Flat back exchange percentage for all peptides\ pmt.set_backexchange(yaml_dict['be_percent']) else: raise ValueError('No valid back exchange control method specified') try: c_term = yaml_dict.get('c_term', 0) or len(yaml_dict['sequence']) + 1 except KeyError: raise ValueError("Must specify either 'c_term' or 'sequence'") states = pmt.groupby_state(c_term=c_term) series = states[yaml_dict['series_name']] if yaml_dict['temperature_unit'].lower() == 'celsius': temperature = yaml_dict['temperature'] + 273.15 elif yaml_dict['temperature_unit'].lower() == 'kelvin': temperature = yaml_dict['temperature'] else: raise ValueError("Invalid option for 'temperature_unit', must be 'Celsius' or 'Kelvin'") kf = KineticsFitting(series, temperature=temperature, pH=yaml_dict['pH']) return kf
def load_folding_from_yaml(yaml_dict, data_dir=None): #name: load what from yaml? """ Creates a :class:`~pyhdx.fitting.KineticsFitting` object from dictionary input. Dictionary can be generated from .yaml format and should specifiy Parameters ---------- yaml_dict : :obj:`dict` Input dictionary specifying metadata and file location to load data_dir : :obj:`str` or pathlib.Path object Returns ------- kf : :class:`~pyhdx.fititng.KineticsFitting` :class:`~pyhdx.fititng.KineticsFitting` class as specified by input dict. """ if data_dir is not None: input_files = [Path(data_dir) / fname for fname in yaml_dict['filenames']] else: input_files = yaml_dict['filenames'] data = read_dynamx(*input_files) pmt = PeptideMasterTable(data, d_percentage=yaml_dict['d_percentage']) #todo add proline, n_term options #todo merge this with the other func where it checks for control names to determine what to apply pmt.set_control(control_100=tuple(yaml_dict['control_100']), control_0=tuple(yaml_dict['control_0'])) try: c_term = yaml_dict.get('c_term', 0) or len(yaml_dict['sequence']) + 1 except KeyError: raise ValueError("Must specify either 'c_term' or 'sequence'") states = pmt.groupby_state(c_term=c_term) series = states[yaml_dict['series_name']] if yaml_dict['temperature_unit'].lower() == 'celsius': temperature = yaml_dict['temperature'] + 273.15 elif yaml_dict['temperature_unit'].lower() == 'kelvin': temperature = yaml_dict['temperature'] else: raise ValueError("Invalid option for 'temperature_unit', must be 'Celsius' or 'Kelvin'") kf = KineticsFitting(series, temperature=temperature, pH=yaml_dict['pH']) return kf
def load_folding_from_yaml(yaml_dict, data_dir=None): #name: load what from yaml? """ """ raise NotImplementedError( 'Loading folding data from yaml currently not implemented') if data_dir is not None: input_files = [ Path(data_dir) / fname for fname in yaml_dict['filenames'] ] else: input_files = yaml_dict['filenames'] data = read_dynamx(*input_files) pmt = PeptideMasterTable(data, d_percentage=yaml_dict['d_percentage'] ) #todo add proline, n_term options #todo merge this with the other func where it checks for control names to determine what to apply pmt.set_control(control_1=tuple(yaml_dict['control_1']), control_0=tuple(yaml_dict['control_0'])) try: c_term = yaml_dict.get('c_term', 0) or len(yaml_dict['sequence']) + 1 except KeyError: raise ValueError("Must specify either 'c_term' or 'sequence'") states = pmt.groupby_state(c_term=c_term) series = states[yaml_dict['series_name']] if yaml_dict['temperature_unit'].lower() == 'celsius': temperature = yaml_dict['temperature'] + 273.15 elif yaml_dict['temperature_unit'].lower() == 'kelvin': temperature = yaml_dict['temperature'] else: raise ValueError( "Invalid option for 'temperature_unit', must be 'Celsius' or 'Kelvin'" ) kf = KineticsFitting(series, temperature=temperature, pH=yaml_dict['pH']) return kf
from pyhdx.panel.sources import DataFrameSource from pyhdx.panel.filters import MultiIndexSelectFilter from lumen.sources import DerivedSource directory = Path(__file__).parent data_dir = directory / 'test_data' data = read_dynamx(data_dir / 'ecSecB_apo.csv', data_dir / 'ecSecB_dimer.csv') pmt = PeptideMasterTable(data) pmt.set_control(('Full deuteration control', 0.167)) states = pmt.groupby_state() st1 = states['SecB his dimer apo'] st2 = states['SecB WT apo'] df1 = pd.DataFrame(st1.full_data) df2 = pd.DataFrame(st2.full_data) rates_df = pd.read_csv(data_dir / 'ecSecB_rates.txt', index_col=0, header=[0, 1]) class TestLumenSources(object): @classmethod def setup_class(cls): cls.df1 = df1 cls.df2 = df2