本文整理匯總了Python中pymc.Uniform方法的典型用法代碼示例。如果您正苦於以下問題:Python pymc.Uniform方法的具體用法?Python pymc.Uniform怎麽用?Python pymc.Uniform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymc
的用法示例。
在下文中一共展示了pymc.Uniform方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _create_competitive_binding_model
# 需要導入模塊: import pymc [as 別名]
# 或者: from pymc import Uniform [as 別名]
def _create_competitive_binding_model(self, receptor_name, DeltaG_prior):
"""
Create the binding free energy priors, binding reaction models, and list of all species whose concentrations will be tracked.
Populates the following fields:
* parameter_names['DeltaGs'] : parameters associated with DeltaG priors
* reactions : reactions for GeneralBindingModel with DeltaG parameters substituted for free energies
formatted like [ ('DeltaG1', {'RL': -1, 'R' : +1, 'L' : +1}), ('DeltaG2', {'RP' : -1, 'R' : +1, 'P' : +1}) ]
* conservation_equations : conservation relationships for GeneralBindingModel with species names substituted with log concentrations
formatted like [ ('receptor', {'receptor' : +1, 'receptor:ligand' : +1}), ('ligand' : {'receptor:ligand' : +1, 'ligand' : +1}) ]
* complex_names : names of all complexes
* all_species : names of all species (ligands, receptor, complexes)
"""
self.parameter_names['binding affinities'] = list()
self.complex_names = list()
self.reactions = list() # reactions for GeneralBindingModel with pymc parameters substituted for free energies
self.conservation_equations = list() # list of conservation relationships for GeneralBindingModel with pymc parameters substituted for log concentrations
receptor_conservation_equation = { receptor_name : +1 } # Begin to populate receptor conservation equation
for ligand_name in self.ligand_names:
# Create complex name
complex_name = receptor_name + ':' + ligand_name
self.complex_names.append(complex_name)
# Create the DeltaG prior
name = 'DeltaG (%s + %s -> %s)' % (receptor_name, ligand_name, complex_name) # form the name of the pymc variable
if DeltaG_prior == 'uniform':
DeltaG = pymc.Uniform(name, lower=DG_min, upper=DG_max) # binding free energy (kT), uniform over huge range
elif DeltaG_prior == 'chembl':
DeltaG = pymc.Normal(name, mu=0, tau=1./(12.5**2)) # binding free energy (kT), using a Gaussian prior inspured by ChEMBL
else:
raise Exception("DeltaG_prior = '%s' unknown. Must be one of 'uniform' or 'chembl'." % DeltaG_prior)
self.model[name] = DeltaG
self.parameter_names['binding affinities'].append(name)
# Create the reaction for GeneralBindingModel
self.reactions.append( (DeltaG, {complex_name : -1, receptor_name : +1, ligand_name : +1}) )
# Create the conservation equation for GeneralBindingModel
self.conservation_equations.append( (ligand_name, {ligand_name : +1, complex_name : +1}) )
# Keep track of receptor conservation.
receptor_conservation_equation[complex_name] = +1
# Create the receptor conservation equation for GeneralBindingModel
self.conservation_equations.append( [receptor_name, receptor_conservation_equation] )
# Create a list of all species that may be present in assay plate
self.all_species = [self.receptor_name] + self.ligand_names + self.complex_names
示例2: _create_extinction_coefficients_model
# 需要導入模塊: import pymc [as 別名]
# 或者: from pymc import Uniform [as 別名]
def _create_extinction_coefficients_model(self):
"""
Determine all spectroscopic wavelengths in use and create model of extinction coefficients
Populates the following fields:
* parameter_names['extinction coefficients'] : all extinction coefficients
* all_wavelengths : list of all wavelengths in use
* absorbance : True if absorbance in use
* fluorescence : True if fluorescence in use
"""
#
# Spectroscopic measurements
#
# TODO: Switch to log extinction coefficients and uniform prior in log extinction coefficients
MIN_EXTINCTION_COEFFICIENT = Unit(0.1, '1/(moles/liter)/centimeter') # maximum physically reasonable extinction coefficient
MAX_EXTINCTION_COEFFICIENT = Unit(100e3, '1/(moles/liter)/centimeter') # maximum physically reasonable extinction coefficient
EXTINCTION_COEFFICIENT_GUESS = Unit(1.0, '1/(moles/liter)/centimeter') # maximum physically reasonable extinction coefficient
# Determine all wavelengths and detection technologies in use
self.all_wavelengths = set()
for well in self.wells:
measurements = well.properties['measurements']
if 'absorbance' in measurements:
for wavelength in measurements['absorbance'].keys():
self.all_wavelengths.add(wavelength)
if 'fluorescence' in measurements:
for (excitation_wavelength, emission_wavelength, geometry) in measurements['fluorescence'].keys():
self.all_wavelengths.add(excitation_wavelength)
self.all_wavelengths.add(emission_wavelength)
print("all wavelengths in use:")
print(self.all_wavelengths)
if (len(self.all_wavelengths) > 0):
# Priors for spectroscopic parameters of each component
self.parameter_names['extinction coefficients'] = list()
for species in self.all_species:
for wavelength in self.all_wavelengths:
name = 'log extinction coefficient of %s at wavelength %s' % (species, wavelength)
log_extinction_coefficient = pymc.Uniform(name, lower=np.log(MIN_EXTINCTION_COEFFICIENT.to_base_units().m), upper=np.log(MAX_EXTINCTION_COEFFICIENT.to_base_units().m), value=np.log(EXTINCTION_COEFFICIENT_GUESS.to_base_units().m)) # extinction coefficient or molar absorptivity for ligand, units of 1/M/cm
self.model[name] = log_extinction_coefficient
self.parameter_names['extinction coefficients'].append(name)