pnnl / isicle

In silico chemical library engine for high-accuracy chemical property prediction
BSD 3-Clause "New" or "Revised" License
58 stars 19 forks source link

Issue in Running the xtb’s Conformer Rotamer Ensemble Sampling Tool ( CREST ) #39

Open sraj21200 opened 3 months ago

sraj21200 commented 3 months ago

While writing the code as per the User's Guide for NMR Chemical Shift Calculation in CREST Conformational Ensembles , there is a runtime error being raised. The jupyter notebook file is here


RuntimeError Traceback (most recent call last) Cell In[5], line 1 ----> 1 conformer = geom.md(forcefield='gff', 2 ewin = 3, 3 task = 'conformer', 4 solvation = 'water', 5 processes = 4)

File ~/anaconda3/isicle/isicle/geometry.py:110, in XYZGeometry.md(self, program, kwargs) 93 def md(self, program="xtb", kwargs): 94 """ 95 Optimize geometry or generate conformers or adducts using stated forcefield. 96 (...) 107 108 """ --> 110 return isicle.md.md(self, program=program, **kwargs)

File ~/anaconda3/isicle/isicle/md.py:66, in md(geom, program, kwargs) 49 """ 50 Optimize geometry via molecular dyanmics using supplied forcefield 51 and basis set. (...) 62 63 """ 65 # Select program ---> 66 return _program_selector(program).run(geom, kwargs)

File ~/anaconda3/isicle/isicle/md.py:444, in XTBWrapper.run(self, geom, **kwargs) 441 self.submit() 443 # Finish/clean up --> 444 self.finish() 446 return self

File ~/anaconda3/isicle/isicle/md.py:394, in XTBWrapper.finish(self) 391 parser.load(os.path.join(self.temp_dir, self.basename + ".out")) 392 self.output = parser.load(os.path.join(self.temp_dir, self.basename + ".out")) --> 394 result = parser.parse() 396 self.dict.update(result) 398 for i in self.geom:

File ~/anaconda3/isicle/isicle/parse.py:1185, in XTBParser.parse(self) 1183 # Check that the file is valid first 1184 if len(self.contents) == 0: -> 1185 raise RuntimeError("No contents to parse: {}".format(self.path)) 1187 last_lines = "".join(self.contents[-10:]) 1188 if ( 1189 ("terminat" not in last_lines) 1190 & ("normal" not in last_lines) 1191 & ("ratio" not in last_lines) 1192 ):

RuntimeError: No contents to parse: /tmp/isicle/tmpe7k4q63_/DMS.out

smcolby commented 2 months ago

Could you paste the contents of /tmp/isicle/tmpe7k4q63_/DMS.out (or if it no longer exists, rerun the code and paste the contents of the .out file indicated by the RuntimeError).

sraj21200 commented 2 months ago

Hello, the .out file doesn't contain anything. I have attached the temporary folder generated in new run below.

13321_2018_305_MOESM2_ESM.zip

The python file which i am running is here.

ezyzip.zip

smcolby commented 2 months ago

Could you attempt running xTB/CREST outside of ISiCLE? I.e. from the command line, for example:

xtb --gfn2 --opt vtight water.xyz

Where water.xyz contains:

3
Water
O     0.0000000    0.0000000   -0.3893611
H     0.7629844    0.0000000    0.1946806
H    -0.7629844    0.0000000    0.1946806
sraj212000 commented 2 months ago

Yes it runs successfully giving the output on the terminal. But can you tell me how to run the following step in command line terminal using xTB/CREST

conformer = geom.md(forcefield='gff',
                    ewin = 3,
                    task = 'conformer',
                    charge = geom.get_formal_charge(),
                    solvation = 'water',
                    processes = 4)

As this is the step where the run time error was getting generated earlier.

smcolby commented 2 months ago

Apolgies for the delay. The below runs okay on my end, both within ISiCLE and directly on the command line. Could you paste your XYZ file here? It wasn't clear based on the files you shared.

crest {geometry}.xyz -chrg {charge} --ewin 3 --optlevel Normal -gff --alpb water -T 4 &> {geometry}.out

sraj212000 commented 2 months ago

This Command line runs smoothly while running on terminal and generates the output file properly. But the issue is since the isicle code is integrated with python programming i am unable to figure out how to move to the next step as per the manual guide to get conformers stored in my conformer variable as while running the python code it generates error.

After running the command and getting the output file how to perform the below parse operation to extract relevant information using the .out file ? The Parse function at which the python code was unable to read output file is shown below.

I am not able to understand this.

    def parse(self):
        """
        Extract relevant information from data
        """

        # Check that the file is valid first
        if len(self.contents) == 0:
            raise RuntimeError("No contents to parse: {}".format(self.path))

        last_lines = "".join(self.contents[-10:])
        if (
            ("terminat" not in last_lines)
            & ("normal" not in last_lines)
            & ("ratio" not in last_lines)
        ):
            raise RuntimeError("XTB job failed: {}".format(self.path))

        self.parse_crest = False
        self.parse_opt = False
        self.parse_isomer = False

        # Initialize result object to store info
        result = {}
        result["protocol"] = self._parse_protocol()

        try:
            result["timing"] = self._parse_timing()
        except:
            pass

        try:
            result["energy"] = self._parse_energy()
        except:
            pass

        # Parse geometry from assoc. XYZ file
        try:
            if self.path.endswith("xyz"):
                try:
                    self.xyz_path = self.path
                    result["geom"] = self._parse_xyz()

                except:
                    pass

            if self.path.endswith("out") or self.path.endswith("log"):
                # try geometry parsing
                try:
                    XYZ = None
                    if result["protocol"].split()[0] == "xtb":
                        self.parse_opt = True
                        XYZ = "xtbopt.xyz"
                    if result["protocol"].split()[1] == "crest":
                        if "-deprotonate" in result["protocol"]:
                            self.parse_isomer = True
                            XYZ = "deprotonated.xyz"
                        elif "-protonate" in result["protocol"]:
                            self.parse_isomer = True
                            XYZ = "protonated.xyz"
                        elif "-tautomer" in result["protocol"]:
                            self.parse_isomer = True
                            XYZ = "tautomers.xyz"
                        else:
                            self.parse_crest = True
                            XYZ = "crest_conformers.xyz"

                    if XYZ is None:
                        raise RuntimeError(
                            "XYZ file associated with XTB job not available,\
                                        please parse separately."
                        )

                    else:
                        temp_dir = os.path.dirname(self.path)
                        self.xyz_path = os.path.join(temp_dir, XYZ)

                        result["geom"] = self._parse_xyz()
                except:
                    pass
        except:
            pass
        return result
smcolby commented 2 months ago

Could you try running the isicle code without charge = geom.get_formal_charge() (i.e. supply charge manually instead)? This may be the culprit, if charge is not getting detected correctly.

To answer your question though, you can initialize the parser as follows:

parser = isicle.parse.XTBParser()
parser.load("/path/to/file.out")
result = parser.parse()