I am new in perl and haven't enough information for this language. Appology if there are mistakes in the code. I have gone through biostar question[1] and other pages on internet to translate DNA sequences in to 6 reading frames. what I tried is
usr/bin/perl
use strict;
use warnings;
local $/ = "\r\n";
my @frames = (1, 2, 3, 4, 5, 6);
foreach my $frame (@frames) {
frame ($frame);
sub frame
{
my $f = shift;
open "3mo_m10_clean_1_paired_assembly_linear_seq.fasta", $ARGV[0];
while ("3mo_m10_clean_1_paired_assembly_linear_seq.fasta"){
chomp;
my $m = length ($_);
if (/^>(\w+)/){
print ">$1"."_"."frame"."$f"."\n";
}elsif($f > 0){
my $frameseq = substr($_, $f-1, $m-$f+1);
print "$frameseq\n";
}elsif ($f<0){
my $comprevseq = reverse $_;
$comprevseq = ~ tr/[A,T,C,G,a,t,c,g,]/ [T,A,G,C,t,a,g,c]/;
my $frameseq = substr ($comprevseq, abs($f)-1, $m-abs($f)+1);
print "$frameseq\n";
}
}
}
close "3mo_m10_clean_1_paired_assembly_linear_seq.fasta";
}
I got the following error and don't know hot to fix it.
Use of uninitialized value $_ in scalar chomp at 3mo_10_clean_1_paire_assembly_linear_seq_6frame.pl line 18.
Use of uninitialized value $_ in pattern match (m//) at 3mo_10_clean_1_paire_assembly_linear_seq_6frame.pl line 21.
Use of uninitialized value $m in subtraction (-) at 3mo_10_clean_1_paire_assembly_linear_seq_6frame.pl line 24.
Use of uninitialized value $_ in substr at 3mo_10_clean_1_paire_assembly_linear_seq_6frame.pl line 24.
I tried as you mentioned using file handle but it is giving following error:
I made an error in my code. Fixed it in the original post