<?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: Perl script for six frame translation !]]></title>
	<link>https://bioinformaticsonline.com/snippets/view/44450/perl-script-for-six-frame-translation?</link>
	<atom:link href="https://bioinformaticsonline.com/snippets/view/44450/perl-script-for-six-frame-translation?" rel="self" type="application/rss+xml" />
	<description><![CDATA[]]></description>
	
	<item>
	<guid isPermaLink="true">https://bioinformaticsonline.com/snippets/view/44450/perl-script-for-six-frame-translation</guid>
	<pubDate>Thu, 01 Feb 2024 01:52:50 -0600</pubDate>
	<link>https://bioinformaticsonline.com/snippets/view/44450/perl-script-for-six-frame-translation</link>
	<title><![CDATA[Perl script for six frame translation !]]></title>
	<description><![CDATA[<code>#!/usr/bin/perl
use strict;
use warnings;
use Bio::SeqIO;

# Path to your input nucleotide sequence file in FASTA format
my $input_fasta = &#039;path/to/your/input.fasta&#039;;

# Step 1: Read the input FASTA file
my $seqio = Bio::SeqIO-&gt;new(-file =&gt; $input_fasta, -format =&gt; &#039;fasta&#039;);
my $sequence = $seqio-&gt;next_seq;

# Step 2: Perform six-frame translation
my @frames = (1, 2, 3, -1, -2, -3);
foreach my $frame (@frames) {
    my $translated_seq = translate_frame($sequence, $frame);
    my $frame_type = $frame &gt; 0 ? &quot;Forward&quot; : &quot;Reverse&quot;;
    print &quot;Frame $frame_type $frame Translation:\n$translated_seq\n&quot;;
}

# Subroutine to translate a sequence in a specific frame
sub translate_frame {
    my ($sequence, $frame) = @_;

    my $translated_seq;
    if ($frame &gt; 0) {
        $translated_seq = $sequence-&gt;translate(-frame =&gt; $frame)-&gt;seq;
    } else {
        # If frame is negative, reverse and complement the sequence before translation
        my $revcomp_seq = $sequence-&gt;revcom;
        $translated_seq = $revcomp_seq-&gt;translate(-frame =&gt; abs($frame))-&gt;seq;
    }

    return $translated_seq;
}</code>]]></description>
	<dc:creator>LEGE</dc:creator>
</item>

</channel>
</rss>