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


Python HashSet.list方法代码示例

本文整理汇总了Python中Bio.Pathway.Rep.HashSet.list方法的典型用法代码示例。如果您正苦于以下问题:Python HashSet.list方法的具体用法?Python HashSet.list怎么用?Python HashSet.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bio.Pathway.Rep.HashSet的用法示例。


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

示例1: testList

# 需要导入模块: from Bio.Pathway.Rep import HashSet [as 别名]
# 或者: from Bio.Pathway.Rep.HashSet import list [as 别名]
 def testList(self):
     a = HashSet(['a', 'b', 'c', 'd', 'e'])
     l = a.list()
     l.sort()
     self.assertEqual(l, ['a', 'b', 'c', 'd', 'e'], "incorrect list")
     l = []
     self.assertTrue('e' in a, "set rep exposure")
开发者ID:,项目名称:,代码行数:9,代码来源:

示例2: children

# 需要导入模块: from Bio.Pathway.Rep import HashSet [as 别名]
# 或者: from Bio.Pathway.Rep.HashSet import list [as 别名]
 def children(self, parent):
     """Returns a list of unique children for parent."""
     s = HashSet([x[0] for x in self.child_edges(parent)])
     return s.list()
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:6,代码来源:MultiGraph.py

示例3: species

# 需要导入模块: from Bio.Pathway.Rep import HashSet [as 别名]
# 或者: from Bio.Pathway.Rep.HashSet import list [as 别名]
 def species(self):
     """Returns a list of the species in this system."""
     s = HashSet(reduce(lambda s,x: s + x,
                        [x.species() for x in self.reactions()], []))
     return s.list()
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:7,代码来源:__init__.py

示例4: parents

# 需要导入模块: from Bio.Pathway.Rep import HashSet [as 别名]
# 或者: from Bio.Pathway.Rep.HashSet import list [as 别名]
 def parents(self, child):
     """Returns a list of unique parents for child."""
     s = HashSet([x[0] for x in self.parent_edges(child)])
     return s.list()
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:6,代码来源:MultiGraph.py

示例5: __init__

# 需要导入模块: from Bio.Pathway.Rep import HashSet [as 别名]
# 或者: from Bio.Pathway.Rep.HashSet import list [as 别名]
class System:
    """Abstraction for a collection of reactions.

    This class is used in the Bio.Pathway framework to represent an arbitrary
    collection of reactions without explicitly defined links.

    Attributes:

    None    
    """
    
    def __init__(self, reactions = []):
        """Initializes a new System object."""
        self.__reactions = HashSet(reactions)

    def __repr__(self):
        """Returns a debugging string representation of self."""
        return "System(" + ",".join(map(repr,self.__reactions.list())) + ")"
    
    def __str__(self):
        """Returns a string representation of self."""
        return "System of " + str(len(self.__reactions)) + \
               " reactions involving " + str(len(self.species())) + \
               " species"

    def add_reaction(self, reaction):
        """Adds reaction to self."""
        self.__reactions.add(reaction)

    def remove_reaction(self, reaction):
        """Removes reaction from self."""
        self.__reactions.remove(reaction)

    def reactions(self):
        """Returns a list of the reactions in this system."""
        return self.__reactions.list()

    def species(self):
        """Returns a list of the species in this system."""
        s = HashSet(reduce(lambda s,x: s + x,
                           [x.species() for x in self.reactions()], []))
        return s.list()

    def stochiometry(self):
        """Computes the stoichiometry matrix for self.

        Returns (species, reactions, stoch) where

            species    = ordered list of species in this system
            reactions  = ordered list of reactions in this system
            stoch      = 2D array where stoch[i][j] is coef of the
                         jth species in the ith reaction, as defined
                         by species and reactions above
        """
        # Note: This an inefficient and ugly temporary implementation.
        #       To be practical, stochiometric matrices should probably
        #       be implemented by sparse matrices, which would require
        #       NumPy dependencies.
        #
        # PS: We should implement automatic checking for NumPy here.
        species = self.species()
        reactions = self.reactions()
        stoch = [] * len(reactions)
        for i in range(len(reactions)):
            stoch[i] = 0 * len(species)
            for s in reactions[i].species():
                stoch[species.index(s)] = reactions[i].reactants[s]
        return (species, reactions, stoch)
开发者ID:BlogomaticProject,项目名称:Blogomatic,代码行数:70,代码来源:__init__.py


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