Exemplo n.º 1
0
def create_uni_struct(pdb_df):
    """ Creates a DataFrame that has UniProt ID and composite
    structure for UniProt.

    Args:
        pdb_df (DataFrame): A DataFrame produced by create_composite.

    Returns:
        df (DataFrame): A new DataFrame with UniProt ID and
        composite UniProt structure.

    """
    uni_struct = {'SP_PRIMARY': [], 'STRUCT': []}
    uni_list = read_pdb_chain_uniprot_uniIDs(pdb_df)
    progress = ProgressBar(
        len(uni_list),
        approx_percentage=1,
        start_msg="Creating DataFrame with ID and composite structure.",
        end_msg="Done creating DataFrame with ID and composite structure."
    )
    for uni in uni_list:
        pdbs = pdb_df[pdb_df.SP_PRIMARY == uni]
        struct_list = []
        assert len(pdbs.index) > 1
        for i, row in pdbs.iterrows():
            struct_list.append(row.SEC_STRUCT)
        assert len(struct_list) > 1
        for struct in struct_list:
            assert len(struct) > 0
            assert len(struct) == len(struct_list[0])
        assert len(struct_list) == len(pdbs.index)
        comp_struct = _uni_struct(struct_list)
        uni_struct['SP_PRIMARY'].append(uni)
        uni_struct['STRUCT'].append(comp_struct)
        progress.inc()

    df = pd.DataFrame(uni_struct)
    return df
Exemplo n.º 2
0
 def _initialize_uniprot_list(self):
     self.uni_list = read_pdb_chain_uniprot_uniIDs(self.df)
     return None