#!/usr/local2/bin/python import os, string from openeye.oechem import * aa = open('d_amino_acids.smi', 'r') dnum = [] for line in aa.readlines(): dnum.append(int(string.split(line)[0])) aa.close() ifs = oemolistream() ifs.open('amino_acids.smi') ifs2 = oemolistream() ifs2.open('/raid1/people/joha/DB/1_KEGG2SDF/a_kegg_filter_5.sdf') ofs_3 = oemolostream() ofs_3.open('a_aa_outofkegg.sdf') aa_dict = {} for aa in ifs.GetOEMols(): aa_dict[OECreateCanSmiString(aa)] = [aa.GetTitle(),0] count = 0 for mol in ifs2.GetOEMols(): key = OECreateCanSmiString(mol) if aa_dict.has_key(key): print dnum, int(mol.GetTitle()[1:]) count+=1 title = aa_dict[key][0] #ofs_3.open('a_'+title+'_'+mol.GetTitle()+'.mol2') # The first one is always S-configurated if aa_dict[key][1] == 0 and int(mol.GetTitle()[1:]) not in dnum and aa_dict[key][0] != 'Glycine': mol.SetTitle('L-'+title) OEWriteMolecule(ofs_3, mol) aa_dict[key][1] = 1 elif aa_dict[key][1] == 1 and int(mol.GetTitle()[1:]) in dnum: mol.SetTitle('D-'+title) OEWriteMolecule(ofs_3, mol) aa_dict[key][1] = 2 elif aa_dict[key][1] == 0 and aa_dict[key][0] == 'Glycine': mol.SetTitle(title) OEWriteMolecule(ofs_3, mol) aa_dict[key][1] = 1 print count