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


Python Library.library_is_nucleic_acid方法代码示例

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


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

示例1: name_service

# 需要导入模块: import Library [as 别名]
# 或者: from Library import library_is_nucleic_acid [as 别名]
    def name_service(self):
        """Runs the name service on all atoms needing to be named. This is a
        complicated function which corrects most commonly found errors and
        omissions from PDB files.
        """
        if len(self.name_service_list) == 0:
            return

        ## returns the next available chain_id in self.struct
        ## XXX: it's possible to run out of chain IDs!
        def next_chain_id(suggest_chain_id):
            if suggest_chain_id != "":
                chain = self.struct.get_chain(suggest_chain_id)
                if not chain:
                    return suggest_chain_id

            ## TODO: Add the following alphanumeric string to Constants.py, 2010-09-21
            for chain_id in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789":
                chain = self.struct.get_chain(chain_id)
                if not chain:
                    return chain_id

            raise StructureBuilderError("name_service exhausted new chain_ids")


        ## NAME SERVICE FOR POLYMER ATOMS

        ## What if we are given a list of atoms with res_name, frag_id, and 
        ## model_id where the frag_id are sequential? They can be sequential 
        ## several ways using insertion codes, but large breaks often denote 
        ## chain breaks.

        ## We need to handle the special case of a list of polymer residues
        ## which do not have chain_ids. This requires a first pass over the
        ## atom list using different rules than what we use for sorting out
        ## non-polymers.

        current_polymer_type      = None
        current_polymer_model_id  = None
        current_polymer_chain_id  = None
        current_polymer_frag_id   = None
        current_polymer_res_name  = None
        current_polymer_name_dict = None

        polymer_model_dict = {}
        current_frag       = None
        current_frag_list  = None

        for atm in self.name_service_list[:]:
            ## determine the polymer type of the atom
            if Library.library_is_amino_acid(atm.res_name):
                polymer_type = "protein"
            elif Library.library_is_nucleic_acid(atm.res_name):
                polymer_type = "dna"
            else:
                ## if the atom is not a polymer, we definitely have a break
                ## in this chain
                current_polymer_type      = None
                current_polymer_model_id  = None
                current_polymer_chain_id  = None
                current_polymer_frag_id   = None
                current_polymer_res_name  = None
                current_polymer_name_dict = None
                current_frag              = None
                current_frag_list         = None
                continue

            fragment_id = Structure.FragmentID(atm.fragment_id)

            ## now we deal with conditions which can terminate the current
            ## polymer chain
            if polymer_type!=current_polymer_type or \
               atm.model_id!=current_polymer_model_id or \
               atm.chain_id!=current_polymer_chain_id or \
               fragment_id<current_polymer_frag_id:

                current_polymer_type      = polymer_type
                current_polymer_model_id  = atm.model_id
                current_polymer_chain_id  = atm.chain_id
                current_polymer_frag_id   = Structure.FragmentID(atm.fragment_id)
                current_polymer_res_name  = atm.res_name
                current_polymer_name_dict = {atm.name: True}

                ## create new fragment
                current_frag = [atm]
                current_frag_list = [current_frag]

                ## create new fragment list (chain)
                try:
                    model = polymer_model_dict[atm.model_id]
                except KeyError:
                    model = [current_frag_list]
                    polymer_model_dict[atm.model_id] = model
                else:
                    model.append(current_frag_list)

                ## we have now dealt with the atom, so it can be removed from 
                ## the name service list
                self.name_service_list.remove(atm)
                continue
#.........这里部分代码省略.........
开发者ID:masci,项目名称:mmLib,代码行数:103,代码来源:StructureBuilder.py


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