-
Notifications
You must be signed in to change notification settings - Fork 3
OpenDXファイルによる原子グリッドの置換 #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smzmsys
wants to merge
9
commits into
master
Choose a base branch
from
opendx
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
面倒事を発言しているかもしれないと思いつつ、、、 https://github.com/openbabel/openbabel/blob/openbabel-2-4-1/src/formats/opendxformat.cpp openbabelに、opendxformatを読み込むモノがあるみたいです。自前実装はいろいろ怖いですし、v2.4.1でも入っているということは依存関係は増えないので、これをご確認いただけますか? |
|
chatGPTが示したコード例 #include <openbabel/obconversion.h>
#include <openbabel/mol.h>
#include <openbabel/griddata.h> // ここが重要:グリッドデータを扱う
#include <iostream>
using namespace OpenBabel;
int main(int argc, char **argv)
{
if (argc < 2)
{
std::cerr << "Usage: read_dx input.dx" << std::endl;
return 1;
}
OBConversion conv;
OBMol mol;
// OpenDXフォーマットで読み込み
if (!conv.SetInFormat("opendx"))
{
std::cerr << "OpenDX format not supported!" << std::endl;
return 1;
}
if (!conv.ReadFile(&mol, argv[1]))
{
std::cerr << "Failed to read " << argv[1] << std::endl;
return 1;
}
// --- グリッドデータ取得 ---
OBGridData *grid = mol.GetData<OBGridData>();
if (!grid)
{
std::cerr << "No grid data found in the molecule." << std::endl;
return 1;
}
// グリッドのサイズを確認
int nx = grid->GetXDim();
int ny = grid->GetYDim();
int nz = grid->GetZDim();
std::cout << "Grid size: " << nx << " x " << ny << " x " << nz << std::endl;
// 空間的な原点とセルサイズ
vector3 origin = grid->GetOrigin();
vector3 spacing = grid->GetSpacing();
std::cout << "Origin: " << origin.x() << ", " << origin.y() << ", " << origin.z() << std::endl;
std::cout << "Spacing: " << spacing.x() << ", " << spacing.y() << ", " << spacing.z() << std::endl;
// --- 任意の (x, y, z) で値を取得する例 ---
int ix = 10, iy = 20, iz = 30; // サンプルの格子インデックス
double value = grid->GetValue(ix, iy, iz);
std::cout << "Value at (" << ix << ", " << iy << ", " << iz << ") = " << value << std::endl;
// --- 物理座標から最近傍の格子点値を得たい場合 ---
double x = 5.0, y = 6.0, z = 7.0;
int gx = (int)((x - origin.x()) / spacing.x());
int gy = (int)((y - origin.y()) / spacing.y());
int gz = (int)((z - origin.z()) / spacing.z());
if (gx >= 0 && gx < nx && gy >= 0 && gy < ny && gz >= 0 && gz < nz)
{
double v = grid->GetValue(gx, gy, gz);
std::cout << "Nearest grid value at (" << x << ", " << y << ", " << z << ") = " << v << std::endl;
}
else
{
std::cout << "Point is outside the grid." << std::endl;
}
return 0;
} |
|
openbabelでopendxファイルをパースする処理に変更しました。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
conformer-docking時、オプションで指定した
dx_folderに.dxが存在する原子タイプは.gridではなく.dxの方のデータを使う機能を追加しました。.dxのグリッドが指定するボックスに一致しているかの判定機能は実装できていません。