How to use the forcebalance.parser function in forcebalance

To help you get started, we’ve selected a few forcebalance examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leeping / forcebalance / test / test_objective.py View on Github external
def setUp(self):
        self.options=forcebalance.parser.gen_opts_defaults.copy()
        self.options.update({
                'root': os.getcwd() + '/test/files',
                'penalty_additive': 0.01,
                'jobtype': 'NEWTON',
                'forcefield': ['water.itp']})
        os.chdir(self.options['root'])
        
        self.logger.debug("\nUsing the following options:\n%s\n" % str(self.options))

        self.tgt_opts = [ forcebalance.parser.tgt_opts_defaults.copy() ]
        self.tgt_opts[0].update({"type" : "ABINITIO_GMX", "name" : "cluster-06"})
        self.ff = forcebalance.forcefield.FF(self.options)
        
        self.objective = forcebalance.objective.Objective(self.options, self.tgt_opts,self.ff)
github leeping / forcebalance / test / test_target.py View on Github external
def setUp(self):
        self.logger.debug("\nBuilding options for target...\n")
        self.options=forcebalance.parser.gen_opts_defaults.copy()
        self.tgt_opt=forcebalance.parser.tgt_opts_defaults.copy()
        self.ff = None  # Forcefield this target is fitting
        self.options.update({'root': os.getcwd() + '/test/files'})

        os.chdir(self.options['root'])
github leeping / forcebalance / test / test_forcefield.py View on Github external
def setUp(self):
        # options used in 001_water_tutorial
        self.logger.debug("\nSetting up options...\n")
        self.options=forcebalance.parser.gen_opts_defaults.copy()
        self.options.update({
                'root': os.getcwd() + '/test/files',
                'penalty_additive': 0.01,
                'jobtype': 'NEWTON',
                'forcefield': ['water.itp']})
        self.logger.debug(str(self.options) + '\n')
        os.chdir(self.options['root'])
        self.logger.debug("Creating forcefield using above options... ")
        self.ff = forcefield.FF(self.options)
        self.ffname = self.options['forcefield'][0][:-3]
        self.filetype = self.options['forcefield'][0][-3:]
        self.logger.debug("ok\n")
github leeping / forcebalance / test / test_parser.py View on Github external
def test_parse_inputs_returns_tuple(self):
        """Check parse_inputs() returns type"""
        output = forcebalance.parser.parse_inputs('test/files/very_simple.in')
        self.assertEqual(type(output), tuple,
        msg = "\nExpected parse_inputs() to return a tuple, but got a %s instead" % type(output).__name__)
        self.assertEqual(type(output[0]), dict,
        msg = "\nExpected parse_inputs()[0] to be an options dictionary, got a %s instead" % type(output).__name__)
        self.assertEqual(type(output[1]), list,
        msg = "\nExpected parse_inputs()[1] to be a target list, got a %s instead" % type(output[1]).__name__)
        self.assertEqual(type(output[1][0]), dict,
        msg = "\nExpected parse_inputs()[1][0] to be a target dictionary, got a %s instead" % type(output[1]).__name__)
github leeping / forcebalance / ForceBalanceGUI.py View on Github external
def open(self):
        filters = [('Forcebalance input files', '*.in'),('Show all', '*')]
        inputfile = tkfile.askopenfilename(title="Open ForceBalance input file...", filetypes=filters)

        if inputfile=='': return

        cwd=os.getcwd()
        os.chdir(os.path.dirname(inputfile))
        opts, tgt_opts = forcebalance.parser.parse_inputs(inputfile)

        self.objectsPane.add(OptionObject(opts, os.path.split(inputfile)[1]))
        for target in tgt_opts:
            self.objectsPane.add(TargetObject(target))
        self.objectsPane.add(ForcefieldObject(opts))
        self.objectsPane.update()
        
        os.chdir(cwd)
github leeping / forcebalance / src / gui / objects.py View on Github external
def __init__(self, filename=None):
        super(CalculationObject,self).__init__(type='calculation')
        self.properties['options']=[]
        self.properties['targets']=[]
        self.properties['forcefield']=None
        self.properties['result']=None

        self.properties['_expand']=True
        self.properties['_expand_targets']=True

        cwd=os.getcwd()
        os.chdir(os.path.dirname(filename))

        self.opts, self.tgt_opts = forcebalance.parser.parse_inputs(filename)
        self.properties['options'] = OptionObject(self.opts, os.path.basename(filename))

        self.properties['name'] = self.properties['options']['name']

        for target in self.tgt_opts:
            self.properties['targets'].append(TargetObject(target))

        if filename:
            self.properties['forcefield'] = ForcefieldObject(self.opts)

        os.chdir(cwd)
github leeping / forcebalance / ForceBalanceGUI.py View on Github external
def display(self, verbose=0):
        s=''
        default_keys=[]
        for key in self.opts.iterkeys():
            if key not in forcebalance.parser.tgt_opts_defaults.keys() or self.opts[key] != forcebalance.parser.tgt_opts_defaults[key]:
                s+= "%s : %s\n" % (key, str(self.opts[key]))
            else: default_keys.append(key)
        if verbose:
            s+= "\n--- options remaining at default ---\n"
            for default_key in default_keys:
                s+= "%s : %s\n" % (default_key, str(self.opts[default_key]))
        
        return s
github leeping / forcebalance / ForceBalanceGUI.py View on Github external
def __init__(self, opts=None, name="unknown options file"):
        super(OptionObject,self).__init__()

        if not opts: self.opts = forcebalance.parser.gen_opts_defaults
        else: self.opts = opts

        self.properties['name'] = name
github leeping / forcebalance / src / gui / objects.py View on Github external
def isDefault(self, option):
        return option in forcebalance.parser.gen_opts_defaults.keys() and self.opts[option] == forcebalance.parser.gen_opts_defaults[option]