debbiemarkslab / EVmutation

Mutation effects predicted from sequence co-variation
61 stars 12 forks source link

CouplingsModel instance has no attribute 'index_map' #1

Closed rraadd88 closed 7 years ago

rraadd88 commented 7 years ago

while running commands in the EVmutation.ipynb, for following command,


# read the experimental mutational scanning dataset for PABP by Melamed et al., RNA, 2013
data = pd.read_csv(
    "example/PABP_YEAST_Fields2013-singles.csv", sep=";", comment="#"
)

# predict mutations using our model
data_pred = tools.predict_mutation_table(
    c, data, "effect_prediction_epistatic"
)
I got this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
 in ()
      6 # predict mutations using our model
      7 data_pred = tools.predict_mutation_table(
----> 8     c, data, "effect_prediction_epistatic"
      9 )

path/to/EVmutation-master/tools.py in predict_mutation_table(model, table, output_column, mutant_column, hamiltonian)
    117 
    118     # predict mutations and add to table
--> 119     pred.loc[:, output_column] = mutations.map(_predict_mutant)
    120 
    121     return pred

path/to/anaconda/envs/py27_evmut/lib/python2.7/site-packages/pandas/core/series.pyc in map(self, arg, na_action)
   2175             new_values = algos.take_1d(arg._values, indexer)
   2176         else:
-> 2177             new_values = map_f(values, arg)
   2178 
   2179         return self._constructor(new_values,

pandas/src/inference.pyx in pandas.lib.map_infer (pandas/lib.c:66124)()

path/to/EVmutation-master/tools.py in _predict_mutant(mutation_str)
     85         try:
     86             m = extract_mutations(mutation_str)
---> 87             delta_E = model.delta_hamiltonian(m)
     88             return delta_E[_component]
     89         except ValueError:

path/to/EVmutation-master/model.py in delta_hamiltonian(self, substitutions, verify_mutants)
    611         try:
    612             for i, (subs_pos, subs_from, subs_to) in enumerate(substitutions):
--> 613                 pos[i] = self.index_map[subs_pos]
    614                 subs[i] = self.alphabet_map[subs_to]
    615                 if verify_mutants and subs_from != self.target_seq[pos[i]]:

AttributeError: CouplingsModel instance has no attribute 'index_map'
I am not sure why this is happening.
thomashopf commented 7 years ago

Your error log suggests that you are running the notebook with Python 2.7 (which gives me the same error message)? Please note that we support only Python >= 3.5. Does switching to Python 3 fix the issue for you?

rraadd88 commented 7 years ago

Thanks. I should have read the instructions carefully. Switching to python 3 fixed the issue. Sorry for the trouble. I guess equivalent of following snippet in python 3.5 may avoid this happening again with somebody.


if (sys.version_info[0], sys.version_info[1]) != (2, 7):
    raise RuntimeError('Python 2.7 required')