#!/usr/local/bin/env python

#=============================================================================================
# MODULE DOCSTRING
#=============================================================================================

"""
Structural modelling algorithms.

DESCRIPTION

This module provides a basic facility for modelling systems based on incomplete structural
biology experimental data or comparative models.  While not intended to fully replace specialized
tools such as MODELLER [1], it will allow rapid import of systems into OpenMM.

REFERENCES

[1] MODELLER: http://salilab.org/modeller

COPYRIGHT AND LICENSE

@author John D. Chodera <jchodera@gmail.com>

All code in this repository is released under the GNU General Public License.

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License along with
this program.  If not, see <http://www.gnu.org/licenses/>.

"""

#=============================================================================================
# GLOBAL IMPORTS
#=============================================================================================

import os
import math
import numpy
import copy
import time

import simtk
import simtk.chem.openmm as openmm
import simtk.unit as units

import Scientific.IO.NetCDF as netcdf
#import tables

#=============================================================================================
# REVISION CONTROL
#=============================================================================================

__version__ = "$Revision$" 

#=============================================================================================
# MODULE CONSTANTS
#=============================================================================================

#=============================================================================================
# Exceptions
#=============================================================================================

class NotImplementedException(Exception):
    """
    Exception denoting that the requested feature has not yet been implemented.

    """

class ParameterException(Exception):
    """
    Exception denoting that a parameter has been incorrectly furnished.

    """

#=============================================================================================
# Modeller
#=============================================================================================

class Modeller(object):
    """

    EXAMPLES

    >>> target_sequence = Modeller.LoadSequenceFromPIR(...)
    >>> modeller = Modeller(target_sequence)
    >>> modeller.addTemplate(....)
    >>> model = modeller.generateModel()
    
    """
    
    def __init__(self, target_sequence):
        """
        Initialize a Modeller object.

        ARGUMENTS

        target_sequence - the sequence to be modeled

        NOTES

        A copy of the System object and an OpenMM Context object will be created and held until this class is destroyed.

        """

        # Create a copy of the system to be minimized.
        self.system = copy.deepcopy(system)

        # Initialize an integrator with arbitrary parameters.
        temperature = 1.0 * units.kelvin
        collision_rate = 90.0 / units.picosecond
        timestep = 1.0 * units.femtosecond
        self.integrator = openmm.LangevinIntegrator(temperature, collision_rate, timestep)

        # Create an OpenMM Context.
        self.context = Context(self.system, integrator)
        
        return


    # Notes on implementation:
    
#=============================================================================================
# MAIN AND TESTS
#=============================================================================================

if __name__ == "__main__":
    import doctest
    doctest.testmod()
