2 # $Id: multi_hmmsearch.PLS,v 1.3 2006-07-04 22:23:36 mauricio Exp $
8 multi_hmmsearch - perform a hmmsearch into multiple FASTA files using
13 multi_hmmsearch -p hmm_file [-i] -f index_file
17 Not technically a Bio::Tools::Run script as this doesn't use any
18 Bioperl or Bioperl-run components but it's useful.
20 =head2 Mandatory Options:
22 -p HMM profile to use for the search.
23 -f INDEX file that contains a list of FASTA files for the multiple
26 =head2 Special Options:
28 -i Create a new index file with the resulting hmms files. This is
29 useful if you want to pass this list as input arguments into
31 -h Show this documentation.
37 User feedback is an integral part of the evolution of this and other
38 Bioperl modules. Send your comments and suggestions preferably to the
39 Bioperl mailing list. Your participation is much appreciated.
41 bioperl-l@bioperl.org - General discussion
42 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
46 Report bugs to the Bioperl bug tracking system to help us keep track
47 of the bugs and their resolution. Bug reports can be submitted via the
50 http://redmine.open-bio.org/projects/bioperl/
54 Mauricio Herrera Cuadra <mauricio-at-open-bio.org>
58 # Modules, pragmas and variables to use
60 use vars
qw($opt_p $opt_i $opt_f $opt_h $index_file);
62 # Gets options from the command line
63 GetOptions qw(-p=s -i -f=s -h);
65 # Print documentation if help switch was given
66 exec('perldoc', $0) and exit() if $opt_h;
68 # If no mandatory options are given prints an error and exits
70 print "ERROR: No HMM profile has been specified.\n Use '-h' switch
71 for documentation.\n" and exit();
73 print "ERROR: No INDEX file has been specified.\n Use '-h' switch for
74 documentation.\n" and exit();
77 # Locates hmmsearch in the filesystem
78 my $hmmsearch = `which hmmsearch`;
81 # Creates a directory for writing the resulting files
82 mkdir("multi", 0755) unless -e
"multi" and -d
"multi";
84 # Creates a new INDEX file if the option was given
87 $prefix =~ s/\.INDEX$//;
88 $index_file = "$prefix.hmms.INDEX";
89 open(HMMSINDEX
, ">", $index_file) or die("Unable to create file:
93 # Opens the INDEX file sent as input
94 open(FH
, "<", $opt_f) or die("Unable to open INDEX file: $opt_f ($!)");
95 print "==> Opening INDEX file:\t\t\t\t$opt_f\n";
96 print "==> HMM profile file is:\t\t\t$opt_p\n";
98 # Cycle that extracts one line for every loop until finding the end of
100 while (my $line = <FH
>) {
102 # Deletes the new line characters from the line
105 # Gets the name for the result file
107 $out =~ s/^split\///;
110 # Performs the hmmsearch for the FASTA file in turn
111 print "--> Performing hmmsearch in file:\t\t$line\n";
112 system("$hmmsearch $opt_p $line > multi/$out.hmms");
113 print "==> hmmsearch results stored in file:\t\tmulti/$out.hmms\n";
115 # Prints the result file name into the new INDEX file if the
117 print HMMSINDEX
"multi/$out.hmms\n" if $opt_i;
123 print "==> New INDEX stored in file:\t\t\t$index_file\n";