コード例 #1
0
def am1_bcc_charges(mol, minsteps=None, wait=True):
    """ Doesn't work yet ..."""
    charge = utils.if_not_none(mol.charge, 0)

    engine = mdt.compute.get_engine()
    image = compute.get_image_path(IMAGE, engine)
    command = 'antechamber -fi pdb -i mol.pdb -fo mol2 -o out.mol2 -c bcc -an n'
    if charge != 0: command += ' -nc %d' % charge
    if minsteps is not None: command += ' -ek "maxcyc=%d"' % minsteps

    def parse_mol2(job):
        """Callback to complete the job"""
        atom_info = utils.DotDict(job=job)
        lines = iter(job.get_output('out.mol2').read().split('\n'))
        while True:
            line = lines.next()
            fields = line.split()
            if fields[0] == 'ATOM':
                idx = int(fields[1]) - 1
                name = fields[2]
                assert mol.atoms[idx].name == name
                atom_info[mol.atoms[idx]] = utils.DotDict(partialcharge=u.q_e *
                                                          float(fields[-2]),
                                                          atomtype=fields[-1])
        return atom_info

    job = engine.launch(image,
                        command=command,
                        name="am1-bcc, %s" % mol.name,
                        inputs={'mol.pdb': mol.write(format='pdb')},
                        when_finished=parse_mol2)
    uibase.display_log(job.get_display_object(), job.name)
    if not wait: return job()
    else: job.wait()
コード例 #2
0
def pull():
    from moldesign import compute
    streams = []
    for img in DOCKER_IMAGES:
        imgurl = compute.get_image_path(img)
        print 'Pulling %s' % imgurl
        streams.append(compute.get_engine().client.pull(imgurl))
    for s in streams:
        for line in s.split('\n'):
            print line
コード例 #3
0
def run_tleap(mol, forcefields=None, parameters=None, **kwargs):
    """
    Drives tleap to create a prmtop and inpcrd file. Specifically uses the AmberTools 16
    tleap distribution.

    Defaults are as recommended in the ambertools manual.

    Args:
        mol (moldesign.Molecule): Molecule to set up
        forcefields (List[str]): list of the names of forcefields to use
            (see AmberTools manual for descriptions)
        parameters (List[ExtraAmberParameters]): (optional) list of amber parameters
            for non-standard residues
        **kwargs: keyword arguments to :meth:`compute.run_job`

    References:
        Ambertools Manual, http://ambermd.org/doc12/Amber16.pdf. See page 33 for forcefield
        recommendations.
    """
    # Prepare input for tleap
    if forcefields is None:
        forcefields = mdt.forcefields.ffdefaults.values()
    leapstr = ['source %s' % LEAPRCFILES[ff] for ff in forcefields]
    inputs = {'input.pdb': mol.write(format='pdb')}

    if parameters:
        if hasattr(parameters, 'lib') or hasattr(parameters, 'frcmod'):
            parameters = [parameters]
        for ipmtr, p in enumerate(parameters):
            frcname = 'res%d.frcmod' % ipmtr
            libname = 'res%d.lib' % ipmtr
            inputs[frcname] = p.frcmod
            inputs[libname] = p.lib
            leapstr.append('loadAmberParams %s' % frcname)
            leapstr.append('loadoff %s' % libname)

    leapstr.append('mol = loadpdb input.pdb\n'
                   "check mol\n"
                   "saveamberparm mol output.prmtop output.inpcrd\n"
                   "savepdb mol output.pdb\n"
                   "quit\n")

    inputs['input.leap'] = '\n'.join(leapstr)

    job = pyccc.Job(image=compute.get_image_path(IMAGE),
                    command='tleap -f input.leap',
                    inputs=inputs,
                    name="tleap, %s" % mol.name)

    return compute.run_job(job, **kwargs)
コード例 #4
0
def run_tleap(mol, forcefields=None, parameters=None, **kwargs):
    """
    Drives tleap to create a prmtop and inpcrd file. Specifically uses the AmberTools 16
    tleap distribution.

    Defaults are as recommended in the ambertools manual.

    Args:
        mol (moldesign.Molecule): Molecule to set up
        forcefields (List[str]): list of the names of forcefields to use
            (see AmberTools manual for descriptions)
        parameters (List[ExtraAmberParameters]): (optional) list of amber parameters
            for non-standard residues
        **kwargs: keyword arguments to :meth:`compute.run_job`

    References:
        Ambertools Manual, http://ambermd.org/doc12/Amber16.pdf. See page 33 for forcefield
        recommendations.
    """
    # Prepare input for tleap
    if forcefields is None:
        forcefields = mdt.forcefields.ffdefaults.values()
    leapstr = ['source %s' % LEAPRCFILES[ff] for ff in forcefields]
    inputs = {'input.pdb': mol.write(format='pdb')}

    if parameters:
        if hasattr(parameters, 'lib') or hasattr(parameters, 'frcmod'):
            parameters = [parameters]
        for ipmtr, p in enumerate(parameters):
            frcname = 'res%d.frcmod' % ipmtr
            libname = 'res%d.lib' % ipmtr
            inputs[frcname] = p.frcmod
            inputs[libname] = p.lib
            leapstr.append('loadAmberParams %s' % frcname)
            leapstr.append('loadoff %s' % libname)

    leapstr.append('mol = loadpdb input.pdb\n'
                   "check mol\n"
                   "saveamberparm mol output.prmtop output.inpcrd\n"
                   "savepdb mol output.pdb\n"
                   "quit\n")

    inputs['input.leap'] = '\n'.join(leapstr)

    job = pyccc.Job(image=compute.get_image_path(IMAGE),
                    command='tleap -f input.leap',
                    inputs=inputs,
                    name="tleap, %s" % mol.name)

    return compute.run_job(job, **kwargs)
