def convert_str(str_data, in_format, out_format):
    mol = Molecule()
    conv = FileFormatManager()
    opts = {}
    opts['perceiveBonds'] = False
    conv.read_string(mol, str_data, in_format, json.dumps(opts))

    return conv.write_string(mol, out_format)
Exemple #2
0
 def read(self):
     str_data = self._file.read()
     mol = Molecule()
     conv = FileFormatManager()
     conv.read_string(mol, str_data, 'json')
     cjson_str = conv.write_string(mol, 'cjson')
     cjson = json.loads(cjson_str)
     return cjson
def molecule_properties(str_data, in_format):
    mol = Molecule()
    conv = FileFormatManager()
    conv.read_string(mol, str_data, in_format)
    properties = {
        'atomCount': mol.atom_count(),
        'heavyAtomCount': mol.atom_count() - mol.atom_count(1),
        'mass': mol.mass(),
        'spacedFormula': mol.formula(' ', 0),
        'formula': mol.formula('', 1)
        }
    return properties
Exemple #4
0
 def read(self):
     str_data = self._file.read()
     mol = Molecule()
     conv = FileFormatManager()
     conv.read_string(mol, str_data, 'json')
     cjson_str = conv.write_string(mol, 'cjson')
     cjson = json.loads(cjson_str)
     # Copy some calculated properties
     data = json.loads(str_data)
     energy = parse(
         'simulation.calculations[0].calculationResults.totalEnergy.value'
     ).find(data)
     if len(energy) == 1:
         energy = energy[0].value
         cjson.setdefault('properties',
                          {})['totalEnergy'] = energy * HARTREE_TO_J_MOL
     return cjson
def calculate_mo(cjson, mo):
    mol = Molecule()
    conv = FileFormatManager()
    conv.read_string(mol, json.dumps(cjson), 'cjson')
    # Do some scaling of our spacing based on the size of the molecule.
    atom_count = mol.atom_count()
    spacing = 0.30
    if atom_count > 50:
        spacing = 0.5
    elif atom_count > 30:
        spacing = 0.4
    elif atom_count > 10:
        spacing = 0.33
    cube = mol.add_cube()
    # Hard wiring spacing/padding for now, this could be exposed in future too.
    cube.set_limits(mol, spacing, 4)
    gaussian = GaussianSetTools(mol)
    gaussian.calculate_molecular_orbital(cube, mo)

    return conv.write_string(mol, "cjson")
Exemple #6
0
def convert_str(str_data, in_format, out_format):
    mol = Molecule()
    conv = FileFormatManager()
    conv.read_string(mol, str_data, in_format)
    return conv.write_string(mol, out_format)
Exemple #7
0
def avo_convert_str(str_data, in_format, out_format):
    mol = Molecule()
    conv = FileFormatManager()
    conv.read_string(mol, str_data, in_format)
    return conv.write_string(mol, out_format)
def atom_count(str_data, in_format):
    mol = Molecule()
    conv = FileFormatManager()
    conv.read_string(mol, str_data, in_format)

    return mol.atom_count()