convert list to fasta format
0
0
Entering edit mode
4 months ago

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

python fasta • 443 views
ADD COMMENT
0
Entering edit mode

show us what you tried.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode
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
ADD REPLY
0
Entering edit mode

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)
ADD REPLY

Login before adding your answer.

Traffic: 1927 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6