}
if ( $count = $check_seq =~ tr/FLPQIEflpqie// and $count > 0 ) {
- return "protein";
+ return "PROTEIN";
} elsif ( $count = $check_seq =~ tr/Uu// and $count > 0 ) {
- return "rna";
+ return "RNA";
} else {
- return "dna";
+ return "DNA";
}
}
{
# Martin A. Hansen, May 2007.
- # returns a requested alphabet
+ # Returns a requested sequence alphabet.
my ( $type, # alphabet type
) = @_;
# returns list
- my ( @alph );
+ my ( %alph_hash, $alph );
- if ( $type =~ /^dna$/i ) {
- @alph = qw( A T C G );
- } elsif ( $type =~ /^rna$/i ) {
- @alph = qw( A U C G );
- } elsif ( $type =~ /^prot/i ) {
- @alph = qw( F L S Y C W P H Q R I M T N K V A D E G );
+ %alph_hash = (
+ DNA => [ qw(A T C G) ],
+ DNA_AMBI => [ qw(A G C U T R Y W S M K H D V B N) ],
+ RNA => [ qw(A U C G) ],
+ RNA_AMBI => [ qw(A G C U T R Y W S M K H D V B N) ],
+ PROTEIN => [ qw(F L S Y C W P H Q R I M T N K V A D E G) ],
+ );
+
+ if ( exists $alph_hash{ uc $type } ) {
+ $alph = $alph_hash{ uc $type };
} else {
die qq(ERROR: Unknown alphabet type: "$type"\n);
}
- return wantarray ? @alph : \@alph;
+ return wantarray ? @{ $alph } : $alph;
}