|
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)
'''
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-16 15:43
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社