alexarnimueller / lstm_peptides Goto Github PK
View Code? Open in Web Editor NEWLong short-term memory recurrent neural networks for learning peptide and protein sequences to later design new, similar examples.
License: Other
Long short-term memory recurrent neural networks for learning peptide and protein sequences to later design new, similar examples.
License: Other
Hello Alex,
I recently read your work and was very inspired. I found a way to generate pseudo-random peptide sequences in your code:
self.ran = Random(len(self.generated), np.min(d.descriptor), np.max(d.descriptor)) # generate rand seqs
probas = count_aas(''.join(seq_desc.sequences)).values() # get the aa distribution of training seqs
self.ran.generate_sequences(proba=probas)
But the pseudo-random peptide sequences I generated using this code are completely different from the peptide sequences provided in your appendix. Only 15% of the sequences predicted by the CAMP predictor are AMP, but the pseudo-random peptide sequences you provided exceed 70% Both were predicted to be AMP.
May I know what is this all about? How are your pseudo-random peptide sequences generated?
Looking forward to your reply!
Hello Alex,
First and foremost, Thanks a lot for this great repository. I have been using the codebase to fine-tune a pre-trained model on a set of peptides and stumbled upon an unexpected behavior and want to bring it up. As suggested in README, I have run LSTM_peptides.py
by setting train
argument to False
and finetune
to True
, but the code entered the train
branch in the main
function (line 727) and started pre-training instead of fine-tuning.
I have dived deeper into the code and found out that argparse
module parses the value of train
argument as a string, i.e. "False"
, which is, in turn, casted to boolean by Python and evaluated as True
. Thus, the if condition in line 727 (if train:
) evaluates to True
as long as any non-empty string is provided; triggering the pre-training code.
To isolate and reproduce the error, I have created a small script argparse_test.py
with the following content.
import argparse
flags = argparse.ArgumentParser()
flags.add_argument("-t", "--train", default=True, help="whether the network should be trained or just sampled from", type=bool)
args = flags.parse_args()
print(args.train)
When I run this script via a Ubuntu 20 terminal with python3 arparse_test.py --train False
(python version is 3.8.10) the output is True
. In fact, I have experimented with several values (false, None, True
) for train
and the code output is always True
, except for python3 arparse_test.py --train ''
, i.e. when train
is set to an empty string.
I wonder if I am missing something or the suggested fine-tuning command is supported in certain Python versions. If this is unexpected behavior (which might have been affecting many users), indeed, I'd be happy to create a pull request as a fix.
Looking forward to your reply!
Hi. How can I generate the output sequences in fasta or csv files after sampling from trained model?
Running LSTM_peptide.py script by using
Tensorflow=2.3.1
Scikitlearn=0.23.2
keras>=2.0.2
progressbar2>=3.34.2
modlamp>=3.3.0
to generate novel peptide. It shows this error
Error
raise TypeError("Variable is unhashable. "
TypeError: Variable is unhashable. Instead, use tensor.ref() as the key.
I tried to fix other issues however I am unable to locate this one
correct entries in requirements
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.