#! /usr/bin/perl -w use strict; my $num_of_params; my $dna1; my $base1; $num_of_params = @ARGV; if ($num_of_params < 2) { die ("\n you havent entered enough parameters! \n"); } open (INFILE, $ARGV[0]) or die "unable to open file"; my @lines = <INFILE>; chomp @lines; $dna1 = join ('', @lines); $dna1 =~ s/\s//g; $dna1 =~ s/^>genome//; @lines = split ('', $dna1); my $count_of_A = 0; my $count_of_C = 0; my $count_of_G = 0; my $count_of_T = 0; my $errors = 0; foreach $base1 (@lines) { if (($base1 eq 'A') || ($base1 eq 'a')) { ++$count_of_A; } elsif (($base1 eq 'G') || ($base1 eq 'g')) { ++$count_of_G; } elsif (($base1 eq 'C') || ($base1 eq 'c')) { ++$count_of_C; } elsif (($base1 eq 'T') || ($base1 eq 't')) { ++$count_of_T; } else { print "There are errors in this DNA sequence. Please check that + your sequence contains only A C T and G\n"; ++$errors; } } print "\nThere are $count_of_A A's in this sequence\n\n"; print "There are $count_of_G G's in this sequence\n\n"; print "There are $count_of_T T's in this sequence\n\n"; print "There are $count_of_C C's in this sequence\n\n"; print "There are $errors errors in this sequence\n\n"; exit;
In reply to programs taking ages to exit by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |