<commit_before>"""
ChannelWorm fitter module for initializing needed parameters.
"""
import matplotlib.pyplot as plt
import channelworm

class Initiator(object):

    def __init__(self, userData={}):

        """Initializes variables for other modules

        :param user: parameters related to user profile
        """

        # TODO: Initialize data provided by user (directly from interface or from DB)

        if 'samples' in userData:
            self.sampleData = userData['samples']
        self.sim_params = dict() # userData['sim_params']
        self.opt_params = dict() # userData['opt_params']
        self.bio_params = dict() # userData['bio_params']

        channelworm.django_setup()

    def get_bio_params(self):
        """
        Get parameters for cell and channel from user / DB and initialize variables.

        """

        # TODO: Get values from pyOW

        self.bio_params['cell_type'] = 'ADAL'
        self.bio_params['channel_type'] = 'EGL-19'
        self.bio_params['ion_type'] = 'Ca'
        self.bio_params['I_leak'] = False

        self.bio_params['cell_params'] =      ['C_mem', 'area', 'spec_cap']
        self.bio_params['unit_cell_params'] = ['F',     'm2',   'F/m2']
        self.bio_params['val_cell_params'] =  [7.5e-11, 7.5e-9, 0.01]

        # self.bio_params['cell_channel_params'] = ['channel_density']
        # self.bio_params['unit_cell_channel_params'] = ['1/m2']
        # self.bio_params['val_cell_channel_params'] = []

        # g (S) = (g_dens (S/m2) / spec_cap (F/m2)) * C_mem (F)

        self.bio_params['gate_params'] = {'vda': {'power': 1},'vdi': {'power': 1},'cdi': {'power': 1}}

        self.bio_params['channel_params'] = ['g_dens','e_rev']
        self.bio_params['unit_chan_params'] = ['S/m2','V']

        self.bio_params['min_val_channel'] = [1, -150e-3]
        self.bio_params['max_val_channel'] = [10, 150e-3]

        if self.bio_params['I_leak']:

            self.bio_params['channel_params'].extend(['gL',   'VL'])
            self.bio_params['unit_chan_params'].extend(['S/m2','V'])

            self.bio_params['min_val_channel'].extend([5e-2,-2e-2]) # chr2
            self.bio_params['max_val_channel'].extend([5e-1, 4e-2]) # chr2

        if 'vda' in self.bio_params['gate_params']:

            self.bio_params['channel_params'].extend(['v_half_a','k_a','T_a'])
            self.bio_params['unit_chan_params'].extend(['V','V','s'])

            self.bio_params['min_val_channel'].extend([-0.15, 0.0001, 0.0001])
            self.bio_params['max_val_channel'].extend([ 0.15,   0.1,  0.01])

        if 'vdi' in self.bio_params['gate_params']:

            self.bio_params['channel_params'].extend(['v_half_i','k_i','T_i'])

            self.bio_params['unit_chan_params'].extend(['V','V','s'])

            self.bio_params['min_val_channel'].extend([-150e-3, -0.1,  0.0001])
            self.bio_params['max_val_channel'].extend([ 150e-3, -0.0001, 0.01])

        if 'cdi' in self.bio_params['gate_params']:

            #Parameters for Ca-dependent inactivation (Boyle & Cohen 2008)
            self.bio_params['channel_params'].extend(['ca_half_i','alpha_ca','k_ca','T_ca'])
            self.bio_params['unit_chan_params'].extend(['M','','M','s'])

            self.bio_params['min_val_channel'].extend([1e-9, 0.1, -1e-6, 1e-3])
            self.bio_params['max_val_channel'].extend([1e-6, 0.9, -1e-9, 1])
<commit_msg>Considering Ca dynamics<commit_after>"""
ChannelWorm fitter module for initializing needed parameters.
"""
import matplotlib.pyplot as plt
import channelworm

class Initiator(object):

    def __init__(self, userData={}):

        """Initializes variables for other modules

        :param user: parameters related to user profile
        """

        # TODO: Initialize data provided by user (directly from interface or from DB)

        if 'samples' in userData:
            self.sampleData = userData['samples']
        self.sim_params = dict() # userData['sim_params']
        self.opt_params = dict() # userData['opt_params']
        self.bio_params = dict() # userData['bio_params']

        channelworm.django_setup()

    def get_bio_params(self):
        """
        Get parameters for cell and channel from user / DB and initialize variables.

        """

        # TODO: Get values from pyOW

        self.bio_params['cell_type'] = 'ADAL'
        self.bio_params['channel_type'] = 'EGL-19'
        self.bio_params['ion_type'] = 'Ca'
        self.bio_params['I_leak'] = False

        self.bio_params['cell_params'] =      ['C_mem', 'area', 'spec_cap']
        self.bio_params['unit_cell_params'] = ['F',     'm2',   'F/m2']
        self.bio_params['val_cell_params'] =  [7.5e-11, 7.5e-9, 0.01]

        # self.bio_params['cell_channel_params'] = ['channel_density']
        # self.bio_params['unit_cell_channel_params'] = ['1/m2']
        # self.bio_params['val_cell_channel_params'] = []

        # g (S) = (g_dens (S/m2) / spec_cap (F/m2)) * C_mem (F)

        self.bio_params['gate_params'] = {'vda': {'power': 1},'vdi': {'power': 1},'cd': {'power': 1}}

        self.bio_params['channel_params'] = ['g_dens','e_rev']
        self.bio_params['unit_chan_params'] = ['S/m2','V']

        self.bio_params['min_val_channel'] = [1, -150e-3]
        self.bio_params['max_val_channel'] = [10, 150e-3]

        if self.bio_params['I_leak']:

            self.bio_params['channel_params'].extend(['gL',   'VL'])
            self.bio_params['unit_chan_params'].extend(['S/m2','V'])

            self.bio_params['min_val_channel'].extend([5e-2,-2e-2]) # chr2
            self.bio_params['max_val_channel'].extend([5e-1, 4e-2]) # chr2

        if 'vda' in self.bio_params['gate_params']:

            self.bio_params['channel_params'].extend(['v_half_a','k_a','T_a'])
            self.bio_params['unit_chan_params'].extend(['V','V','s'])

            self.bio_params['min_val_channel'].extend([-0.15, 0.0001, 0.0001])
            self.bio_params['max_val_channel'].extend([ 0.15,   0.1,  0.01])

        if 'vdi' in self.bio_params['gate_params']:

            self.bio_params['channel_params'].extend(['v_half_i','k_i','T_i'])

            self.bio_params['unit_chan_params'].extend(['V','V','s'])

            self.bio_params['min_val_channel'].extend([-150e-3, -0.1,  0.0001])
            self.bio_params['max_val_channel'].extend([ 150e-3, -0.0001, 0.01])

        if 'cd' in self.bio_params['gate_params']:

            #Parameters for Ca Dynamics (Boyle & Cohen 2008)
            self.bio_params['channel_params'].extend(['ca_half','alpha_ca','k_ca','T_ca'])
            self.bio_params['unit_chan_params'].extend(['M','','M','s'])

            self.bio_params['min_val_channel'].extend([1e-9, 0.1, -1e-6, 1e-3])
            self.bio_params['max_val_channel'].extend([1e-6, 0.9, -1e-9, 1])

{'fraction_non_alphanumeric': 0.17675580370261534, 'fraction_numerical': 0.031442844548927415, 'mean_word_length': 2.9120689655172414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3200180', 'n_tokens_mistral': 2480, 'n_tokens_neox': 2306, 'n_words': 374}