]> git.donarmstrong.com Git - biopieces.git/blobdiff - code_perl/Maasha/Seq.pm
added \r remove hack to genbank/embl parsers
[biopieces.git] / code_perl / Maasha / Seq.pm
index cfedd89b96e6cbc38d22b65e15b24d1fbca5d65c..4d6c7997665eb2ff19d4e2e44b6c035de841dbd4 100644 (file)
@@ -65,11 +65,11 @@ sub seq_guess_type
     }
 
     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";
     }
 }
 
@@ -914,26 +914,30 @@ sub seq_alph
 {
     # 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;
 }