syntenyGeneSetAnalysis.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:xenoGI 作者: ecbush 项目源码 文件源码
def scoreGeneSet(geneT,scoresO,geneNames,scoreType):
    '''Given a tuple of genes in geneT, calculate the average score
between them. If there are some genes that lack a score, we give it
the minimum possible. The kind of score we use is indicated by
scoreType, which corresponds to the type of score in the scores
graph.
    '''

    geneNumsL = [geneNames.nameToNum(name) for name in geneT]
    edgeL = getInternalEdges(geneNumsL,scoresO)

    scSum = sum((scoresO.getScoreByEdge(edge,scoreType) for edge in edgeL))

    # if there was an edge between every node, there would be
    # len(geneT) choose 2.
    maxPossibleNumEdges = len(list(itertools.combinations(geneT,2)))
    actualNumEdges = len(edgeL)

    numMissEdge=maxPossibleNumEdges-actualNumEdges

    scSum += numMissEdge * min(scoresO.scoreD[scoreType])

    avSc = scSum / maxPossibleNumEdges

    return avSc,maxPossibleNumEdges,actualNumEdges
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号