当前位置: 首页>>代码示例>>Python>>正文


Python hgu.Util类代码示例

本文整理汇总了Python中hgu.Util的典型用法代码示例。如果您正苦于以下问题:Python Util类的具体用法?Python Util怎么用?Python Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initialise

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:26,代码来源:PerspectiveAmbits.py

示例2: createNode

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:25,代码来源:Nodes.py

示例3: getCloneByNibbXdbId

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:28,代码来源:NibbXdbClone.py

示例4: checkForNewRoot

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:30,代码来源:Nodes.py

示例5: setGroupStatus

    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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:60,代码来源:ReportTree011.py

示例6: createStage

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:29,代码来源:Stages.py

示例7: initialise

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:28,代码来源:Stages.py

示例8: selectOne

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:26,代码来源:DbAccess.py

示例9: _addToKnowledge

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:29,代码来源:PartOfs.py

示例10: __addGeneToKnowledge

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:35,代码来源:MgiMarker.py

示例11: getByAncestorOid

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:26,代码来源:AnadRelationshipTransitiveDb.py

示例12: initialise

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
开发者ID:ma-tech,项目名称:Anatomy,代码行数:59,代码来源:DbAccess.py

示例13: __init__

    def __init__(self, filePath, reportTree):
        """
        Open a linear report file.

        This method must be overriden by a derived class.  Raises exception
        if it is ever called.
        """
        Util.methodNotOverriddenError()
开发者ID:ma-tech,项目名称:Anatomy,代码行数:8,代码来源:ReportFile011.py

示例14: addPageBreak

    def addPageBreak(self):
        """
        Add a page break.

        This method must be overriden by a derived class.  Raises exception
        if it is ever called.
        """
        Util.methodNotOverriddenError()
开发者ID:ma-tech,项目名称:Anatomy,代码行数:8,代码来源:ReportFile011.py

示例15: addH3

    def addH3(self, textLine):
        """
        Add a normal header line.

        This method must be overriden by a derived class.  Raises exception
        if it is ever called.
        """
        Util.methodNotOverriddenError()
开发者ID:ma-tech,项目名称:Anatomy,代码行数:8,代码来源:ReportFile011.py


注:本文中的hgu.Util类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。