#!/usr/bin/env python

# setup the environment

import os, sys, string, time
import shutil
import urllib

# Test for environment variables

if not os.environ.has_key('CCP4'):
    raise RuntimeError, 'CCP4 not found'
if not os.environ.has_key('http_proxy'):
    print "http_proxy not specified in environemnt"

# Update the python path with the bmp folders
bmp = os.environ["CCP4"] + "/src/bmp" 
bmp_incl = bmp + "/include"
bmp_data = bmp + "/data"

# Set the envionment deubg flag and any python specific variables
os.environ['BMP_DEBUG'] = "False"
os.environ['BMP_CLUSTER'] = "False"
os.environ['PYTHONUNBUFFERED'] = "True"

sys.path.append(bmp_incl + '/dev')
sys.path.append(bmp_incl + '/file_info')
sys.path.append(bmp_incl + '/modelling')
sys.path.append(bmp_incl + '/mr')
sys.path.append(bmp_incl + '/output')
sys.path.append(bmp_incl + '/seq_align')
sys.path.append(bmp_incl + '/ccp4')
sys.path.append(bmp_incl + '/structures')
sys.path.append(bmp_incl + '/tools')
sys.path.append(bmp_incl + '/initialisation')

# Import the BMP classes
import BMP_initialise
import BMP_master

# Call the inialisation class
init=BMP_initialise.Initialise()

# Set the environment variables
init.setBMP(bmp)
init.setBMP_INCL(bmp_incl)
init.setBMP_DATA(bmp_data)

init.bmp_initialisation(sys.argv)

# Call the master script for doing a full search and Molecular Replacement
master=BMP_master.Master()
master.fast_search_MR(init)
