Source code for mmtfPyspark.utils.traverseStructureHierarchy

#!/usr/bin/env python
'''traverseStructureHierachy.py

A class that prints of hierachy information about a structure

Examples
--------
>>> pdb = mmtfReader.download_mmtf_files(['1STP'], sc)
>>> pdb.foreach(lambda t: traverseStructureHierarchy.printMmtfInfo(t[1]) )

>>> structure = mmtfReader.download_mmtf_files(['1STP'], sc).collect()[0]
>>> traverseStructureHierarchy.print_mmtf_info(structure[1])

'''
__author__ = "Yue Yu"
__maintainer__ = "Mars (Shih-Cheng) Huang"
__email__ = "marshuang80@gmail.com"
__version__ = "0.2.0"
__status__ = "Done"

from mmtfPyspark.utils.dsspSecondaryStructure import *

def _get_chain_to_entity_index(structure):
    entityChainIndex = [0] * structure.num_chains
    for i in range(0, len(structure.entity_list)):
        for j in structure.entity_list[i]["chainIndexList"]:
            entityChainIndex[j] = i
    return entityChainIndex


def _list_to_string(temp):
    return("[" + ", ".join(map(str, temp)) + "]")

def _check_structure_or_tuple(structure):
    if type(structure) == tuple:
        structure = structure[1]
    return structure