<?xml version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
	<title><![CDATA[BOL: Python script for six frame translation of sequences !]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/44451/python-script-for-six-frame-translation-of-sequences?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/44451/python-script-for-six-frame-translation-of-sequences?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44451/python-script-for-six-frame-translation-of-sequences</guid>
	<pubDate>Thu, 01 Feb 2024 01:54:14 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44451/python-script-for-six-frame-translation-of-sequences</link>
	<title><![CDATA[Python script for six frame translation of sequences !]]></title>
	<description><![CDATA[<code>from Bio import SeqIO
from Bio.Seq import Seq

def translate_frame(sequence, frame):
    if frame &gt; 0:
        translated_seq = sequence[frame-1:].translate()
    else:
        reverse_complement = sequence.reverse_complement()
        translated_seq = reverse_complement[abs(frame)-1:].translate()

    return translated_seq

def six_frame_translation(fasta_file):
    records = list(SeqIO.parse(fasta_file, &quot;fasta&quot;))

    for record in records:
        print(f&quot;Sequence ID: {record.id}&quot;)
        for frame in range(1, 7):
            protein_sequence = translate_frame(record.seq, frame)
            frame_type = &quot;Forward&quot; if frame &gt; 0 else &quot;Reverse&quot;
            print(f&quot;Frame {frame_type} {abs(frame)} Translation:\n{protein_sequence}\n&quot;)

# Replace &#039;path/to/your/input.fasta&#039; with the actual path to your input nucleotide sequence in FASTA format
input_fasta = &#039;path/to/your/input.fasta&#039;
six_frame_translation(input_fasta)</code>]]></description>
	<dc:creator>LEGE</dc:creator>
</item>

</channel>
</rss>