1 #!/usr/local/bin/ruby -w
5 # Copyright:: Copyright (C) 2006-2008 Christian M. Zmasek
6 # License:: GNU Lesser General Public License (LGPL)
8 # $Id: hmm_split.rb,v 1.5 2008/11/17 22:32:43 cmzmasek Exp $
10 # To split a Pfam HMM file into one file for each HMM.
14 module ForesterScripts
16 if RUBY_VERSION !~ /1.9/
17 puts( "Your ruby version is #{RUBY_VERSION}, expected 1.9.x " )
22 if ( ARGV == nil || ARGV.length != 3 )
23 puts( "usage: hmm_split.rb <Pfam HMM file> <outfile suffix> <outdir>" )
31 if ( !File.exists?( outdir ) )
32 puts( "outdir [" + outdir + "] does not exist" )
35 if ( !File.exists?( hmmfile ) )
36 puts( "Pfam HMM file [" + hmmfile + "] does not exist" )
45 File.open( hmmfile ) do | file |
46 while line = file.gets
49 if ( line =~ /NAME\s+(.+)/ )
51 puts( "Pfam HMM file [" + hmmfile + "] format error [line: " + line + "]" )
55 elsif ( line =~ /\/\// )
57 puts( "Pfam HMM file [" + hmmfile + "] format error [line: " + line + "]" )
61 outfile = outdir + '/' + name + suffix
62 if ( File.exists?( outfile ) )
63 puts( "file [" + outfile + "] already exists" )
66 open( outfile, 'w' ) do | out |
70 puts( count.to_s + ": " + name )
78 puts( "wrote " + count.to_s + " individual HMM files to " + outdir )