Esempio n. 1
0
class HartreeMoleculeComparator(object):
    def __init__(self):
        for key, value in locals().items():
            if key != self:
                setattr(self, key, value)
        self.logger = logging.getLogger('hartree_comparator')
        self.loader = SnapshotLoader()
    
    def get_atoms(self, fname):
        "Pulls the atoms data structure from the given file"
        result = self.loader.load(fname, FileReader(fname))
        return result.getAtoms()
        
    def compare(self, first, second):
        try:
            first_atoms = self.get_atoms(first)
        except ValueError:
            self.logger.exception("Problems parsing first file %s" % first)
            raise
        try:
            second_atoms = self.get_atoms(second)
        except ValueError:
            self.logger.exception("Problems parsing second file %s" % second)
            raise
        
        if first_atoms == second_atoms:
            return True
        self.logger.error("Atoms for files %s and %s do not match" % (first, 
           second,))
        self.logger.error("%s: %s" % (first, first_atoms))
        self.logger.error("%s: %s" % (second, second_atoms))
        return False
Esempio n. 2
0
    def __init__(self):
        jar_path = Path(__file__).parent / "hartree"
        found_jars = sorted(jar_path.glob('*.jar'))
        if len(found_jars) == 0:
            raise Exception(
                "Could not find any JARs in dir {}".format(jar_path))

        for found_jar in found_jars:
            jpype.addClassPath(found_jar)

        print("Classpath: ", jpype.getClassPath())

        jpype.startJVM(convertStrings=False)

        # TODO: Figure out how to scope these imports for the class
        # noinspection PyUnresolvedReferences
        from org.cmayes.hartree.loader.gaussian import SnapshotLoader

        self.loader = SnapshotLoader()
Esempio n. 3
0
class HartreeWrapper:
    def __init__(self):
        jar_path = Path(__file__).parent / "hartree"
        found_jars = sorted(jar_path.glob('*.jar'))
        if len(found_jars) == 0:
            raise Exception(
                "Could not find any JARs in dir {}".format(jar_path))

        for found_jar in found_jars:
            jpype.addClassPath(found_jar)

        print("Classpath: ", jpype.getClassPath())

        jpype.startJVM(convertStrings=False)

        # TODO: Figure out how to scope these imports for the class
        # noinspection PyUnresolvedReferences
        from org.cmayes.hartree.loader.gaussian import SnapshotLoader

        self.loader = SnapshotLoader()

    def read_all_gaussian(self, files):
        # noinspection PyUnresolvedReferences
        from java.io import FileReader
        mapped_results = {}
        for cur_file in files:
            mapped_results[cur_file] = self.loader.load(
                cur_file, FileReader(cur_file))

        return mapped_results

    def read_gaussian(self, tgt_file):
        # noinspection PyUnresolvedReferences
        from java.io import FileReader
        return self.loader.load(tgt_file, FileReader(tgt_file))

    def __del__(self):
        if jpype.isJVMStarted():
            jpype.shutdownJVM()
Esempio n. 4
0
 def __init__(self):
     for key, value in locals().items():
         if key != self:
             setattr(self, key, value)
     self.logger = logging.getLogger('hartree_comparator')
     self.loader = SnapshotLoader()