コード例 #5
0
def init_config():
    """Called at the end of package import to read initial configuration and setup cloud computing.
    """
    config.update(CONFIG_DEFAULTS)

    path = _get_config_path()

    if os.path.exists(path):
        with open(path, 'r') as infile:
            print 'Reading configuration from %s' % path
            config.update(yaml.load(infile))

    if config.default_python_image is None:
        config.default_python_image = compute.get_image_path('moldesign_complete')
コード例 #6
0
def init_config():
    """Called at the end of package import to read initial configuration and setup cloud computing.
    """
    config.update(CONFIG_DEFAULTS)

    path = _get_config_path()

    if os.path.exists(path):
        with open(path, 'r') as infile:
            print 'Reading configuration from %s' % path
            config.update(yaml.load(infile))

    if config.default_python_image is None:
        config.default_python_image = compute.get_image_path(
            'moldesign_complete')
コード例 #7
0
    def calculate(self, requests=None, guess=None, wait=True):
        inputfile = [
            'SQM input for %s' % self.mol.name, ' &qmmm',
            " qm_theory='%s' qmcharge=%d, printcharges=1, maxcyc=0" %
            (self.params.theory, self.get_formal_charge()), '/'
        ]
        for atom in self.mol.atoms:
            inputfile.append(
                ' {atom.atnum}  {atom.name}  {pos[0]:.8f} {pos[1]:.8f} {pos[2]:.8f}'
                .format(atom=atom, pos=atom.position.value_in(u.angstrom)))

        engine = mdt.compute.get_engine()
        image = compute.get_image_path(IMAGE)
        job = engine.launch(image,
                            'sqm -i mol.in -o mol.out',
                            inputs={'mol.in': '\n'.join(inputfile)},
                            name="sqm single point, %s" % self.mol.name)
        if not wait: return job

        else: return self._parse_results(job)
コード例 #8
0
def run_tleap(mol,
              protein='ff14SB',
              dna='OL15',
              rna='OL3',
              carbohydrate='GLYCAM_06j-1',
              lipid='lipid14',
              water='tip3p',
              organic='gaff2',
              off_files=(),
              frcmod_files=(),
              **kwargs):
    """
    Drives tleap to create a prmtop and inpcrd file. Specifically uses the AmberTools 16
    tleap distribution.

    Defaults are as recommended in the ambertools manual.

    Args:
        mol (moldesign.Molecule): Molecule to set up
        protein (str): protein forcefield name (default:ff14SB)
        dna (str): dna forcefield name (default: OL15)
        rna (str): rna forcefield name (default: OL3)
        carbohydrate (str): carbohydrate forcefield name (default: GLYCAM_06j)
        lipid (str): lipid forcefield name (default: lipid14)
        water (str): water forcefield name (default: tip3p)
        organic (str): organic forcefield name (default: gaff2)
        off_files (List[batch.FileContainer]):
        frcmod_files (List[batch.FileContainer]):
        **kwargs: keyword arguments to :meth:`compute.run_job`

    References:
        Ambertools Manual, http://ambermd.org/doc12/Amber16.pdf. See page 33 for forcefield
        recommendations.
    """
    # Prepare input for tleap
    leapstr = [
        'source %s' % LEAPRCFILES[ff]
        for ff in (protein, dna, rna, carbohydrate, lipid, water, organic)
    ]

    for frcmod in frcmod_files:
        fname = frcmod.dumphere()
        leapstr.append('loadamberparam %s' % fname)
    for off in off_files:
        fname = off.dumphere()
        leapstr.append('loadoff %s' % fname)
    leapstr.append('mol = loadpdb input.pdb\n'
                   "check mol\n"
                   "saveamberparm mol output.prmtop output.inpcrd\n"
                   "quit\n")

    # Launch the job
    inputs = {
        'input.pdb': mol.write(format='pdb'),
        'input.leap': '\n'.join(leapstr)
    }

    job = pyccc.Job(image=compute.get_image_path(IMAGE),
                    command='tleap -f input.leap',
                    inputs=inputs,
                    name="tleap, %s" % mol.name)

    return compute.run_job(job, **kwargs)