If you are on a 32-bit system, you must use Math::BigInt.
Don't be foolish. :) Just don't use the stupid integer.pm module:
#!/usr/bin/perl
use strict;
use warnings;
# use integer;
my %iupac_dgn;
my @iupac_code=('M','R','W','S','Y','K','V','H','D','B','N');
my @iupac_den=('2','2','2','2','2','2','3','3','3','3','4');
@iupac_dgn{@iupac_code}=@iupac_den;
my $string = 'GGNMDNNSNNNNDBNVWVSMNNHYNBNG';
my @residues = split( //, $string );
my $degeneracy = 1;
foreach my $residues( @residues ) {
if( grep( m/^$residues$/, keys %iupac_dgn ) ) {
my $factor = $iupac_dgn{$residues};
$degeneracy = ($factor * $degeneracy);
}
}
printf "%28s, %30d", $string, $degeneracy;
__END__
GGNMDNNSNNNNDBNVWVSMNNHYNBNG, 2348273369088
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.