Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Mar 22nd, 2010  |  syntax: Perl  |  size: 1.16 KB  |  hits: 75  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl -w
  2. #Divide the sequences file into segment sequence.
  3. #Usage: seq_seg.pl <sequences_file>
  4.  
  5. use warnings;
  6. use strict;
  7.  
  8. ####################
  9. #
  10. #Load Bio::SeqIO module for handling input/output of sequences and processing sequences.
  11. #
  12. ####################
  13. use Bio::SeqIO;
  14.  
  15. ####################
  16. #
  17. #Initializing variables.
  18. #
  19. ####################
  20. my $file = $ARGV[0];
  21. ####################
  22. #
  23. #Gain access to sequences file.
  24. #
  25. ####################
  26. my $seqIOobj = Bio::SeqIO->new(-file=>"$ARGV[0]");
  27. ####################
  28. #
  29. #The main part of the program.
  30. #
  31. ####################
  32. while((my $seqobj = $seqIOobj->next_seq()))
  33. {
  34.   ####################
  35.   #
  36.   #Acquire the induvidual sequence information by using Bio::SeqIO module.
  37.   #
  38.   ####################
  39.   my $seq = $seqobj->seq();
  40.   my $seq_id = $seqobj->primary_id();
  41.   open my $FILE_OUT, '>', "$seq_id";
  42.   ####################
  43.   #
  44.   #Change the default file handle to $FILE_OUT.
  45.   #
  46.   ####################
  47.   select $FILE_OUT;
  48.   ####################
  49.   #
  50.   #Print the last result to $FILE_OUT handle.
  51.   #
  52.   ####################
  53.   print ">$seq_id\n$seq\n";
  54.   close $FILE_OUT;
  55. }