If you are on a 32-bit system, you must use Math::BigInt. The following returns 2348273369088.
#!/usr/bin/perl
use strict;
use warnings;
use integer;
use Math::BigInt;
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 = Math::BigInt->new( 1 );
foreach my $residues(@residues){
$degeneracy *= $iupac_dgn{$residues} || 1;
}
printf "%28s, %30s\n", $string, $degeneracy;
Update: I will concur with Tye as long as the result is less than 2 ** 49 on a 32b machine/implementation. Thanks.
Good Luck. -c
-
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.