本文整理汇总了Python中fullrmc.Globals.LOGGER.warn方法的典型用法代码示例。如果您正苦于以下问题:Python LOGGER.warn方法的具体用法?Python LOGGER.warn怎么用?Python LOGGER.warn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fullrmc.Globals.LOGGER
的用法示例。
在下文中一共展示了LOGGER.warn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_constraint_original_value
# 需要导入模块: from fullrmc.Globals import LOGGER [as 别名]
# 或者: from fullrmc.Globals.LOGGER import warn [as 别名]
def get_constraint_original_value(self):
"""
Compute all partial Pair Distribution Functions (PDFs).
:Returns:
#. PDFs (dictionary): The PDFs dictionnary, where keys are the element wise intra and inter molecular PDFs and values are the computed PDFs.
"""
if self.originalData is None:
LOGGER.warn("originalData must be computed first using 'compute_data' method.")
return {}
return self._get_constraint_value(self.originalData)
示例2: create_angles_by_definition
# 需要导入模块: from fullrmc.Globals import LOGGER [as 别名]
# 或者: from fullrmc.Globals.LOGGER import warn [as 别名]
def create_angles_by_definition(self, anglesDefinition):
"""
Creates anglesMap using angles definition.
Calls set_angles(anglesMap) and generates angles attribute.
:Parameters:
#. anglesDefinition (dict): The angles definition.
Every key must be a molecule name (residue name in pdb file).
Every key value must be a list of angles definitions.
Every angle definition is a list of five items where:
#. First item: The name of the central atom forming the angle.
#. Second item: The name of the left atom forming the angle (interchangeable with the right atom).
#. Third item: The name of the right atom forming the angle (interchangeable with the left atom).
#. Fourth item: The minimum lower limit or the minimum angle allowed in degrees.
#. Fifth item: The maximum upper limit or the maximum angle allowed in degrees.
::
e.g. (Carbon tetrachloride): anglesDefinition={"CCL4": [('C','CL1','CL2' , 105, 115),
('C','CL2','CL3' , 105, 115),
('C','CL3','CL4' , 105, 115),
('C','CL4','CL1' , 105, 115) ] }
"""
if self.engine is None:
raise Exception(LOGGER.error("Engine is not defined. Can't create angles"))
assert isinstance(anglesDefinition, dict), LOGGER.error("anglesDefinition must be a dictionary")
# check map definition
existingMoleculesNames = sorted(set(self.engine.moleculesNames))
anglesDef = {}
for mol, angles in anglesDefinition.items():
if mol not in existingMoleculesNames:
LOGGER.warn("Molecule name '%s' in anglesDefinition is not recognized, angles definition for this particular molecule is omitted"%str(mol))
continue
assert isinstance(angles, (list, set, tuple)), LOGGER.error("mapDefinition molecule angles must be a list")
angles = list(angles)
molAnglesMap = []
for angle in angles:
assert isinstance(angle, (list, set, tuple)), LOGGER.error("mapDefinition angles must be a list")
angle = list(angle)
assert len(angle)==5
centralAt, leftAt, rightAt, lower, upper = angle
assert is_number(lower)
lower = FLOAT_TYPE(lower)
assert is_number(upper)
upper = FLOAT_TYPE(upper)
assert lower>=0, LOGGER.error("anglesMap items lists fourth item must be positive")
assert upper>lower, LOGGER.error("anglesMap items lists fourth item must be smaller than the fifth item")
assert upper<=180, LOGGER.error("anglesMap items lists fifth item must be smaller or equal to 180")
lower *= FLOAT_TYPE( PI/FLOAT_TYPE(180.) )
upper *= FLOAT_TYPE( PI/FLOAT_TYPE(180.) )
# check for redundancy
append = True
for b in molAnglesMap:
if (b[0]==centralAt) and ( (b[1]==leftAt and b[2]==rightAt) or (b[1]==rightAt and b[2]==leftAt) ):
LOGGER.warn("Redundant definition for anglesDefinition found. The later '%s' is ignored"%str(b))
append = False
break
if append:
molAnglesMap.append((centralAt, leftAt, rightAt, lower, upper))
# create bondDef for molecule mol
anglesDef[mol] = molAnglesMap
# create mols dictionary
mols = {}
for idx in self.engine.pdb.xindexes:
molName = self.engine.moleculesNames[idx]
if not molName in anglesDef.keys():
continue
molIdx = self.engine.moleculesIndexes[idx]
if not mols.has_key(molIdx):
mols[molIdx] = {"name":molName, "indexes":[], "names":[]}
mols[molIdx]["indexes"].append(idx)
mols[molIdx]["names"].append(self.engine.allNames[idx])
# get anglesMap
anglesMap = []
for val in mols.values():
indexes = val["indexes"]
names = val["names"]
# get definition for this molecule
thisDef = anglesDef[val["name"]]
for angle in thisDef:
centralIdx = indexes[ names.index(angle[0]) ]
leftIdx = indexes[ names.index(angle[1]) ]
rightIdx = indexes[ names.index(angle[2]) ]
lower = angle[3]
upper = angle[4]
anglesMap.append((centralIdx, leftIdx, rightIdx, lower, upper))
# create angles
self.set_angles(anglesMap=anglesMap)
示例3: set_angles
# 需要导入模块: from fullrmc.Globals import LOGGER [as 别名]
# 或者: from fullrmc.Globals.LOGGER import warn [as 别名]
def set_angles(self, anglesMap):
"""
Sets the angles dictionary by parsing the anglesMap list.
:Parameters:
#. anglesMap (list): The angles map definition.
Every item must be a list of five items.
#. First item: The central atom index.
#. Second item: The index of the left atom forming the angle (interchangeable with the right atom).
#. Third item: The index of the right atom forming the angle (interchangeable with the left atom).
#. Fourth item: The minimum lower limit or the minimum angle allowed in rad.
#. Fifth item: The maximum upper limit or the maximum angle allowed in rad.
"""
map = []
if self.engine is not None:
if anglesMap is not None:
assert isinstance(anglesMap, (list, set, tuple)), LOGGER.error("anglesMap must be None or a list")
for angle in anglesMap:
assert isinstance(angle, (list, set, tuple)), LOGGER.error("anglesMap items must be lists")
angle = list(angle)
assert len(angle)==5, LOGGER.error("anglesMap items must be lists of 5 items each")
centralIdx, leftIdx, rightIdx, lower, upper = angle
assert is_integer(centralIdx), LOGGER.error("anglesMap items lists of first item must be an integer")
centralIdx = INT_TYPE(centralIdx)
assert is_integer(leftIdx), LOGGER.error("anglesMap items lists of second item must be an integer")
leftIdx = INT_TYPE(leftIdx)
assert is_integer(rightIdx), LOGGER.error("anglesMap items lists of third item must be an integer")
rightIdx = INT_TYPE(rightIdx)
assert centralIdx>=0, LOGGER.error("anglesMap items lists first item must be positive")
assert leftIdx>=0, LOGGER.error("anglesMap items lists second item must be positive")
assert rightIdx>=0, LOGGER.error("anglesMap items lists third item must be positive")
assert centralIdx!=leftIdx, LOGGER.error("bondsMap items lists first and second items can't be the same")
assert centralIdx!=rightIdx, LOGGER.error("bondsMap items lists first and third items can't be the same")
assert leftIdx!=rightIdx, LOGGER.error("bondsMap items lists second and third items can't be the same")
assert is_number(lower), LOGGER.error("anglesMap items lists of third item must be a number")
lower = FLOAT_TYPE(lower)
assert is_number(upper), LOGGER.error("anglesMap items lists of fourth item must be a number")
upper = FLOAT_TYPE(upper)
assert lower>=0, LOGGER.error("anglesMap items lists fourth item must be positive")
assert upper>lower, LOGGER.error("anglesMap items lists fourth item must be smaller than the fifth item")
assert upper<=PI, LOGGER.error("anglesMap items lists fifth item must be smaller or equal to %.10f"%PI)
map.append((centralIdx, leftIdx, rightIdx, lower, upper))
# set anglesMap definition
self.__anglesMap = map
# create bonds list of indexes arrays
self.__angles = {}
self.__atomsLUAD = {}
if self.engine is not None:
# parse bondsMap
for angle in self.__anglesMap:
centralIdx, leftIdx, rightIdx, lower, upper = angle
assert centralIdx<len(self.engine.pdb), LOGGER.error("angle atom index must be smaller than maximum number of atoms")
assert leftIdx<len(self.engine.pdb), LOGGER.error("angle atom index must be smaller than maximum number of atoms")
assert rightIdx<len(self.engine.pdb), LOGGER.error("angle atom index must be smaller than maximum number of atoms")
# create atoms look up angles dictionary
if not self.__atomsLUAD.has_key(centralIdx):
self.__atomsLUAD[centralIdx] = []
if not self.__atomsLUAD.has_key(leftIdx):
self.__atomsLUAD[leftIdx] = []
if not self.__atomsLUAD.has_key(rightIdx):
self.__atomsLUAD[rightIdx] = []
# create angles
if not self.__angles.has_key(centralIdx):
self.__angles[centralIdx] = {"leftIndexes":[],"rightIndexes":[],"lower":[],"upper":[]}
# check for redundancy and append
elif leftIdx in self.__angles[centralIdx]["leftIndexes"]:
index = self.__angles[centralIdx]["leftIndexes"].index(leftIdx)
if rightIdx == self.__angles[centralIdx]["rightIndexes"][index]:
LOGGER.warn("Angle definition for central atom index '%i' and interchangeable left an right '%i' and '%i' is already defined. New angle limits [%.3f,%.3f] ignored and old angle limits [%.3f,%.3f] kept."%(centralIdx, leftIdx, rightIdx, lower, upper, self.__angles[centralIdx]["lower"][index], self.__angles[centralIdx]["upper"][index]))
continue
elif leftIdx in self.__angles[centralIdx]["rightIndexes"]:
index = self.__angles[centralIdx]["rightIndexes"].index(leftIdx)
if rightIdx == self.__angles[centralIdx]["leftIndexes"][index]:
LOGGER.warn("Angle definition for central atom index '%i' and interchangeable left an right '%i' and '%i' is already defined. New angle limits [%.3f,%.3f] ignored and old angle limits [%.3f,%.3f] kept."%(centralIdx, leftIdx, rightIdx, lower, upper, self.__angles[centralIdx]["lower"][index], self.__angles[centralIdx]["upper"][index]))
continue
# add angle definition
self.__angles[centralIdx]["leftIndexes"].append(leftIdx)
self.__angles[centralIdx]["rightIndexes"].append(rightIdx)
self.__angles[centralIdx]["lower"].append(lower)
self.__angles[centralIdx]["upper"].append(upper)
self.__atomsLUAD[centralIdx].append(centralIdx)
self.__atomsLUAD[leftIdx].append(centralIdx)
self.__atomsLUAD[rightIdx].append(centralIdx)
# finalize angles
for idx in self.engine.pdb.xindexes:
angles = self.__angles.get(idx, {"leftIndexes":[],"rightIndexes":[],"lower":[],"upper":[]} )
self.__angles[INT_TYPE(idx)] = {"leftIndexes": np.array(angles["leftIndexes"], dtype = INT_TYPE),
"rightIndexes": np.array(angles["rightIndexes"], dtype = INT_TYPE),
"lower" : np.array(angles["lower"] , dtype = FLOAT_TYPE),
"upper" : np.array(angles["upper"] , dtype = FLOAT_TYPE) }
lut = self.__atomsLUAD.get(idx, [] )
self.__atomsLUAD[INT_TYPE(idx)] = sorted(set(lut))
# reset constraint
self.__initialize_constraint__()