#!/usr/local2/bin/python2.3 # transform sdfs to mol2 and give new titles import sys, string, os from openeye.oechem import * if os.path.exists('na_sdf2mol2.txt'): os.system('cp na_sdf2mol2.txt na_sdf2mol2.txt.sik') title_listf = open('na_sdf2mol2.txt', 'r') title_list = [] for line in title_listf.readlines(): title_list.append(line[:-1]) title_listf.close() else: title_list = [] ifs = oemolistream() ofs = oemolostream() molecule = None file_list = [sys.argv[1]] for file in file_list: if string.find(file, '_lp_') != -1: ti_path = 'LP' elif string.find(file, '_ln_') != 1: ti_path = 'LN' else: ti_path = 'LN' ifs.open(file) for mol in ifs.GetOEMols(): # if mol.NumAtoms() < 71: will alle XXXXX !!!! OEPerceiveChiral(mol) OEFindRingAtomsAndBonds(mol) OETriposAtomTypes(mol) OETriposAtomTypeNames(mol) OETriposBondTypeNames(mol) OETriposAtomNames(mol) OEAssignAromaticFlags(mol) OEGasteigerPartialCharges(mol) count, parts = OEDetermineRingSystems(mol) ring_path = 'MORE' # Generate title, evtl new ionization state out of ionizer pretitle = 'MFCD'+mol.GetTitle() title = pretitle+'_p001_'+string.lower(ring_path)+'_'+string.lower(ti_path) num = 1 # while title in 'titles_RING_'+ring_path+'_'+ti_path: while title in title_list: num+=1 title = pretitle+'_p00'+str(num)+'_'+string.lower(ring_path)+'_'+string.lower(ti_path) mol.SetTitle(title) title_list.append(title) ofs.open('MOLS/RING_'+ring_path+'_NA_HEI/OH_'+ti_path+'/'+title+'.mol2') OEWriteMol2File(ofs,mol) ofs.close() title_listf = open('na_sdf2mol2.txt', 'w') for title in title_list: title_listf.write(title+'\n') title_listf.close()