Exemplo n.º 1
0
 def get_filename_for_atomic2_input(self, molecule, bond_topology_idx):
     """Returns the expected filename for an atomic input."""
     if bond_topology_idx:
         return '{}.{:06d}.{:03d}.{:02d}.inp'.format(
             smu_utils_lib.get_composition(
                 molecule.bond_topologies[bond_topology_idx]),
             molecule.molecule_id // 1000, molecule.molecule_id % 1000,
             bond_topology_idx)
     else:
         return '{}.{:06d}.{:03d}.inp'.format(
             smu_utils_lib.get_composition(
                 molecule.bond_topologies[bond_topology_idx]),
             molecule.molecule_id // 1000, molecule.molecule_id % 1000)
Exemplo n.º 2
0
    def process_stage1_proto(self, conformer):
        """Return the contents of conformer as a string in SMU7 stage1 file format.

    This is for the stage1 format, which just contains the results of geometry
    optimization

    Args:
      conformer: dataset_pb2.Conformer

    Returns:
      A string representation of the protocol buffer in Uni Basel's file format.
    """
        contents = []

        identifier = smu_utils_lib.get_composition(
            conformer.bond_topologies[0])
        properties = conformer.properties
        contents.append(self.get_stage1_header(conformer, identifier))
        contents.append(
            self.get_adjacency_code_and_hydrogens(
                conformer.bond_topologies[0]))
        contents.append(self.get_ids(conformer, identifier, 'stage1'))
        contents.append(self.get_system(properties))
        contents.append(self.get_stage1_timings(properties))
        contents.append(self.get_gradient_norms(properties, spacer=' '))
        contents.append(
            self.get_coordinates(conformer.bond_topologies[0], conformer))
        contents.append(
            self.get_frequencies_and_intensities(properties, header=False))

        return ''.join(contents)
Exemplo n.º 3
0
 def test_simple(self):
     bt = dataset_pb2.BondTopology()
     bt.atoms.extend([
         dataset_pb2.BondTopology.ATOM_C, dataset_pb2.BondTopology.ATOM_C,
         dataset_pb2.BondTopology.ATOM_N, dataset_pb2.BondTopology.ATOM_H,
         dataset_pb2.BondTopology.ATOM_H, dataset_pb2.BondTopology.ATOM_H
     ])
     self.assertEqual('x03_c2nh3', smu_utils_lib.get_composition(bt))
Exemplo n.º 4
0
    def process_stage2_proto(self, conformer):
        """Return the contents of conformer as a string in SMU7 stage2 file format.

    This is for the stage2 format which is at the end of the pipeline.

    Args:
      conformer: dataset_pb2.Conformer

    Returns:
      A string representation of the protocol buffer in Uni Basel's file format.
    """
        contents = []

        identifier = smu_utils_lib.get_composition(
            conformer.bond_topologies[0])
        properties = conformer.properties
        contents.append(self.get_stage2_header(conformer, identifier))
        contents.append(self.get_database(conformer))
        contents.append(self.get_error_codes(properties))
        contents.append(
            self.get_adjacency_code_and_hydrogens(
                conformer.bond_topologies[0]))
        contents.append(self.get_ids(conformer, identifier, 'stage2'))
        contents.append(self.get_system(properties))
        contents.append(self.get_stage2_timings(properties))
        contents.append(
            self.get_bonds(conformer.bond_topologies[0], properties))
        contents.append(self.get_gradient_norms(properties,
                                                spacer='         '))
        contents.append(
            self.get_coordinates(conformer.bond_topologies[0], conformer))
        contents.append(self.get_rotational_constants(properties))
        contents.append(self.get_symmetry_used(properties))
        contents.append(
            self.get_frequencies_and_intensities(properties, header=True))
        contents.append(self.get_gaussian_sanity_check(properties))
        contents.append(self.get_normal_modes(properties))
        contents.append(self.get_properties(properties))
        contents.append(self.get_diagnostics(properties))
        contents.append(self.get_atomic_block(properties))
        contents.append(self.get_homo_lumo(properties))
        contents.append(
            self.get_excitation_energies_and_oscillations(properties))
        contents.append(
            self.get_nmr_isotropic_shieldings(conformer.bond_topologies[0],
                                              properties))
        contents.append(
            self.get_partial_charges(conformer.bond_topologies[0], properties))
        contents.append(self.get_polarizability(properties))
        contents.append(self.get_multipole_moments(properties))

        return ''.join(contents)
Exemplo n.º 5
0
    def process(self, conformer):
        """Creates the atomic input file for conformer."""
        contents = []
        contents.append(conformer.bond_topologies[0].smiles + '\n')
        contents.append('{}.{:06d}.{:03d}\n'.format(
            smu_utils_lib.get_composition(conformer.bond_topologies[0]),
            conformer.conformer_id // 1000, conformer.conformer_id % 1000))

        contents.extend(self.get_mol_block(conformer))
        contents.extend(self.get_energies(conformer))
        contents.extend(self.get_frequencies(conformer))
        contents.append('$end\n')

        return ''.join(contents)
Exemplo n.º 6
0
    def get_ids(self, molecule, stage, bt_idx):
        """Returns lines with identifiers.

    This include the smiles string, the file, and the ID line.
    We meed to know the stage because the SMU1 special cases are handled
    differently in the two stages.

    Args:
      molecule: dataset_pb2.Molecule
      stage: 'stage1' or 'stage2'
      bt_idx: bond topology index

    Returns:
      A multiline string representation of id lines.
    """
        result = ''
        if self.annotate:
            result += '# From smiles or properties.smiles_openbabel\n'
        if molecule.properties.HasField('smiles_openbabel'):
            result += molecule.properties.smiles_openbabel + '\n'
        else:
            result += molecule.bond_topologies[bt_idx].smiles + '\n'
        if self.annotate:
            result += '# From topology\n'
        result += smu_utils_lib.get_composition(
            molecule.bond_topologies[bt_idx]) + '\n'
        if self.annotate:
            result += '# From bond_topology_id, molecule_id\n'
        bond_topology_id = molecule.bond_topologies[bt_idx].bond_topology_id
        # Special case SMU1. Fun.
        if smu_utils_lib.special_case_dat_id_from_bt_id(bond_topology_id):
            if stage == 'stage1':
                bond_topology_id = 0
            elif stage == 'stage2':
                bond_topology_id = smu_utils_lib.special_case_dat_id_from_bt_id(
                    bond_topology_id)
            else:
                raise ValueError(f'Unknown stage {stage}')
        result += 'ID{:8d}{:8d}\n'.format(bond_topology_id,
                                          molecule.molecule_id % 1000)
        return result
Exemplo n.º 7
0
 def get_filename_for_atomic_input(self, conformer):
     """Returns the expected filename for an atomic input."""
     return '{}.{:06d}.{:03d}.inp'.format(
         smu_utils_lib.get_composition(conformer.bond_topologies[0]),
         conformer.conformer_id // 1000, conformer.conformer_id % 1000)