Example #1
0
# Check to see if AMBERHOME is set.
if "AMBERHOME" in _environ:
    _amber_home = _environ.get("AMBERHOME")
else:
    _amber_home = None

# Check to see if GROMACS is installed.
import Sire.Base as _SireBase
from os import path as _path

# First, let the user tell us where to find GROMACS. This
# assumes that gromacs is installed in $GROMACSHOME/bin/gmx.
_gmx_exe = None
if "GROMACSHOME" in _environ:
    try:
        _gmx_exe = _SireBase.findExe("%s/bin/gmx" % _environ.get("GROMACSHOME")) \
                            .absoluteFilePath()
    except:
        try:
            _gmx_exe = _SireBase.findExe("%s/bin/gmx_mpi" % _environ.get("GROMACSHOME")) \
                                .absoluteFilePath()
        except:
            pass

if _gmx_exe is None:
    # The user has not told us where it is, so need to look in $PATH.
    try:
        _gmx_exe = _SireBase.findExe("gmx").absoluteFilePath()
    except:
        try:
            _gmx_exe = _SireBase.findExe("gmx_mpi").absoluteFilePath()
        except:
Example #2
0
from Sire import Maths as _SireMaths
from Sire import Mol as _SireMol
from Sire import Units as _SireUnits

from BioSimSpace import _isVerbose
from BioSimSpace._Exceptions import AlignmentError as _AlignmentError
from BioSimSpace._Exceptions import MissingSoftwareError as _MissingSoftwareError
from BioSimSpace._SireWrappers import Molecule as _Molecule

from BioSimSpace import IO as _IO
from BioSimSpace import Units as _Units
from BioSimSpace import _Utils as _Utils

# Try to find the FKCOMBU program from KCOMBU: http://strcomp.protein.osaka-u.ac.jp/kcombu
try:
    _fkcombu_exe = _SireBase.findExe("fkcombu").absoluteFilePath()
except:
    _fkcombu_exe = None


def matchAtoms(molecule0,
               molecule1,
               scoring_function="rmsd_align",
               matches=1,
               return_scores=False,
               prematch={},
               timeout=5 * _Units.Time.second,
               property_map0={},
               property_map1={}):
    """Find mappings between atom indices in molecule0 to those in molecule1.
       Molecules are aligned using a Maximum Common Substructure (MCS) search.
Example #3
0
def _find_md_package(system, protocol, gpu_support=False):
    """Find a molecular dynamics package on the system and return
       a handle to it as a MDPackage object.

       Parameters
       ----------

       system : :class:`System <BioSimSpace._SireWrappers.System>`
           The molecular system.

       protocol : :class:`Protocol <BioSimSpace.Protocol>`
           The simulation protocol.

       gpu_support : bool
           Whether to use package must have GPU support.

       Returns
       -------

       (package, exe) : (str, str)
           The name of the MD package and a path to its executable.
    """

    # The input has already been validated in the run method, so no need
    # to re-validate here.

    # Get the file format of the molecular system.
    fileformat = system.fileFormat()

    # Make sure that this format is supported.
    if not fileformat in _file_extensions:
        raise ValueError("Cannot find an MD package that supports format: %s" %
                         fileformat)
    else:
        packages = _file_extensions[fileformat]

    # Is this a free energy protocol.
    if type(protocol) is _Protocol.FreeEnergy:
        is_free_energy = True
    else:
        is_free_energy = False

    # Loop over each package that supports the file format.
    for package in packages:
        # If this is free energy protocol, then check that the package has support.
        if not is_free_energy or _free_energy[package]:
            # Check whether this package exists on the system and has the desired
            # GPU support.
            for exe, gpu in _md_packages[package].items():
                # If the user has requested GPU support make sure the package
                # supports it.
                if not gpu_support or gpu:
                    # AMBER
                    if package == "AMBER":
                        # Search AMBERHOME, if set.
                        if _amber_home is not None:
                            _exe = "%s/bin/%s" % (_amber_home, exe)
                            if _os.path.isfile(_exe):
                                return (package, _exe)
                        # Search system PATH.
                        else:
                            try:
                                exe = _SireBase.findExe(exe).absoluteFilePath()
                                return (package, exe)
                            except:
                                pass
                    # GROMACS
                    elif package == "GROMACS":
                        if _gmx_exe is not None:
                            return (package, _gmx_exe)
                    # SOMD
                    elif package == "SOMD":
                        return (package, _SireBase.getBinDir() + "/somd")
                    # Search system PATH.
                    else:
                        try:
                            exe = _SireBase.findExe(exe).absoluteFilePath()
                            return (package, exe)
                        except:
                            pass

    # If we get this far, then no package was found.
    raise _MissingSoftwareError("Couldn't find package to support format: %s" %
                                fileformat)