Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #!/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. local $/ = "\r\n";
  6.  
  7. my @frames = (1, 2, 3, -1, -2, -3 ); #six frames;
  8. foreach my $frame (@frames) {
  9. frame ($frame);
  10.  
  11. sub frame
  12. {
  13. my $f = shift;
  14. open IN, $ARGV[0];
  15.  
  16. while (<IN>){
  17. chomp; #each sequence should be in single line;
  18. my $m = length ($_);
  19.  
  20. if(/^>(\w+)/){
  21. print ">$1"."_"."frame"."$f"."\n";
  22. }elsif($f > 0){
  23. my $frameseq = substr($_, $f-1, $m-$f+1);
  24. print "$frameseq\n";
  25. }elsif ($f <0){
  26. my $comprevseq = reverse $_;
  27. $comprevseq =~ tr/[A,T,C,G,a,t,c,g]/[T,A,G,C,t,a,g,c]/; # sequence reverse complement;
  28. my $frameseq = substr ($comprevseq, abs($f)-1, $m-abs($f)+1);
  29.  
  30. print "$frameseq\n";
  31. }
  32. }
  33. }
  34. close IN;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement