This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Translate Multiple Sequences With Bio.Seq

I have a list of multiple sequences that I am looking to translate into protein (hundreds of sequences). I am trying to translate each of the sequences and create a new column of the translation using Bio.Seq. I can translate a sequence individually, but I am looking to write a loop to translate all the sequences in the dataframe. I am unable to use publically available resources because of IP issues.

With the code below I get the error:

TypeError: The sequence data given to a Seq object should be a string (not another Seq object etc)

The df containing the sequences looks like the following and is titled "translate":

0     ['caggaggtgc...
1     ['cagagggtct...

current code:

for line in translate:
fields = line.split('\t')
sequence_m = fields[:]
        if not sequence_m in sequence_m_list:
        sequence_m_list.append(sequence_m)

from Bio.Seq import Seq, Alphabet, IUPAC
from Bio.Alphabet import IUPAC
for I in range(len(sequence_m_list)):
        seq_m = Seq(sequence_m_list[i])
        translated_seq_m = seq_m.translate()

Any insights would be appreciated!

sequence python

A couple of points on your post:

  1. This is a Question-type post, not a Forum discussion. I've made the necessary change. To learn more, please read posts under the how-to tag.
  2. Please use the formatting bar (especially the code option) to present your post better. You can use backticks for inline code (`text` becomes text), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.
    code_formatting

Thank you, very useful! This is my first post and didn't realize these options.

Welcome to the forum! I apologize for the lack of introduction to forum features. We're working on ways for users to get a quick intro to these options while they're making their first post.

0 answers

No answers yet.

Log in to answer this question.