in reply to negative numbers when doing multiplications?
Things you can try: use bigint (see bigint), and use ordinary print instead of printf() for debugging.
Finally your hash access is unnecessary complicated - instead of the grep you can just access $iupac_dgn{$residues} directly.
The simplified code looks like this:
#!/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){ $degeneracy *= $iupac_dgn{$residues} || 1; } printf "%28s, %30s\n", $string, $degeneracy;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: negative numbers when doing multiplications?
by chuckbutler (Monsignor) on Mar 26, 2010 at 14:03 UTC | |
by tye (Sage) on Mar 26, 2010 at 20:46 UTC | |
by almut (Canon) on Mar 26, 2010 at 22:16 UTC | |
by ikegami (Patriarch) on Mar 26, 2010 at 22:34 UTC | |
by almut (Canon) on Mar 26, 2010 at 22:50 UTC | |
|