autodataming的个人博客分享 http://blog.sciencenet.cn/u/autodataming

博文

借助chemdraw批量把cdx转成3dmol2格式

已有 11522 次阅读 2013-11-8 21:00 |个人分类:DrugDesign|系统分类:科研笔记| 分子, 批量, 转3d, 保持构型

chem3d.pl

背景:

http://bbs.sciencenet.cn/home.php?mod=space&uid=950202&do=blog&id=739794

由于openbabel不能把2d的sdf转成3d的SDF,同时保持构型

由于chemdraw,chem3d又属于商业软件,貌似没有提供API,

如果您知道chemdraw的API,请与我联系 744891290@qq.com

可能corina也能转3d且保持构型,由于它要申请liscense,我就没尝试。

解铃仍须系铃人。

chemdraw 画的结构存成的2D的sdf,或者cdx

所以借助chem3d转成3d肯定没问题

方法:

借助于perl的win32-guitest的模块,写了一个类似按键精灵的脚本,

打开文件,再另存为;

 

 

 

 

#!/usr/bin/perl -w
use strict;

use Win32::GuiTest qw( FindWindowLike SetForegroundWindow SendKeys WMGetText);
my @windowhandles=FindWindowLike(undef,"^Chem");

     printf ("the calucator handle is %x",$windowhandles[0]);
SetForegroundWindow($windowhandles[0]);
opendir(DIR,"E:/yyq/zy/");
my @files=readdir(DIR);
shift @files;
shift @files;
foreach my $file(@files)
{
SendKeys("^o");

@windowhandles=FindWindowLike(undef,"^打开");
printf ("the calucator handle is %x",$windowhandles[0]);
 SetForegroundWindow($windowhandles[0]);
 sleep 1;
my $command='+'.$file;
SendKeys($command);
 
SendKeys('%o');
sleep 1;
SendKeys('^+s');

my $command2;

if($file=~/(\S+)\./)
{
     $command2=$1;
}
SendKeys($command2);
SendKeys('%s');
sleep 2;

}

 

 

 

 

 

 

 

 

 

 

 

 

当然用perl调用windows函数肯定没有c直接调用,顺畅。

处理一个命令后,我让它休息2s,最终依旧有4个文件命令缺少了首字母。

本来打算研究完这个模块,再写这个脚本的,

遇到了一个问题

SendMessage函数需要一个c++指针,不知道用perl怎么来构建。

搞了好长时间没搞出来,没时间再搞了,

就随便把几个命令,堆积了一下

如果能再加几个if判断,这个脚本可能会更流畅

如果能够窗口最小化的情况下操作,那样就可以做其他事情了,

而现在运行这个批处理,这台电脑是暂时不能处理其他事情的。

##########

这算不算一个chemdraw的外挂

 

 

 



https://wap.sciencenet.cn/blog-950202-740152.html

上一篇:maestro中小分子手性识别的问题
下一篇:sybyl中小分子的能量优化
收藏 IP: 109.169.70.*| 热度|

1 李剑超

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-20 09:37

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部