split_seqs_3.pl 342 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/perl -w
  2. #
  3. #
  4. use strict;
  5. my $cnt = shift or die("Usage: $0 <parts> <index> <fasta_file>\n");
  6. my $idx = shift or die("Usage: $0 <parts> <index> <fasta_file>\n");
  7. $idx --;
  8. my $ns = 0;
  9. my $print = 0;
  10. while(<>){
  11. if(/^>/){
  12. if($ns % $cnt == $idx){
  13. $print = 1;
  14. } else {
  15. $print = 0;
  16. }
  17. $ns ++;
  18. }
  19. print if($print);
  20. }
  21. 1;