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

Diff of /FigKernelPackages/raelib.pm

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

revision 1.22, Sun Jul 10 22:48:23 2005 UTC revision 1.23, Mon Jul 11 21:25:03 2005 UTC
# Line 658  Line 658 
658   return ${$sims[0]}[1];   return ${$sims[0]}[1];
659  }  }
660    
661    
662    =head1 read_fasta
663    
664    Read a fasta format file and return a reference to a hash with the data. The key is the ID and the value is the sequence. If you supply the optional keep comments then the comments (anything after the first white space are returned as a sepaarte hash).
665    
666    Usage:
667    my $fasta=$raelib->read_fasta($file);
668    my ($fasta, $comments)=$raelib->read_fasta($file, 1);
669    
670    =cut
671    
672    sub read_fasta {
673     my ($self, $file, $keepcomments)=@_;
674     open (IN, $file) || die "Can't open $file";
675     my %f; my $t; my $s; my %c;
676     while (<IN>) {
677      chomp;
678      if (/^>/) {
679       if ($s) {
680        $f{$t}=$s;
681        undef $s;
682       }
683       s/^>(\S+)\s*//;
684       $t=$1;
685       $c{$t}=$_ if ($_);
686      }
687      else {$s .= $_}
688     }
689     $f{$t}=$s;
690     if ($keepcomments) {return (\%f, \%c)}
691     else {return \%f}
692    }
693    
694    =head1 rc
695    
696    Reverse complement. It's too easy.
697    
698    =cut
699    
700    sub rc {
701     my ($self, $seq)=@_;
702     $seq=~tr/GATCgatc/CTAGctag/;
703     $seq = reverse $seq;
704     return $seq;
705    }
706    
707  1;  1;
708    

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3