在python中迭代两个字典

时间:2016-12-05 06:40:24

标签: python numpy dictionary

下面的代码给了我一个只有19项的mw_vs_sasa字典,即使amino_acid_dictionary和amino_acid_mw都有20个。请帮我调试一下。

  amino_acid_dictionary = {'ALA': ALA, 'ARG': ARG, 'ASN': ASN, 'ASP': ASP, 
                        'CYS': CYS, 'GLU': GLU, 'GLN': GLN, 'GLY': GLY,
                        'HIS': HIS, 'ILE': ILE, 'LEU': LEU, 'LYS': LYS, 
                        'MET': MET, 'PHE': PHE, 'PRO': PRO, 'SER': SER,
                        'THR': THR, 'TRP': TRP, 'TYR': TYR, 'VAL': VAL}

    amino_acid_mw = {'ALA': 89.09, 'ARG': 174.20, 'ASN': 132.12, 'ASP': 133.10, 
                         'CYS': 121.16, 'GLU': 147.13, 'GLN': 146.15, 'GLY': 75.07,
                         'HIS': 155.16, 'ILE': 131.18, 'LEU': 131.18, 'LYS': 146.19, 
                         'MET': 149.21, 'PHE': 165.19, 'PRO': 115.13, 'SER': 105.09,
                         'THR': 119.12, 'TRP': 204.23, 'TYR': 181.19, 'VAL': 117.15}
    mw_vs_sasa = {}
    oo=0
    for (title, weight) in amino_acid_mw.items():
        oo+=1
        print(oo)
        mw_vs_sasa[weight] = np.mean(amino_acid_dictionary[title])

0 个答案:

没有答案