本文整理汇总了Python中hgu.Util.fatalError方法的典型用法代码示例。如果您正苦于以下问题:Python Util.fatalError方法的具体用法?Python Util.fatalError怎么用?Python Util.fatalError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hgu.Util
的用法示例。
在下文中一共展示了Util.fatalError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getByAncestorOid
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def getByAncestorOid(ancestorOid, relType = Relationships.PART_OF):
"""
Return the all records with given OID as ancestor.
"""
if relType != Relationships.PART_OF:
# Take this error check out if and when we support transitive
# closure of other relationship types.
Util.fatalError([
"AnadRelationshipTransitive.getByAncestorOid() currently only",
"works with " + Relationships.PART_OF + " relationships."])
ancestorIter = Iterator(
where = (
ANCESTOR_OID_COLUMN + " = " +
DbAccess.formatSqlValue(ancestorOid) +
" and " +
RELATIONSHIP_TYPE_NAME_COLUMN + " = " +
DbAccess.formatSqlValue(relType)))
rels = []
for dbRec in ancestorIter:
rels.append(dbRec)
return rels
示例2: createNode
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def createNode(species, componentName, isGroup, publicId,
description = None):
"""
Create a new node record.
"""
# Validate first
if publicId in _byPublicId:
Util.fatalError([
"Attempt to create a node with public ID '" + publicId +
" but node with that ID already exists."])
node = AnaNodeDb.AnaNodeDbRecord()
oid = Oids.createNextOid()
node.setOid(oid)
node.setSpecies(species)
node.setComponentName(componentName)
node.setIsGroup(isGroup)
node.setPublicId(publicId)
node.setDescription(description)
node.insert()
_addToKnowledge(node)
return node
示例3: __addGeneToKnowledge
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def __addGeneToKnowledge(geneNomen):
"""
Add this gene to what we know about MGI genes.
"""
name = geneNomen.getName()
symbol = geneNomen.getSymbol()
accession = geneNomen.getAccession()
# accession
if accession:
accessionLower = accession.lower()
if accessionLower in _nomenclatureByAnyName:
Util.fatalError([
"Accession " + accession +
" occurs twice in MGI marker files."])
_nomenclatureByAccession[accessionLower] = geneNomen
_nomenclatureByAnyName[accessionLower] = geneNomen
# symbol
symbolLower = symbol.lower()
if symbolLower in _nomenclatureByAnyName:
Util.warning([
"Symbol " + symbol + " occurs twice in MGI marker files.",
"Ignoring earlier occurrence."])
_nomenclatureByAnyName[symbolLower] = geneNomen
_nomenclatureBySymbol[symbolLower] = geneNomen
# name can be same as Symbol
nameLower = name.lower()
_nomenclatureByName[nameLower] = geneNomen
if nameLower not in _nomenclatureByAnyName:
_nomenclatureByAnyName[nameLower] = geneNomen
return None
示例4: selectOne
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def selectOne(dbTable, where):
"""
Select a single record from a single table.
If record does not exist then None is returned.
"""
columnNames = dbTable.getColumnNames()
query = _buildSingleTableQuery(dbTable, columnNames, where = where)
cursor = _dbConn.cursor()
cursor.execute(query)
if cursor.rowcount > 1:
Util.fatalError([
"Query expected to return 0 or 1 row returned " +
str(cursor.rowcount) + " rows. Query:",
query])
elif cursor.rowcount == 1:
sqlRecord = cursor.fetchone()
dbRecord = _createDbRecord(
dbTable, sqlRecord, columnNames)
else:
dbRecord = None
cursor.close()
return dbRecord
示例5: checkForNewRoot
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def checkForNewRoot():
"""
Check if ontology has a new root node. Update this module's internal
state if there is a new root, and return the root node if it has changed
or not.
"""
# Hmm, could do this the efficient but unsafe way: pick a node randomly
# and follow its part of path upward until it ends.
# Or could check every node and report an error if we find more than one
# root in the list.
# Do it the slow, safe way.
global _rootNode
roots = []
for node in Iterator():
if len(getPartOfParentsForNode(node)) == 0:
roots.append(node)
if len(roots) == 0:
Util.warning(["No root node found in ontology."])
elif len(roots) == 1:
_rootNode = roots[0]
else:
message = [str(len(roots)) + " root nodes found."]
for node in roots:
message.append("ID: " + node.getPublicId() +
" Name: " + node.getComponentName())
Util.fatalError(message)
return _rootNode
示例6: createStage
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def createStage(species, name, sequence,
description = None, shortExtraText = None, publicId = None):
"""
Create a new stage record.
sequence must be one greater than the current maximum stage sequence value.
"""
if sequence != len(_bySequence):
Util.fatalError([
"Attempt to create stage '" + name + "' out of sequence.",
"New sequence must be 1 greater than current maximum sequence.",
"Sequence of last existing stage: " + str(len(_bySequence)),
"Sequence requested: " + str(sequence)])
stg = AnaStageDb.AnaStageDbRecord()
oid = Oids.createNextOid()
stg.setOid(oid)
stg.setSpecies(species)
stg.setName(name)
stg.setSequence(sequence)
stg.setDescription(description)
stg.setShortExtraText(shortExtraText)
stg.setPublicId(publicId)
stg.insert()
_addToKnowledge(stg)
return stg
示例7: initialise
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def initialise():
"""
Read all stages into memory.
This must be called after DbAccess.initialise() and before calling any
other function in this module.
"""
global _byOid, _bySequence, _byName, _byPublicId
_byOid = {}
_bySequence = []
_byName = {}
_byPublicId = {}
for stage in AnaStageDb.SequenceIterator():
_addToKnowledge(stage)
# Verify that stage sequence starts at 0, and is dense. Otherwise
# this code will fail.
for index, stage in enumerate(_bySequence):
if index != stage.getSequence():
Util.fatalError([
"Stage sequence does not start at 0, and/or is not dense.",
"Stage " + stage.getName() + " has index " + str(index) +
" but has sequence " + stage.getSequence + ".",
"Code requires 0-relative, dense stage sequences."])
return None
示例8: initialise
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def initialise():
"""
Read all perspective ambits into memory.
This must be called after DbAccess.initialise() and before calling any
other function in this module.
"""
global _byPerspective, _startsByPerspective, _stopsByPerspective
global _byNodeOid
_byPerspective = {}
_startsByPerspective = {}
_stopsByPerspective = {}
_byNodeOid = {}
for ambit in AnaPerspectiveAmbitDb.Iterator():
_addToKnowledge(ambit)
for perspectiveName, startAmbit in _startsByPerspective.iteritems():
if len(startAmbit) == 0:
Util.fatalError([
"Perspective '" + perspectiveName +
"' has no start ambit records."])
return None
示例9: _addToKnowledge
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def _addToKnowledge(anatApo, deferReverse = False ):
"""
Add the part of record to this module's internal knowledge.
If deferReverse is True then do not update the
_partOfInReverseSequence global variable.
"""
_partOfByOid[anatApo.getOid()] = anatApo
_partOfBySequence.append(anatApo)
parentOid = anatApo.getParentApoOid()
if parentOid != None:
if parentOid not in _byParentOid:
_byParentOid[parentOid] = []
_byParentOid[parentOid].append(anatApo)
if anatApo.isPrimaryPath():
nodeOid = anatApo.getNodeOid()
if nodeOid in _primaryPathByNodeOid:
Util.fatalError([
"Node OID " + str(nodeOid) + " occurs more than once " +
"in " + AnadPartOfDb.TABLE_NAME])
_primaryPathByNodeOid[nodeOid] = anatApo
if not deferReverse:
global _partOfInReverseSequence
_partOfInReverseSequence = _partOfBySequence[:]
_partOfInReverseSequence.reverse()
return
示例10: setGroupStatus
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def setGroupStatus(self):
"""
Set the group status for this line, and all of its descendant lines.
May also change the group status for its ancestor lines as well.
"""
# Have two sources of information:
# Node.isPrimary: is this node a primary node or a group node?
# PartOf.isPrimary/isGroup: Is this the primary path to this node, or
# was this node reached by going through a
# group node?
# Set status for this line.
parentApoOid = self.getParentApoOid()
if parentApoOid == None:
# At root. Status will change to GROUP_ANCESTOR when we hit the
# first group.
self.__groupStatus = GROUP_AVERSE
else:
parentLine = self.__reportTree.getLineByOid(parentApoOid)
parentStatus = parentLine.getGroupStatus()
if parentStatus in [GROUP_AVERSE, GROUP_ANCESTOR]:
node = self.getNode()
if not node.isPrimary():
# We have a group that is not itself in a group path.
self.__groupStatus = GROUP
# walk up parents marking them as ancestors.
ancestorLine = parentLine
while (ancestorLine != None and
ancestorLine.getGroupStatus() != GROUP_ANCESTOR):
ancestorLine.__groupStatus = GROUP_ANCESTOR
ancestorApoOid = ancestorLine.getParentApoOid()
if ancestorApoOid != None:
ancestorLine = self.__reportTree.getLineByOid(
ancestorApoOid)
else:
ancestorLine = None
else: # Not a group, and not in a group path
self.__groupStatus = GROUP_AVERSE
elif parentStatus == GROUP:
# That makes us a direct descendent
self.__groupStatus = GROUP_DIRECT_DESCENDANT
elif parentStatus in [GROUP_DIRECT_DESCENDANT,
GROUP_INDIRECT_DESCENDANT]:
# That makes us an indirect descendent
self.__groupStatus = GROUP_INDIRECT_DESCENDANT
else:
Util.fatalError([
"Should have covered all cases.",
"ParentStatus: ", parentStatus])
# Set status for all kid lines.
for line in self.__childLines:
line.setGroupStatus()
return
示例11: __fatalError
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def __fatalError(self, offender):
"""
Something unexpected encountered in input. Raise a fatal exception.
"""
Util.fatalError([
"NIBB Clone Sequence HTML parser error.",
"Current state: " + self.__state,
"Unexpected tag/line: " + offender])
示例12: __verifyStaticFileSection
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def __verifyStaticFileSection(fileHandle, expectedLines, errorMessage):
"""
Abort if contents of a static section of a file do not look like
what they are supposed to.
"""
for expectedLine in expectedLines:
actualLine = fileHandle.readline()
if not re.match(expectedLine, actualLine):
Util.fatalError([
errorMessage,
'Expected: "' + expectedLine + '"',
'Actual: "' + actualLine + '"'])
return
示例13: __addGeneToKnowledge
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def __addGeneToKnowledge(geneNomen):
"""
Add this gene to what we know about HGNC genes.
"""
symbol = geneNomen.getSymbol()
# symbol
if symbol in _nomenclatureBySymbol:
Util.fatalError([
"Symbol " + symbol + " occurs twice in HGNC Core Data file."])
_nomenclatureBySymbol[symbol] = geneNomen
return None
示例14: _addToByAnyName
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def _addToByAnyName(anyName, gene):
"""
Add the given name to the byAnyName lookup for the given gene.
"""
anyNameLower = anyName.lower()
if anyNameLower in _geneByAnyName:
Util.fatalError([
"String '" + anyName +
"' associated with more than one gene in Xenbase gene file.",
"Rewrite the code to deal with this."])
else:
_geneByAnyName[anyNameLower] = gene
return
示例15: createPerspective
# 需要导入模块: from hgu import Util [as 别名]
# 或者: from hgu.Util import fatalError [as 别名]
def createPerspective(name, comments):
"""
Create a new perspective record.
"""
if name in _byName:
Util.fatalError([
"Attempt to create perspective with name '" + name +
"' when perspective with that name already exists."])
perspective = AnaPerspectiveDb.AnaPerspectiveDbRecord()
perspective.setName(name)
perspective.setComments(comments)
perspective.insert()
_byName[name] = perspective
return perspective