This is a test version of Biostars. For the public version, visit https://www.biostars.org.
convert list to fasta format

How can I convert a Python list of peptide sequences to fasta format?

python fasta

I just have a python list, containing several peptide sequences, each peptide is 50 amino acids length. I want to run this list in a machine learning program, but before I need to put it in fasta format.

open a file for writing
loop over each item in the dictionary
   write the sign '>'
   write the sequence name
   write a line return
   write the sequence dna
   write a line return
close the file

I'm writing the Python script below. I had some issues, but now it's working, my main difficulty now is to convert the output (a list) to fasta format. Do I need to convert the list to a panda dataframe before? or there is a more straight forward way to do it? can you give me a more pythonic answer?

sequence = input("Digit the peptide sequence: ")
peptides(sequence):
peptides_50 = []
for i in range(0, len(sequence) - 50):
    peptides_50 += [''.join(sequence[i:i+50])]
 print(peptides_50)

0 answers

No answers yet.

Log in to answer this question.