本文整理匯總了Python中hgu.Util.warning方法的典型用法代碼示例。如果您正苦於以下問題:Python Util.warning方法的具體用法?Python Util.warning怎麽用?Python Util.warning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hgu.Util
的用法示例。
在下文中一共展示了Util.warning方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: checkForNewRoot
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [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
示例2: __addGeneToKnowledge
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [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
示例3: getCloneByNibbXdbId
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [as 別名]
def getCloneByNibbXdbId(nibbXdbId):
"""
Return information about a NIBB XDB clone, given its NIBB XDB ID.
nibbXdbId: NIBB XDB clone ID, with or without the leading NIBB:.
"""
cloneId = Util.stripPublicIdPrefix(nibbXdbId)
nibbXdbClone = None
if cloneId in _clonesByNibbXdbId:
nibbXdbClone = _clonesByNibbXdbId[cloneId]
elif cloneId in _failedNibbXdbIds:
pass
else:
# build clone from sequence and library.
library = NibbXdbLibrary.getLibraryByNibbXdbId(cloneId)
if library:
sequencePage = urllib.urlopen(SEQUENCE_URL + cloneId )
nibbXdbClone = NibbXdbClone(sequencePage, library)
_clonesByNibbXdbId[cloneId] = nibbXdbClone
else:
Util.warning([
"Failed to locate NIBB clone library for " + nibbXdbId])
_failedNibbXdbIds.add(nibbXdbId)
return nibbXdbClone
示例4: initialise
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [as 別名]
def initialise(dbHost, dbName, dbUser, dbPass,
outputDir = None, outputFilePath = None, charset = None):
"""
Initialise the database connection.
The outputDir and outputFilePath parameters are optional and are
only needed if you are updating the code. outputDir is deprecated.
Use outputFilePath instead.
charset should be set to "latin1" if you are having difficulties
writing non-ASCII characters.
"""
global _dbConn, _outputFile
# PYTHON Connection
_dbConn = MySQLdb.connect(
user = dbUser, passwd = dbPass, host = dbHost, db = dbName,
charset = charset, unix_socket = '/tmp/mysql.sock' )
# JYTHON Connection
#dbUrl = "jdbc:mysql://" + dbHost + "/" + dbName
#dbDriver = "org.gjt.mm.mysql.Driver"
#_dbConn = zxJDBC.connect(dbUrl, dbUser, dbPass, dbDriver)
"""
try :
# if called from command line with .login CLASSPATH setup right,this works
_dbConn = zxJDBC.connect(dbUrl, dbUser, dbPass, dbDriver)
except:
# if called from Apache or account where the .login has not set CLASSPATH
# need to use run-time CLASSPATH Hacker
try :
jarLoad = classPathHacker()
a = jarLoad.addFile("/net/homehost/export/home/mwicks/Downloads/JarRegenerateDerivedData/lib/mm.mysql-2.0.14-bin.jar")
_dbConn = zxJDBC.connect(dbUrl, dbUser, dbPass, dbDriver)
except :
sys.exit ("still failed \n%s" % (sys.exc_info()))
"""
# Output dir only defined if producing SQL.
if outputDir != None:
# Open single output file to hold all generated SQL.
fileName = outputDir + "/" + "db.sql"
_outputFile = open(fileName, "w")
Util.warning([
"The 'outputDir' parameter to 'DbAccess.initialise()' has been "
"deprecated.",
"Please use the 'outputFilePath' parameter instead."
])
elif outputFilePath != None:
# Open single output file to hold all generated SQL.
_outputFile = open(outputFilePath, "w")
else:
_outputFile = None
return
示例5: _processWithdrawns
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [as 別名]
def _processWithdrawns(withdrawn):
"""
Process withdrawn nomenclature from the marker file. Withdrawn
nomenclature forms a graph that terminates at valid gene names.
The names in the graph become synonyms for the gene names at the
end of the graph.
withdrawn: Dictionary indexed by lower case withdrawn symbol.
Each entry is a list of GeneNomenclature objects
for that symbol.
"""
# Walk through withdrawn nomenclature, collating them and adding them
# to the known nomenclature.
for symbolLower, withdrawnNomens in withdrawn.iteritems():
processedNomens = sets.Set()
horizon = sets.Set(withdrawnNomens)
geneNomens = sets.Set()
while len(horizon) > 0:
withdrawnNomen = horizon.pop()
geneSymbol = withdrawnNomen.getReplacementSymbol()
geneSymbolLower = geneSymbol.lower()
geneNomen = _nomenclatureByAnyName.get(geneSymbolLower)
if geneNomen:
geneNomens.add(geneNomen)
else:
nextGeneration = withdrawn.get(geneSymbolLower)
if nextGeneration:
for nextNomen in nextGeneration:
if nextNomen not in processedNomens:
horizon.add(nextNomen)
elif _verbose:
Util.warning([
"Cirucular withdrawn list for symbol '" +
symbolLower + "'",
"Loop starts at symbol: '" +
nextNomen.getSymbol() + "'"
" ends at Symbol: '" +
withdrawnNomen.getSymbol() + "'"])
elif _verbose:
Util.warning([
"MGI Withdrawn symbol '" + symbolLower +
"' leads to a dead end at symbol '" +
geneSymbol + "'."])
processedNomens.add(withdrawnNomen)
if len(geneNomens) > 0:
if symbolLower not in _nomenclatureByWithdrawnName:
_nomenclatureByWithdrawnName[symbolLower] = geneNomens
else:
_nomenclatureByWithdrawnName[symbolLower] += geneNomens
return
示例6: writeStageReport
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [as 別名]
def writeStageReport(reportTree, outputDir, format, reportType,
togetherness):
"""
Write stage specific reports, one for each stage.
"""
if format == XML and togetherness == CONCATENATED:
# Reject outright any request for concatenated XML stage reports.
# There is not enough memory on my machine to produce these.
Util.warning([
"You have requested an XML report that would include a separate",
"tree for each stage, all in the same XML file. This is a",
"reasonable request, but past experience indicates that there",
"is not enough memory on most workstations to build such a large",
"XML file. Therefore, THE REQUESTED REPORT WILL NOT BE GENERATED."])
return None
reportDir = (outputDir + "/" +
FORMATS[format][FORMAT_SUBDIRECTORY] + "/ByStage/" +
REPORT_TYPES[reportType][REPORT_TYPE_NAME])
reportFile = None
if togetherness == CONCATENATED:
# Open one report file.
fileName = (reportDir + "/AllStages" +
REPORT_TYPES[reportType][REPORT_TYPE_NAME] + "." +
FORMATS[format][FORMAT_EXTENSION])
reportFile = _openReportFile(fileName, reportTree, format)
reportFile.addReportHeader()
for stage in Stages.SequenceIterator():
if togetherness == SEPARATE:
# open report file for each stage
fileName = (reportDir + "/" + stage.getName() +
REPORT_TYPES[reportType][REPORT_TYPE_NAME] +
"." + FORMATS[format][FORMAT_EXTENSION])
reportFile = _openReportFile(fileName, reportTree, format)
reportFile.addReportHeader()
if reportType == GROUPS_EMBEDDED:
_writeStageGroupsEmbeddedReport(reportTree, reportFile, stage, format)
elif reportType == GROUPS_TRAILING:
_writeStageGroupsTrailingReport(reportTree, reportFile, stage)
if togetherness == SEPARATE:
reportFile.closeReportFile()
else:
reportFile.addPageBreak()
if togetherness == CONCATENATED:
reportFile.closeReportFile()
return
示例7: _addGeneToKnowledge
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [as 別名]
def _addGeneToKnowledge(gene):
"""
Add this gene to what we know about Xenbase genes.
"""
# Accession
accessionLower = gene.getAccession().lower()
if accessionLower in _geneByAccession:
Util.fatalError([
"Accession ID '" + gene.getAccession() +
"' occurs more than once in Xenbase gene file."])
else:
_geneByAccession[accessionLower] = gene
_addToByAnyName(gene.getAccession(), gene)
# Symbol
symbolLower = gene.getSymbol().lower()
if symbolLower in _geneBySymbol:
Util.fatalError([
"Gene Symbol '" + gene.getSymbol() +
"' occurs more than once in Xenbase gene file."])
else:
_geneBySymbol[symbolLower] = gene
_addToByAnyName(gene.getSymbol(), gene)
# Name
nameLower = gene.getName().lower()
if nameLower != symbolLower:
if nameLower in _geneByName:
Util.fatalError([
"Gene Name '" + gene.getName() +
"' occurs more than once in Xenbase gene file."])
else:
_geneByName[nameLower] = gene
_addToByAnyName(gene.getName(), gene)
# Synonyms
for syn in gene.getSynonyms():
synLower = syn.lower()
if synLower == symbolLower:
if _verbose:
Util.warning([
"Synonym '" + syn + "' same as symbol. Ignoring synonym."])
else:
if synLower not in _geneBySynonym:
_geneBySynonym[synLower] = []
_geneBySynonym[synLower].append(gene)
return None
示例8: __readGenes
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [as 別名]
def __readGenes(markerFileName):
"""
Read lines from marker file saving information about genes.
"""
markerFile = open(markerFileName, "r")
__verifyStaticFileSection(markerFile, _MGI_MF_EXPECTED_HEADER,
"MGI marker file header not as expected")
# now pointing at first data row; read until you have read all the
# marker data
withdrawn = {} # indexed by lower case symbol
markerLine = "Bogus"
while markerLine not in [None, "", "\n"]:
# read until end of markers
markerLine = markerFile.readline()
markerType = markerLine[_MGI_MF_TYPE_COL:_MGI_MF_TRAILER_COL].strip()
if markerType in ["Gene", "DNA Segment"]:
symbol = markerLine[_MGI_MF_SYMBOL_COL:_MGI_MF_STATUS_COL].strip()
name = markerLine[_MGI_MF_NAME_COL:_MGI_MF_TYPE_COL].strip()
accession = (
markerLine[_MGI_MF_ACCESSION_COL:_MGI_MF_LOCATION_COL].strip())
if accession == "NULL":
accession = None
nomen = GeneNomenclature(symbol, name, accession, markerType)
if nomen.isWithdrawn():
if nomen.getSymbol() == nomen.getReplacementSymbol():
if _verbose:
Util.warning([
"Ignoring self-referential withdrawn MGI record " +
"for symbol '" + nomen.getSymbol() + "'"])
else:
symbolLower = symbol.lower()
if symbolLower in withdrawn:
withdrawn[symbolLower].append(nomen)
else:
withdrawn[symbolLower] = [nomen]
else:
__addGeneToKnowledge(nomen)
markerFile.close()
# Add withdrawn nomenclature
_processWithdrawns(withdrawn)
return
示例9: getGeneNomenclature
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [as 別名]
def getGeneNomenclature(anyName):
"""
Return the GeneNomenclature object that the given string maps to.
Returns None if string does not map to any gene.
anyName can be a gene name, gene symbol, accesion number, or gene
synonym. It is case insensitive.
"""
anyNameLower = anyName.lower()
geneNomen = _nomenclatureByAnyName.get(anyNameLower)
if geneNomen:
if not geneNomen.isGene():
Util.warning([
"'" + anyName + "' refers to a " + geneNomen.getMarkerType() +
" at MGI, which is not a gene."])
else:
# Name is not recognised in names, accessions, symbols, or
# synonyms that map to one entry.
# Check if string maps to a synonym that maps to multiple entries
multipleSyns = _nomenclatureBySynonym.get(anyNameLower)
if multipleSyns:
message = [
"The string '" + anyName +
"' is a synonym that maps to multiple " +
"entries at MGI."]
for synNomen in multipleSyns:
message.append(synNomen.getSymbol())
message.append("Returning none as can't tell which one to pick.")
Util.warning(message)
else:
# Check if string maps to a withdrawn name that maps to multiple
# entries.
multipleSyns = _nomenclatureByWithdrawnName.get(anyNameLower)
if multipleSyns:
message = [
"The string '" + anyName + "' is a withdrawn name that " +
"maps to multiple entries at MGI."]
for synNomen in multipleSyns:
message.append(synNomen.getSymbol())
message.append(
"Returning none as can't tell which one to pick.")
Util.warning(message)
else:
Util.warning([
"The string '" + anyName + "' matches no genes at MGI."])
return geneNomen
示例10: getGeneByAnyName
# 需要導入模塊: from hgu import Util [as 別名]
# 或者: from hgu.Util import warning [as 別名]
def getGeneByAnyName(anyName):
"""
Return the Xenbase Gene object that the given string maps to.
Returns None if string does not map to any gene.
anyName can be a gene name, gene symbol, accesion number, or gene
synonym. It is case insensitive.
"""
anyNameLower = anyName.lower()
gene = _geneByAnyName.get(anyNameLower)
if gene == None:
if anyNameLower in _geneBySynonym:
if len(_geneBySynonym[anyNameLower]) > 1:
Util.warning([
"'" + anyName + "' is a synonym for multiple genes.",
"Can't resolve which one so returning None."])
else:
gene = _geneBySynonym[anyNameLower][0]
if gene == None and _verbose:
Util.warning([
"The string '" + anyName + "' matches no genes at Xenbase."])
return gene