public static Molecule AddRGrpMolToCoreMolecule(RgMolecule _rgMol, Molecule _coreMol, int _rgrpNum) { try { //Get RGroup position int rgrpPos = GetRGroupPosition(_coreMol, _rgrpNum); //Get Radical position int radPos = GetRadicalPosition(_rgMol); //Add Rgroup Molecule to Core Molecule AddRGroupToCore(ref _coreMol, _rgMol); _coreMol.add(new MolBond(_coreMol.getAtom(rgrpPos).getBond(0).getAtom1(), _rgMol.getAtom(radPos))); _coreMol.removeNode(_coreMol.getNode(rgrpPos), CGraph.RMCLEANUP_ALL); _coreMol.clean(2, null, null); rgrpPos = GetRGroupPosition(_coreMol, _rgrpNum); _coreMol.removeNode(_coreMol.getNode(rgrpPos), CGraph.RMCLEANUP_ALL); _coreMol.clean(2, null, null); return(_coreMol); } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(null); }
public static RgMolecule ReturnRGroupMolecule(string _rgrpSmiles, int _rgrpNum) { RgMolecule rgMol = null; try { if (_rgrpSmiles != "") { MolHandler mHandler = new MolHandler(_rgrpSmiles); Molecule objSmileMol = mHandler.getMolecule(); rgMol = new RgMolecule(); MolAtom mAtom = new MolAtom(MolAtom.RGROUP, 1, 0, 0); mAtom.setRgroup(_rgrpNum); rgMol.add(mAtom); int radNum = 0; for (int i = 0; i < objSmileMol.getAtomCount(); i++) { if (objSmileMol.getAtom(i).getRadical() > 0) //objSmileMol.getRadical(i) { radNum = i; break; } } for (int i = 0; i < objSmileMol.getAtomCount(); i++) { if (i == radNum) { objSmileMol.getAtom(i).setRadical(MolAtom.RAD_OFF); } rgMol.add(objSmileMol.getAtom(i)); } for (int j = 0; j < objSmileMol.getBondCount(); j++) { rgMol.add(objSmileMol.getBond(j)); } rgMol.add(new MolBond(objSmileMol.getAtom(radNum), mAtom)); rgMol.clean(2, null, null); return(rgMol); } } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } return(rgMol); }
private static int GetRadicalPosition(RgMolecule _rgMol) { int radPos = 0; try { for (int k = 0; k < _rgMol.getAtomCount(); k++) { if (_rgMol.getAtom(k).getRadical() > 0) { radPos = k; } } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } return(radPos); }
public static Molecule AddRGrpMolToCoreMolecule(RgMolecule _rgMol, Molecule _coreMol, int _rgrpNum) { try { //Get RGroup position int rgrpPos = GetRGroupPosition(_coreMol, _rgrpNum); //Get Radical position int radPos = GetRadicalPosition(_rgMol); //Add Rgroup Molecule to Core Molecule AddRGrpMolToCoreMol(ref _coreMol, _rgMol, radPos); _coreMol.add(new MolBond(_coreMol.getAtom(rgrpPos).getBond(0).getAtom1(), _rgMol.getAtom(radPos))); _coreMol.removeNode(_coreMol.getNode(rgrpPos), CGraph.RMCLEANUP_ALL); _coreMol.clean(2, null, null); rgrpPos = GetRGroupPosition(_coreMol, _rgrpNum); _coreMol.removeNode(_coreMol.getNode(rgrpPos), CGraph.RMCLEANUP_ALL); _coreMol.clean(2, null, null); //chemaxon.reaction.Standardizer stnd = new chemaxon.reaction.Standardizer("removeexplicitH:radical"); //Molecule molCore = stnd.standardize(_coreMol); //Standardize the molecule Standardizer objStnd = new Standardizer(new File(@"C:\Documents and Settings\sairam.punyamantula\Desktop\stand.xml")); Molecule molCore = objStnd.standardize(_coreMol); molCore.clean(2, null, null); return(molCore); } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } return(null); }
private static void AddRGrpMolToCoreMol(ref Molecule _coreMol, RgMolecule _rgMol, int _radicalpos) { try { for (int aIndx = 0; aIndx < _rgMol.getAtomCount(); aIndx++) { if (aIndx == _radicalpos) { _rgMol.getAtom(aIndx).setRadical(MolAtom.RAD_OFF); } _coreMol.add(_rgMol.getAtom(aIndx)); } for (int bIndx = 0; bIndx < _rgMol.getBondCount(); bIndx++) { _coreMol.add(_rgMol.getBond(bIndx)); } } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } }
private static void AddRGroupToCore(ref Molecule _coreMol, RgMolecule _rgMol) { try { for (int aIndx = 0; aIndx < _rgMol.getAtomCount(); aIndx++) { if (aIndx == 0) { _rgMol.getAtom(0).setRadical(MolAtom.RAD_OFF); } _coreMol.add(_rgMol.getAtom(aIndx)); } for (int bIndx = 0; bIndx < _rgMol.getBondCount(); bIndx++) { _coreMol.add(_rgMol.getBond(bIndx)); } } catch (Exception ex) { ErrorHandling_NTS.WriteErrorLog(ex.ToString()); } }
public static DataTable GetRGroupEnumerationResults(DataTable _enumDataTbl, string _qryRCore) { DataTable dtEnumResData = new DataTable(); try { dtEnumResData.Columns.Add("id", typeof(string)); dtEnumResData.Columns.Add("structure", typeof(object)); dtEnumResData.Columns.Add("mol_weight", typeof(double)); dtEnumResData.Columns.Add("mol_formula", typeof(string)); dtEnumResData.Columns.Add("iupac_name", typeof(string)); dtEnumResData.Columns.Add("inchi_key", typeof(string)); int rgrpNum = 1; Molecule molEnum = null; MolHandler mHandler = null; Molecule rCoreMol = null; RgMolecule rgMol = null; MolHandler mHand_Result = null; DataRow dtRow = null; string strMolFile = ""; string strIUPACName = ""; string strErrMsg = ""; if (_enumDataTbl != null) { if (_enumDataTbl.Rows.Count > 0) { for (int rowindx = 0; rowindx < _enumDataTbl.Rows.Count; rowindx++) { molEnum = new Molecule(); mHandler = new MolHandler(_qryRCore); rCoreMol = mHandler.getMolecule(); try { for (int colindx = 1; colindx < _enumDataTbl.Columns.Count; colindx++) { rgrpNum = GetRgroupNumFromRGroupName(_enumDataTbl.Columns[colindx].ColumnName); rgMol = ReturnRGroupMolecule(_enumDataTbl.Rows[rowindx][colindx].ToString(), rgrpNum); //molEnum = AddRGrpMolToCoreMolecule(rgMol, rCoreMol, rgrpNum); AddRGrpMolToCoreMolecule(ref rCoreMol, rgMol, rgrpNum); } //Set Radical Empty to Result Mol SetRadicalEmptyToResultMol(ref rCoreMol); mHand_Result = new MolHandler(rCoreMol); strMolFile = ""; strMolFile = mHand_Result.toFormat("mol"); } catch { } dtRow = dtEnumResData.NewRow(); dtRow["id"] = _enumDataTbl.Rows[rowindx][0].ToString(); dtRow["structure"] = strMolFile; if (strMolFile != "") { dtRow["mol_weight"] = mHand_Result.calcMolWeight(); dtRow["mol_formula"] = mHand_Result.calcMolFormula(); dtRow["inchi_key"] = ChemistryOperations.GetStructureInchiKey(strMolFile); strIUPACName = ""; strErrMsg = ""; if (ChemistryOperations.GetIUPACNameFromStructure(strMolFile, out strIUPACName, out strErrMsg)) { strIUPACName = Validations.GetConvertedIUPACName(strIUPACName); } else { strIUPACName = "IUPAC name not provided"; } dtRow["iupac_name"] = strIUPACName; } dtEnumResData.Rows.Add(dtRow); } return(dtEnumResData); } } } catch (Exception ex) { PepsiLiteErrorHandling.WriteErrorLog(ex.ToString()); } return(dtEnumResData); }