rev_seq.pl 371 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/perl -w
  2. #
  3. #AUthor: Ruan Jue
  4. #
  5. use strict;
  6. my $seq = shift;
  7. if($seq){
  8. rev_seq($seq);
  9. } else {
  10. $seq = '';
  11. while(<>){
  12. if(/^>/){
  13. &rev_seq($seq);
  14. print; next;
  15. $seq = '';
  16. }
  17. chomp;
  18. $seq .= $_;
  19. }
  20. &rev_seq($seq);
  21. }
  22. 1;
  23. sub rev_seq {
  24. my $s = shift;
  25. $s =~tr/ACGTacgt/TGCAtgca/;
  26. $s = reverse $s;
  27. while($s=~/(.{1,100})/g){
  28. print "$1\n";
  29. }
  30. }