Rewriting perl code using bioperl

Code: #!/usr/bin/perl use strict; use warnings; die “Usage: $0 <fasta_file style=”box-sizing: border-box; color: rgb(102, 102, 102); font-family: ‘Open Sans’, sans-serif; font-size: 13px; font-style: italic; line-height: 20px; background-color: rgb(251, 251, 251);”><coord_file style=”box-sizing: border-box;”>n” unless @ARGV > 0; my ($fasta_file, $coord_file) = @ARGV; open FASTA, “<” . $fasta_file; my $seq_id; my $dna_string = “”; my $count_seq = 0; while () { my $line = $_; chomp $line; if ($line =~ /^>(.+)$/) { $seq_id = $1; $count_seq++; next; } else { $dna_string .= $line } } open COORD, “<” . $coord_file; while () { my $line = $_; chomp $line; next unless $line =~ /^(d+)s+(d+)s+(d+)s+([+-][123])s+(S+)s*/; my ($id, $x, $y, $frame, $score) = ($1, $2, $3, $4, $5); print “Putative Genesn”; print “>$id start_coord = $x, stop_coord = $y, frame = $frame, score = $scoren”; print &orf_seq($x, $y, $frame),”n”; } sub orf_seq { my ($x, $y, $frame) = @_; my $orf; if ($x < $y) { $orf = substr($dna_string, $x – 1, $y – $x + 1); } else { $orf = substr($dna_string, $y – 1, $x – $y + 1); $orf = &revcom($orf); } return $orf; } sub revcom { my $string = shift @_; $string =~ tr/ATCG/TAGC/; my $rev = reverse $string; return $rev; }

Read more here: Source link