[Bio] / FigKernelPackages / SeedUtils.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/SeedUtils.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Thu Jun 18 01:28:57 2009 UTC revision 1.2, Tue Jun 30 20:11:54 2009 UTC
# Line 23  Line 23 
23      use Tracer;      use Tracer;
24      use base qw(Exporter);      use base qw(Exporter);
25    
26      our @EXPORT = qw(create_fasta_record);      our @EXPORT = qw(create_fasta_record rev_comp);
27    
28  =head1 SEED Utility Methods  =head1 SEED Utility Methods
29    
# Line 92  Line 92 
92      return $retVal;      return $retVal;
93  }  }
94    
95    =head3 rev_comp
96    
97        my $revcmp = rev_comp($dna);
98    
99    or
100    
101        rev_comp(\$dna);
102    
103    Return the reverse complement of a DNA string.
104    
105    =over 4
106    
107    =item dna
108    
109    Either a DNA string, or a reference to a DNA string.
110    
111    =item RETURN
112    
113    If the input is a DNA string, returns the reverse complement. If the
114    input is a reference to a DNA string, the string itself is reverse
115    complemented.
116    
117    =back
118    
119    =cut
120    
121    sub rev_comp {
122        # Get the parameters.
123        my ($dna) = @_;
124        # Determine how we were called.
125        my ($retVal, $refMode);
126        if (ref $dna eq 'SCALAR') {
127            $retVal = lc reverse $dna;
128            $refMode = 0;
129        } else {
130            $retVal = lc reverse $$dna;
131            $refMode = 1;
132        }
133        # Now $retVal contains the reversed DNA string in all lower case, and
134        # $refMode is TRUE iff the user passed in a reference. The following
135        # translation step complements the string.
136        $retVal =~ tr/acgtumrwsykbdhv/tgcaakywsrmvhdb/;
137        # Return the result in the method corresponding to the way it came in.
138        if ($refMode) {
139            $$dna = $retVal;
140            return;
141        } else {
142            return $retVal;
143        }
144    }
145    
146    
147  1;  1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3