def extract_named_descriptors_of_seq(sequence): ''' Returns a map ("descriptor" -> value) of descriptors when given a sequence of aminoacids (string) :param sequence: :return: ''' #mol = Chem.MolFromSequence(str(sequence)) res = {} sequence=str(sequence) if len(sequence) > 3: #print(Autocorrelation.CalculateGearyAutoTotal(sequence)) res = PseudoAAC.GetPseudoAAC(sequence, lamda=3, weight=0.05, AAP=[_Hydrophobicity, _hydrophilicity, _residuemass, _pK1, _pK2, _pI]) res.update(AAComposition_extra_PS.CalculateAAComposition(sequence)) res.update(CTD.CalculateCTD(sequence)) mol = Chem.MolFromSequence(str(sequence)) #res = geary.GetGearyAuto(mol) res.update(kappa.GetKappa(mol)) res.update(charge.GetCharge(mol)) #res.update(moran.GetMoranAuto(mol)) res.update(moreaubroto.GetMoreauBrotoAuto(mol)) res.update(molproperty.GetMolecularProperty(mol)) #res.update(moe.GetMOE(mol)) res.update(basak.Getbasak(mol)) #print(res) #input() return res
def smiles_converter(self, smi, L): res = [] try: mol = Chem.MolFromSmiles(smi) res.append(constitution.GetConstitutional(mol)) res.append(connectivity.GetConnectivity(mol)) res.append(fingerprint.CalculateMACCSFingerprint(mol)[1]) try: res.append(kappa.GetKappa(mol)) except: pass try: drug.ReadMolFromSmile(smi) res.append(drug.GetMOE()) except: pass try: res.append(charge.GetCharge(mol)) except: pass except: pass super_dict = {} # uses set to avoid duplicates if len(res) >= 1: for d in res: for k, v in d.items(): # use d.iteritems() in python 2 super_dict[k] = v super_dict["smiles"] = smi.strip() L.append(super_dict)
def compute1D2DDesc(self, prDescbyChem): self.prDesc = prDescbyChem # check if descriptors already computed pdes = prDescbyChem + self.name + ".txt" if path.exists(pdes) and path.getsize(pdes) > 10: filin = open(pdes, "r") llines = filin.readlines() filin.close() ldesc = llines[0].strip().split("\t")[1:] lval = llines[1].strip().split("\t")[1:] ddes = {} i = 0 while i < len(ldesc): ddes[ldesc[i]] = lval[i] i += 1 self.allDesc = ddes self.log = self.log + "Desc already computed -> " + pdes + "\n" return 0 if not "smiclean" in self.__dict__: self.log = self.log + "No smiles prepared\n" return 1 else: self.mol = loader.ReadMolFromSmile(self.smiclean) print self.smiclean try: self.consti = constitution.GetConstitutional(self.mol) except: self.consti = {} self.compo = {} try: self.compo["nheavy"] = self.mol.GetNumHeavyAtoms() except: self.compo = {} try: self.molprop = molproperty.GetMolecularProperty(self.mol) except: self.molprop = {} # 2D try: self.topo = topology.GetTopology(self.mol) except: self.topo = {} try: self.connect = connectivity.GetConnectivity(self.mol) except: self.connect = {} try: self.kap = kappa.GetKappa(self.mol) except: self.kap = {} try: self.burden = bcut.GetBurden(self.mol) except: self.burden = {} try: self.basakD = basak.Getbasak(self.mol) except: self.basakD = {} try: self.est = estate.GetEstate(self.mol) except: self.est = {} try: self.moreauBurto = moreaubroto.GetMoreauBrotoAuto(self.mol) except: self.moreauBurto = {} try: self.autcormoran = moran.GetMoranAuto(self.mol) except: self.autcormoran = {} try: self.gearycor = geary.GetGearyAuto(self.mol) except: self.gearycor = {} try: self.charges = charge.GetCharge(self.mol) except: self.charges = {} try: self.MOE = moe.GetMOE(self.mol) except: self.MOE = {} # combine all 1D2D if not "allDesc" in dir(self): self.allDesc = dict() self.allDesc.update(deepcopy(self.consti)) self.allDesc.update(deepcopy(self.compo)) self.allDesc.update(deepcopy(self.molprop)) self.allDesc.update(deepcopy(self.topo)) self.allDesc.update(deepcopy(self.connect)) self.allDesc.update(deepcopy(self.kap)) self.allDesc.update(deepcopy(self.burden)) self.allDesc.update(deepcopy(self.basakD)) self.allDesc.update(deepcopy(self.est)) self.allDesc.update(deepcopy(self.moreauBurto)) self.allDesc.update(deepcopy(self.autcormoran)) self.allDesc.update(deepcopy(self.gearycor)) self.allDesc.update(deepcopy(self.charges)) self.allDesc.update(deepcopy(self.MOE)) if self.allDesc == {}: return 1 else: return 0
def get_descriptor2D(self): try: self.topo = topology.GetTopology(self.mol) except: self.topo = {} try: self.connect = connectivity.GetConnectivity(self.mol) except: self.connect = {} try: self.kap = kappa.GetKappa(self.mol) except: self.kap = {} try: self.burden = bcut.GetBurden(self.mol) except: self.burden = {} try: self.basakD = basak.Getbasak(self.mol) except: self.basakD = {} try: self.est = estate.GetEstate(self.mol) except: self.est = {} try: self.moreauBurto = moreaubroto.GetMoreauBrotoAuto(self.mol) except: self.moreauBurto = {} try: self.autcormoran = moran.GetMoranAuto(self.mol) except: self.autcormoran = {} try: self.gearycor = geary.GetGearyAuto(self.mol) except: self.gearycor = {} try: self.charges = charge.GetCharge(self.mol) except: self.charges = {} try: self.MOE = moe.GetMOE(self.mol) except: self.MOE = {} # list 2D -> modified in main library !!!! self.l2D = topology._Topology.keys() self.l2D = self.l2D + connectivity._connectivity.keys() self.l2D = self.l2D + LKAPA self.l2D = self.l2D + LBUCUT self.l2D = self.l2D + basak._basak.keys() self.l2D = self.l2D + LESTATE self.l2D = self.l2D + LMOREAUBROTO self.l2D = self.l2D + LMORAN self.l2D = self.l2D + LGEARY self.l2D = self.l2D + charge._Charge.keys() self.l2D = self.l2D + LMOE # combine all 2D self.all2D = dict() self.all2D.update(deepcopy(self.topo)) self.all2D.update(deepcopy(self.connect)) self.all2D.update(deepcopy(self.kap)) self.all2D.update(deepcopy(self.burden)) self.all2D.update(deepcopy(self.basakD)) self.all2D.update(deepcopy(self.est)) self.all2D.update(deepcopy(self.moreauBurto)) self.all2D.update(deepcopy(self.autcormoran)) self.all2D.update(deepcopy(self.gearycor)) self.all2D.update(deepcopy(self.charges)) self.all2D.update(deepcopy(self.MOE))
def get_descriptor1D2D(self): try: self.consti = constitution.GetConstitutional(self.mol) except: self.consti = {} self.compo = {} try: self.compo["nheavy"] = self.mol.GetNumHeavyAtoms() except: self.compo = {} try: self.molprop = molproperty.GetMolecularProperty(self.mol) except: self.molprop = {} try: self.topo = topology.GetTopology(self.mol) except: self.topo = {} try: self.connect = connectivity.GetConnectivity(self.mol) except: self.connect = {} try: self.kap = kappa.GetKappa(self.mol) except: self.kap = {} try: self.burden = bcut.GetBurden(self.mol) except: self.burden = {} try: self.basakD = basak.Getbasak(self.mol) except: self.basakD = {} try: self.est = estate.GetEstate(self.mol) except: self.est = {} try: self.moreauBurto = moreaubroto.GetMoreauBrotoAuto(self.mol) except: self.moreauBurto = {} try: self.autcormoran = moran.GetMoranAuto(self.mol) except: self.autcormoran = {} try: self.gearycor = geary.GetGearyAuto(self.mol) except: self.gearycor = {} try: self.charges = charge.GetCharge(self.mol) except: self.charges = {} try: self.MOE = moe.GetMOE(self.mol) except: self.MOE = {} # list 1D2D -> modified in main library !!!! self.l1D2D = constitution._constitutional.keys() self.l1D2D = self.l1D2D + ["nheavy"] self.l1D2D = self.l1D2D + molproperty.MolecularProperty.keys() self.l1D2D = self.l1D2D +topology._Topology.keys() self.l1D2D = self.l1D2D + connectivity._connectivity.keys() self.l1D2D = self.l1D2D + LKAPA self.l1D2D = self.l1D2D + LBUCUT self.l1D2D = self.l1D2D + basak._basak.keys() self.l1D2D = self.l1D2D + LESTATE self.l1D2D = self.l1D2D + LMOREAUBROTO self.l1D2D = self.l1D2D + LMORAN self.l1D2D = self.l1D2D + LGEARY self.l1D2D = self.l1D2D + charge._Charge.keys() self.l1D2D = self.l1D2D + LMOE # combine all 1D-2D self.all1D2D = dict() self.all1D2D.update(self.consti) self.all1D2D.update(self.compo) self.all1D2D.update(self.molprop) self.all1D2D.update(deepcopy(self.topo)) self.all1D2D.update(deepcopy(self.connect)) self.all1D2D.update(deepcopy(self.kap)) self.all1D2D.update(deepcopy(self.burden)) self.all1D2D.update(deepcopy(self.basakD)) self.all1D2D.update(deepcopy(self.est)) self.all1D2D.update(deepcopy(self.moreauBurto)) self.all1D2D.update(deepcopy(self.autcormoran)) self.all1D2D.update(deepcopy(self.gearycor)) self.all1D2D.update(deepcopy(self.charges)) self.all1D2D.update(deepcopy(self.MOE))