kyu999 / biovec

A new approach for representing biological sequences
https://pypi.org/project/biovec/
99 stars 33 forks source link

Error loading the swissprot saved model in python 3.6 #11

Closed rainwala closed 4 years ago

rainwala commented 4 years ago

Hello,

I am trying your code (I installed via pip3), and when I try to load the swissprot model using this code:

import biovec

pv = biovec.models.load_protvec('biovec/swissprot-reviewed-protvec.model')
print(pv.to_vecs("ATATQSQSMTEEL"))

I get the error:

/home/aawan/.local/lib/python3.6/site-packages/smart_open/smart_open_lib.py:398: UserWarning: This function is deprecated, use smart_open.open instead. See the migration notes for details: https://github.com/RaRe-Technologies/smart_open/blob/master/README.rst#migrating-to-the-new-open-function
  'See the migration notes for details: %s' % _MIGRATION_NOTES_URL
Traceback (most recent call last):
  File "test_biovec.py", line 3, in <module>
    pv = biovec.models.load_protvec('biovec/swissprot-reviewed-protvec.model')
  File "/usr/local/lib/python3.6/dist-packages/biovec/models/prot_vec.py", line 6, in load_protvec
    return word2vec.Word2Vec.load(model_fname)
  File "/usr/local/lib/python3.6/dist-packages/gensim/models/word2vec.py", line 975, in load
    return super(Word2Vec, cls).load(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/gensim/models/base_any2vec.py", line 629, in load
    model = super(BaseWordEmbeddingsModel, cls).load(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/gensim/models/base_any2vec.py", line 278, in load
    return super(BaseAny2VecModel, cls).load(fname_or_handle, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/gensim/utils.py", line 425, in load
    obj = unpickle(fname)
  File "/usr/local/lib/python3.6/dist-packages/gensim/utils.py", line 1332, in unpickle
    return _pickle.load(f, encoding='latin1')
_pickle.UnpicklingError: invalid load key, '\x0a'.
kyu999 commented 4 years ago

What version of biovec are you using? If it's not up-to-date, please update it first :)

I could not reproduce this error under this condition:

biovec 0.2.7 gensim 3.4.0 Python 3.6.7

rainwala commented 4 years ago

Hi,

I am using biovec 0.2.7 gensim 3.4.8 Python 3.6.8

Should I try downgrading gensim?

kyu999 commented 4 years ago

Yeah let's make the versions same, also download the latest model file again. By the way, What OS are you using?