如何使用.sdf文件修复RDkit中的“ OSError:File error:Bad input file”?

时间:2019-04-08 00:54:30

标签: c++ sdf rdkit

我正在使用来自Arxiv的python中的第三方代码,该代码使用RDkit作为库。它需要一个带有化学分子数据的.sdf文件作为参数,但是RDkit会引发错误:

OSError: File error: Bad input file file.sdf

我按照说明进行操作,安装了所需的所有软件包,按照文件所述下载了文件,由于.sdf很大,因此占用了我很大的空间,因为.sdf文件很大。但是我无法使其运行,所有这些尝试都没有成功。

我一直在寻找RDkit软件包,这是引发错误的代码段:

LocalForwardSDMolSupplier(std::string filename, bool sanitize, bool removeHs,
                          bool strictParsing) {
  std::istream *tmpStream = nullptr;
  tmpStream = static_cast<std::istream *>(
      new std::ifstream(filename.c_str(), std::ios_base::binary));
  if (!tmpStream || (!(*tmpStream)) || (tmpStream->bad())) {
    std::ostringstream errout;
    errout << "Bad input file " << filename;
    throw RDKit::BadFileException(errout.str());
  }
  dp_inStream = tmpStream;
  df_owner = true;
  df_sanitize = sanitize;
  df_removeHs = removeHs;
  df_strictParsing = strictParsing;
  POSTCONDITION(dp_inStream, "bad instream");
}

似乎是C ++,我不知道。

我希望看到此代码如何工作,以及输入和输出如何适应我的代码。我希望看到此.sdf文件,但也许另一个可以满足我的需求。

1 个答案:

答案 0 :(得分:0)

最后,我在原始代码中发现该文件的路径不正确。它需要先添加../,因为它正在调用另一个文件夹中的文件,而不是从主文件夹中,而是从一个子文件夹中调用。

谢谢,伙计们!

相关问题