Beispiel #1
0
def _create_struct_dict(interval_dict, ss_dis, uni_folder):
    """ Creates the structure dictionary.

    Args:
        interval_dict (dict): A dictionary in the following form:
                {
                        '11BG_A_Q3E840':
                            [
                                [
                                    [1, 124],
                                    [27, 150]
                                ]
                            ]
                    }
        uni_folder (Unicode): A path to the folder that has single
            UniProt fasta files.
        ss_dis: a dictionary extracted from ss_dis.txt, in the following form:
            ss_dis[pdb_A] = {
                'sequence': '',
                'secstr': '',
                'disorder': ''
            }

    Returns:
        A dictionary in the following form:
        {
            'PDB_CHAIN': [],
            'UNIPROT': [],
            'SEC_STRUCT': []
        }

    """
    structure_dict = {'PDB_CHAIN': [], 'SP_PRIMARY': [], 'SEC_STRUCT': []}
    for pdb_chain_uni in interval_dict:
        pdb_chain = ''.join([
            pdb_chain_uni.split('_')[0],
            '_',
            pdb_chain_uni.split('_')[1]
        ])
        uni_id = pdb_chain_uni.split('_')[2]

        uni_fp = build_abs_path(uni_folder, uni_id)
        len_uni_seq = len(
            (SeqIO.read(open(uni_fp), "fasta")).seq
        )

        disorder = ss_dis[pdb_chain]['disorder']
        ss = ss_dis[pdb_chain]['secstr']
        intervals = interval_dict[pdb_chain_uni]
        pdb_struct = _create_pdb_struct(intervals, disorder, ss, len_uni_seq)

        structure_dict['PDB_CHAIN'].append(pdb_chain)
        structure_dict['SP_PRIMARY'].append(uni_id)
        structure_dict['SEC_STRUCT'].append(pdb_struct)
    return structure_dict