#!/usr/bin/env ccp4-python
#
#     Copyright (C) 2014 Ronan Keegan 
#
#     This code is distributed under the terms and conditions of the
#     CCP4 Program Suite Licence Agreement as a CCP4 Application.
#     A copy of the CCP4 licence can be obtained by writing to the
#     CCP4 Secretary, Daresbury Laboratory, Warrington WA4 4AD, UK.
#
# Class for storing useful utility stuff for MrBUMP
#
# Ronan Keegan 24/02/2014

import sys, os, string
import shutil

class Utils:

   def __init__(self):
      self.name=""

   def which(self, program):
      def is_exe(fpath):
          return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
   
      fpath, fname = os.path.split(program)
      if fpath:
          if is_exe(program):
              return program
      else:
          for path in os.environ["PATH"].split(os.pathsep):
              exe_file = os.path.join(path, program)
              if is_exe(exe_file):
                  return exe_file
  
      return None

if __name__ == "__main__":

   u=Utils()
   print u.which("molrep")
