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

博文

CCDC smarts搜索注意事项

已有 2296 次阅读 2016-11-9 18:38 |系统分类:科研笔记

smarts 规则

http://www.daylight.com/dayhtml/doc/theory/theory.smarts.html

大写的C 代表非芳香碳,小写的c 代表芳香碳,[#6] 或者[C,c]可代表任意碳。

XBD_sub=ccdc.search.SMARTSSubstructure('[#9][#6]')  #index is 0
XBA_sub=ccdc.search.SMARTSSubstructure('[#7]')   #index is 0





'''python

#!/python2
#coding: utf-8

import ccdc
from ccdc.search import SubstructureSearch, SMARTSSubstructure
from ccdc.descriptors import MolecularDescriptors as MD, GeometricDescriptors as GD
from ccdc.io import EntryReader
csd_entry_reader = EntryReader('CSD')
print "number of entries:",len(csd_entry_reader)
#create fragment
#       ccdc.search.SMARTSSubstructure
XBD_sub=ccdc.search.SMARTSSubstructure('[#9][#6]')  #index is 0
XBA_sub=ccdc.search.SMARTSSubstructure('[#7]')   #index is 0

#load fragment
XB_search_engine=ccdc.search.SubstructureSearch()
XBDid=XB_search_engine.add_substructure(XBD_sub)
XBAid=XB_search_engine.add_substructure(XBA_sub)

#set bond length and angle
#1.36  1.45
#XB_search_engine.add_distance_constraint('DIST2',XBDid,0,XBDid,1,(0,1.36),type='Intramolecular')
#3.02  3.22
XB_search_engine.add_distance_constraint('DIST1',XBDid,0,XBAid,0,(0,3.02),type='Intermolecular')
XB_search_engine.add_angle_constraint('ANG1',XBDid,1,XBDid,0,XBAid,0,(140.0,180.0))


#test search mode



#no errors// not disordered //R factor less than 0.1
XB_search_engine.settings.no_disorder='all'
XB_search_engine.settings.no_errors=True
#XB_search_engine.settings.max_r_factor = 0.1


print "start searching"
#searching   set small database
XBhits=XB_search_engine.search(max_hits_per_structure=5)
print "len XB",len(XBhits)
#output
outf=open('outf.txt','w')
for obj in XBhits:
   '''
   '''
   #refcode DIST0  DIST1 ANG1 N_atomtype Rfactor  Atom1id  Atom2id  Atom3id
   bond_len=MD.atom_distance(obj.match_atoms()[0],obj.match_atoms()[1])
   
   #atom label
   atoms=obj.match_atoms()
   atomslabel=[       i.label   for i in atoms]
   
   #molecule charge
   mols=obj.match_components()
   charges=[]
   for i in mols:
       charges.append(i.formal_charge)

   
   #year
   objentry=csd_entry_reader.entry(obj.identifier)
   year=objentry.publication.year
   
   
   
   elements=[    obj.identifier  ,bond_len,obj.constraints['DIST1'],   obj.constraints['ANG1'],obj.match_atoms()[2].sybyl_type,    obj.entry.r_factor]
   elements.extend(atomslabel)
   if len(charges) ==1:
       charges.append('same')
   elements.extend(charges)
   elements.append(year)
   line='    '.join(map(str,elements))+"n"
 
   
   
   print line,
   outf.write(line)

'''





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

上一篇:linux 安装PIP,出现SSLerror
下一篇:开源对接软件
收藏 IP: 202.127.19.*| 热度|

0

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

数据加载中...

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

GMT+8, 2024-6-16 11:02

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部