alexarnimueller/LSTM_peptides

Error in sequence analysis generated in source code

zhouhao-learning opened this issue · 5 comments

Hello, I've been paying attention to your work recently, but unfortunately, I can't run your code correctly through the examples you provided. When I execute the command python LSTM_peptides.py -- name Train100 -- dataset new_sequences.csv -- layers 2 -- neurons 64 -- epochs 10 sample -- 2, my error goes to the following:

Traceback (most recent call last):
  File "LSTM_peptides.py", line 791, in <module>
    finetune=FLAGS.finetune, references=FLAGS.refs)
  File "LSTM_peptides.py", line 780, in main
    data.analyze_generated(sample, fname=model.logdir + '/analysis_temp' + str(temperature) + '.txt', plot=True)
  File "LSTM_peptides.py", line 400, in analyze_generated
    a.plot_summary(filename=fname[:-4] + '.png')
  File "/home/zh/anaconda3/envs/LSTM_Squence/lib/python3.5/site-packages/modlamp/analysis.py", line 197, in plot_summary
    self.calc_len()
  File "/home/zh/anaconda3/envs/LSTM_Squence/lib/python3.5/site-packages/modlamp/analysis.py", line 177, in calc_len
    d.length()
  File "/home/zh/anaconda3/envs/LSTM_Squence/lib/python3.5/site-packages/modlamp/descriptors.py", line 264, in length
    desc.append(float(len(seq.strip())))
AttributeError: 'list' object has no attribute 'strip'

And some of the grammar in your code is Python 2, and some of the grammar is Python 3. If I don't modify your source code, I won't be able to use Python 2 to create the model, because there will be some unexpected errors in Python 2. I modified some of your code to be Python 3 grammar, so that I can correctly train the model and generate the sequence.
The reason I got the error is because some of the sequences from the d. length () function are strings and some are lists. I don't understand why. Shouldn't the generated sequences be strings? Why is there a list? Please tell me how I can solve this mistake?

hi zhouhao-learning
first of all: great that you found our code and a use case for it.
I'm sorry for the inconvenience. an external module, modlamp, has changed in the meantime. I have fixed the bug there. yet, you will need to do the following to make it work:

  1. pip install --update modlamp
  2. update the LSTM_peptides repository (in the LSTM_peptides folder type "git pull origin master")

let me know if you succeed

@alexarnimueller
Hello,
First of all, thank you for your reply, but I cloned your code, updated modlamp, and used Python 2.7. When I executed the command python LSTM_peptides.py--epochs 2, I got another error:

Traceback (most recent call last):
  File "LSTM_peptides.py", line 793, in <module>
    _save_flags("./" + FLAGS.name + "/flags.txt")
  File "LSTM_peptides.py", line 78, in _save_flags
    f.write(k + ": " + str(v.value) + "\n")
AttributeError: 'bool' object has no attribute 'value'

I resolved this error by modifying your LSTM_peptides.py file. Here is the correct code after the modification.

def _save_flags(flgs, filename):
    with open(filename, 'w') as f:
        f.write("Used flags:\n-----------\n")
        for k, v in flgs.__dict__['__flags'].items():
            f.write(k + ": " + str(v) + "\n")

Finally, I still can't run in Python 3 environment. I think you should change some code so that it can be executed in Python 3 environment, because Python 2 is not updated now. I hope you can take my advice. Thank you.

The code runs very well on python2.7 and I will keep it like that. Why don't you make an environment for it?
Concerning the flags: newer tensorflow versions don't support your change. So better keep my way of saving the flags and just update your tensorflow

Well, I just recommend that you change it to Python version 3, because I believe many people will prefer to use Python 3 if they see your code later, because Python 3 is more active and python 2 is no longer updated, and the tensofrlow 1.3 you provide does not make your code work properly, it will be at the time of model creation. error

I don't want to argue any longer about it. If there is a bug, let me know where and I'll fix it. The code runs without error for me