knobs_into_holes.py 文件源码

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

项目:isambard 作者: woolfson-group 项目源码 文件源码
def filter_graph(g, cutoff=7.0, min_kihs=2):
        """ Get subgraph formed from edges that have max_kh_distance < cutoff.

        Parameters
        ----------
        g : MultiDiGraph representing KIHs
            g is the output from graph_from_protein
        cutoff : float
            Socket cutoff in Angstroms.
            Default is 7.0.
        min_kihs : int
            Minimum number of KIHs shared between all pairs of connected nodes in the graph.

        Returns
        -------
        networkx.MultiDigraph
            subgraph formed from edges that have max_kh_distance < cutoff.
        """
        edge_list = [e for e in g.edges(keys=True, data=True) if e[3]['kih'].max_kh_distance <= cutoff]
        if min_kihs > 0:
            c = Counter([(e[0], e[1]) for e in edge_list])
            # list of nodes that share > min_kihs edges with at least one other node.
            node_list = set(list(itertools.chain.from_iterable([k for k, v in c.items() if v > min_kihs])))
            edge_list = [e for e in edge_list if (e[0] in node_list) and (e[1] in node_list)]
        return networkx.MultiDiGraph(edge_list)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号