當前位置: 首頁>>代碼示例>>Python>>正文


Python MultiGraph.labels方法代碼示例

本文整理匯總了Python中Bio.Pathway.Rep.MultiGraph.labels方法的典型用法代碼示例。如果您正苦於以下問題:Python MultiGraph.labels方法的具體用法?Python MultiGraph.labels怎麽用?Python MultiGraph.labels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bio.Pathway.Rep.MultiGraph的用法示例。


在下文中一共展示了MultiGraph.labels方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Network

# 需要導入模塊: from Bio.Pathway.Rep import MultiGraph [as 別名]
# 或者: from Bio.Pathway.Rep.MultiGraph import labels [as 別名]
class Network(object):
    """A set of species that are explicitly linked by interactions.

    The network is a directed multigraph with labeled edges. The nodes in the graph
    are the biochemical species involved. The edges represent an interaction between
    two species, and the edge label is a reference to the associated Interaction
    object.

    Attributes:

    None
    
    """

    def __init__(self, species = []):
        """Initializes a new Network object."""
        self.__graph = MultiGraph(species)

    def __repr__(self):
        """Returns a debugging string representation of this network."""
        return "<Network: __graph: " + repr(self.__graph) + ">"

    def __str__(self):
        """Returns a string representation of this network."""
        return "Network of " + str(len(self.species())) + " species and " + \
               str(len(self.interactions())) + " interactions."

    def add_species(self, species):
        """Adds species to this network."""
        self.__graph.add_node(species)

    def add_interaction(self, source, sink, interaction):
        """Adds interaction to this network."""
        self.__graph.add_edge(source, sink, interaction)

    def source(self, species):
        """Returns list of unique sources for species."""
        return self.__graph.parents(species)

    def source_interactions(self, species):
        """Returns list of (source, interaction) pairs for species."""
        return self.__graph.parent_edges(species)

    def sink(self, species):
        """Returns list of unique sinks for species."""
        return self.__graph.children(species)

    def sink_interactions(self, species):
        """Returns list of (sink, interaction) pairs for species."""
        return self.__graph.child_edges(species)

    def species(self):
        """Returns list of the species in this network."""
        return self.__graph.nodes()

    def interactions(self):
        """Returns list of the unique interactions in this network."""
        return self.__graph.labels()
開發者ID:BingW,項目名稱:biopython,代碼行數:60,代碼來源:__init__.py


注:本文中的Bio.Pathway.Rep.MultiGraph.labels方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。