#!usr/bin/perl -w use library; use strict; ### Translates a sequence in all 6 frames. # Cutoff value for sizes of ORFs returned can be altered within the subroutine # 'split_sequence'. ### my $filename = usrquery ("Please enter filename: \n"); my @filedata = read_file_data ($filename); my $tag = extract_tag (@filedata); my $dna = extract_sequence (@filedata); $dna =~ tr/actg/ACTG/; my $size = length($dna); my ($start, $stop, $j, $translated_frame, $frame) = ''; my (@all_orfs) = (); my $outputfile = ''; # Remember to 'close OUTFILE' at end # open_outfile; $j = 1; while ($j < 4) {$frame = $j; @all_orfs = (); $translated_frame = ''; for (my $i=($frame-1);$i < (length($dna)-2);$i +=3) {my $codon = substr ($dna, $i, 3); $translated_frame .= trans ($codon);} @all_orfs = split_sequence ($translated_frame); foreach my $ORF (@all_orfs) {$translated_frame =~ /$ORF/ig; $stop = pos ($translated_frame); $start = ($stop - (length $ORF))+1; my ($nt_start, $nt_stop) = counting ($start, $stop, $frame); my $aa = length $ORF; print OUTFILE "$tag, $size bp, frame $frame, positions $nt_start to $nt_stop, $aa residues.\n"; print OUTFILE "$ORF\n"; } ++$j;} my $rc = revcomp ($dna); $j = 1; while ($j < 4) {$frame = $j; @all_orfs = (); $translated_frame = ''; for (my $i=($frame-1);$i < (length($dna)-2);$i +=3) {my $codon = substr ($rc, $i, 3); $translated_frame .= trans ($codon);} @all_orfs = split_sequence ($translated_frame); foreach my $ORF (@all_orfs) {$translated_frame =~ /$ORF/ig; $stop = pos ($translated_frame); $start = ($stop - (length $ORF))+1; my ($nt_start, $nt_stop) = counting ($start, $stop, $frame); my $rc_nt_start = (($size - $nt_start)+1); my $rc_nt_stop = (($size - $nt_stop)+1); my $aa = length $ORF; print OUTFILE "$tag, $size bp, frame -$frame, positions $rc_nt_start to $rc_nt_stop, $aa residues.\n"; print OUTFILE "$ORF\n"; }++$j;} close OUTFILE; exit;