How to use the moltemplate.force_fields.msi_frc_converter.msifrc2lt.InputError function in moltemplate

To help you get started, we’ve selected a few moltemplate 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 jewettaij / moltemplate / moltemplate / force_fields / msi_frc_converter / msifrc2lt.py View on Github external
sys.stdout.write("#\n"
                         "# WARNING: The following 1-2, 1-3, and 1-4 weighting parameters were ASSUMED:\n")
        sys.stdout.write("#          " + special_bonds_command + "\n")
        sys.stdout.write(
            "#          (See http://lammps.sandia.gov/doc/special_bonds.html for details)\n")

        #sys.stderr.write(' done.\n')
        
        if filename_in != '':
            file_in.close()




    except InputError as err:
        sys.stderr.write('\n\n' + str(err) + '\n')
        sys.exit(1)
github jewettaij / moltemplate / moltemplate / force_fields / msi_frc_converter / msifrc2lt.py View on Github external
elif tokens[i].lower() == 'mass':
                            icol_mass = i
                        elif tokens[i].lower() == 'element':
                            icol_elem = i
                        elif tokens[i].lower() == 'connections':
                            icol_nbonds = i
                        elif tokens[i].lower() == 'comment':
                            icol_comment = i
                        elif tokens[i].lower() == '!ver':   #(version of ff)
                            icol_ver = i
                        elif tokens[i].lower() == 'ref':
                            icol_ref = i
                    assert(icol_ver == 0)

                    if -1 in (icol_type, icol_mass):
                        raise InputError('Error: Invalid #atom_types section.\n'
                                         '       The meaning of each column cannot be determined.\n'
                                         '       This file needs a valid "!Ver..." comment.\n')
                    if icol_comment == -1:
                        icol_comment = max(icol_type, icol_mass,
                                           icol_elem, icol_nbonds) + 1

                    sys.stderr.write('icol_ver = '+str(icol_ver)+'\n')
                    sys.stderr.write('icol_ref = '+str(icol_ref)+'\n')
                    sys.stderr.write('icol_mass = '+str(icol_mass)+'\n')
                    sys.stderr.write('icol_nelem = '+str(icol_elem)+'\n')
                    sys.stderr.write('icol_nbonds = '+str(icol_nbonds)+'\n')
                    sys.stderr.write('icol_comment = '+str(icol_comment)+'\n')
                    continue

                tokens = map(RemoveOuterQuotes,
                             NSplitQuotedString(line.strip(),
github jewettaij / moltemplate / moltemplate / force_fields / msi_frc_converter / msifrc2lt.py View on Github external
if ((len(type_subset) == 0) or (tokens[1] in type_subset)):

                        atom2mass[tokens[icol_type]] = str(max(float(tokens[icol_mass]), 1.0e-06))
                        # Some atoms in cvff.prm have zero mass. Unfortunately this
                        # causes LAMMPS to crash, even if these atoms are never used,
                        # so I give the mass a non-zero value instead.

                        if icol_elem != -1:
                            atom2element[tokens[icol_type]] = tokens[icol_elem]
                        if icol_nbonds != -1:
                            atom2numbonds[tokens[icol_type]] = int(tokens[icol_nbonds])
                        atom2descr[tokens[icol_type]] = tokens[icol_comment]
                        atom2ver[tokens[icol_type]] = tokens[icol_ver]
                        atom2ref[tokens[icol_type]] = tokens[icol_ref]
                elif len(tokens) > 0:
                    raise InputError('Error: Invalid atom line: (line#'+str(iline)+')\n' +
                                     '\"'+line.strip()+'\"')

            elif (len(tokens) > 4) and (section_name == '#nonbond(12-6)'):
                if line.lstrip().find('!') == 0:
                    continue
                atom_name = tokens[2]
                pair2ver[atom_name] = tokens[0]
                pair2ref[atom_name] = tokens[1]
                A = float(tokens[3])
                B = float(tokens[4])
                epsilon = B*B/(4*A)
                sigma = pow(B/A, 1.0/6)
                if sigma == 0.0:
                    sigma = 1.0   #(non-zero to avoid nan error later)
                pair2style[atom_name] = 'lj/cut/long'
                pair_styles.add('lj/cut/long')
github jewettaij / moltemplate / moltemplate / force_fields / msi_frc_converter / msifrc2lt.py View on Github external
def DetermineAutoPriority(anames):
    #scan through list of strings anames, looking for patterns of the form
    #*n
    #where n is an integer.
    #(These patterns are used by MSI software when using "auto_equivalences"
    # to look up force field parameters for bonded interactions.)
    #Make sure this pattern only appears once and return n to the caller.
    n = None
    for i in range(0, len(anames)):
        if anames[:1] == '*':
            if n == None:
                n = int(anames[1:])
            elif n != int(anames[1:]):
                raise InputError('Error: Inconsistent priority integers in the following interaction:\n'
                                 '      ' + ' '.join(anames) + '\n')
    if n == None:
        return 0
    else:
        return n