#!/usr/bin/env ruby

class ParamsReader
  def initialize
  end
public
	def ParamsReader.read_params_file(params_file)
		params = {}
		File.open(params_file, "r").each do |l|
			if(l[0..0] != "#")
				arr = l.strip.split("=")
	#			print "len = ", arr.length, "\n"
				if(arr.length > 0 and arr.length != 2)
					print "ERROR reading input parameters: onlysingle key-value pair is allowed  per line!\n"
					exit
				end
				if(arr != nil and arr.length>0)
					key=arr[0]
					val=arr[1]
	#				print "key=#{key}, val=#{val}\n"
					params[key]=val
				end
			end
		end 
		return params
	end
end




# SAMPLE usage:
###############
#params_file="/nfs/labs/compbio/sgeorg/motif_analysis/PARalyzer_clusters/Tuschl_kde_5deep/preprocessing_PAR_CLIP.params"
#params = ParamsReader.read_params_file(params_file)
#print params.inspect,"\n"
