//void SetMolDisplayFormatText() //{ // MolDisplayFormatEdit.Text = // QueryMolCtl.Molecule.PrimaryDisplayFormat == MoleculeRenderer.Helm ? "Biopolymer" : "Structure"; //} /// <summary> /// Get currently selected search type from form /// </summary> /// <returns></returns> StructureSearchType GetSearchType() { StructureSearchType searchType = StructureSearchType.Unknown; if (SubStruct.Checked) { searchType = StructureSearchType.Substructure; } else if (Full.Checked) { searchType = StructureSearchType.FullStructure; } else if (Similarity.Checked) { searchType = StructureSearchType.MolSim; } else if (SmallWorld.Checked) { searchType = StructureSearchType.SmallWorld; } return(searchType); }
public static string StructureSearchTypeToExternalName(StructureSearchType sst) { if (sst == StructureSearchType.Unknown) { return(""); } string txt = sst.ToString(); // default name if (sst == StructureSearchType.Substructure) { txt = "Substructure"; } else if (sst == StructureSearchType.MolSim) { txt = "Similar"; } else if (sst == StructureSearchType.MatchedPairs) { txt = "Matched Pair"; } return(txt); }
/// <summary> /// Get the list of related compounds /// </summary> /// <param name="mt"></param> /// <param name="cid"></param> /// <param name="str"></param> public void StartSearchAndRetrievalOfRelatedStructures( string mtName, string cid, MoleculeMx str, StructureSearchType searchTypes) { RSC.RenderSearchResultsDelegate = RenderSearchResults; // set render callback DisplayEmptySearchResults(); if (Lex.IsUndefined(str.PrimaryValue) || (!str.IsChemStructureFormat && str.IsBiopolymerFormat)) // reasonable structure? { return; } Cid = cid; CidMtName = mtName; QueryStruct = str; SearchTypes = searchTypes; Timer.Enabled = true; Thread t = new Thread(new ParameterizedThreadStart(SearchAndRetrieveRelatedStructuresThreadMethod)); t.IsBackground = true; t.SetApartmentState(ApartmentState.STA); object[] parms = null; t.Start(parms); return; }
/// <summary> /// Get list of related structures using the supplied compound id for the query structure /// </summary> /// <param name="cid"></param> /// <param name="type"></param> /// <returns></returns> public static string GetRelatedMatchCounts( string cid, string mtName, string chime, StructureSearchType searchTypes, int searchId) { if (ServiceFacade.UseRemoteServices) { Mobius.Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusCompoundUtilService, (int)Services.Native.ServiceOpCodes.MobiusCompoundUtilService.GetRelatedCompoundIds, //new Services.Native.NativeMethodTransportObject(new object[] { cid, mtName, chime, (int)searchTypes, searchId })); new Services.Native.NativeMethodTransportObject(new object[] { cid, mtName, chime, searchId })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); string result = (resultObject != null) ? (string)resultObject.Value : null; return(result); } else { return(QEL.MoleculeUtil.GetRelatedMatchCounts(cid, mtName, chime, searchTypes, searchId)); } }
/// <summary> /// Determine if match passes the current filter settings /// </summary> /// <param name="ssm"></param> /// <param name="dbId"></param> /// <param name="searchType"></param> /// <param name="searchTypeCount"></param> /// <param name="include"></param> /// <returns></returns> bool FilterMatch( StructSearchMatch ssm, int dbId, StructureSearchType searchType, CheckEdit searchTypeCtl, ref int searchTypeCount, ref bool include) { bool dbChecked = false; if (dbId == CorpDbId) { dbChecked = CorpDB.Checked; } else if (dbId == ChemblDbId) { dbChecked = ChemblDB.Checked; } if (!dbChecked || ssm.SrcDbId != dbId || ssm.SearchType != searchType) { return(false); } if (searchTypeCtl.Checked) { include = true; } searchTypeCount++; return(true); }
/// <summary> /// Get list of related structure compound Ids for a compound id /// </summary> /// <param name="cid"></param> /// <param name="mtName"></param> /// <param name="chime"></param> /// <returns></returns> public static string GetRelatedMatchCounts( string cid, string mtName, string chime, StructureSearchType searchTypes, int searchId) { string result = RelatedStructureSearch.GetRelatedMatchCounts(cid, mtName, chime, searchTypes, searchId); return(result); }
/// <summary> /// ShowModelSelectionMenu - static method /// </summary> /// <param name="location"></param> /// <param name="molEditorCtl"></param> /// <param name="qc"></param> public static void ShowModelSelectionMenu( Point location, MoleculeControl molEditorCtl, StructureSearchType searchType, QueryColumn qc = null) { MoleculeSelectorControl i = new MoleculeSelectorControl(); i.MolEditorCtl = molEditorCtl; i.Qc = qc; i.StructureSearchType = searchType; i.NewMoleculeMenu.Show(location); return; }
/// <summary> /// AddToFavoritesList /// </summary> /// <param name="molEditorCtl"></param> /// <param name="searchType"></param> public static void AddToFavoritesList( MoleculeControl molEditorCtl, StructureSearchType searchType) { MoleculeListItem sli = null; DialogResult dr; MoleculeMx mol = molEditorCtl.Molecule; if (MoleculeMx.IsUndefined(mol)) { return; } mol = mol.Clone(); // make a copy for the list sli = FindStructure(mol, GetFavoriteStructuresList()); if (sli != null) { dr = MessageBoxMx.Show("The current molecule already exists in Favorites list under the name: " + sli.Name + "\r\n" + "Do you still want the add the current query molecule to the Favorites list?", "Molecule already in Favorites", MessageBoxButtons.YesNoCancel); if (dr != DialogResult.Yes) { return; } } string name = molEditorCtl.GetTemporaryStructureTag(); name = InputBoxMx.Show("Enter the name that you want to assign to the molecule", "Enter Name", name); if (Lex.IsUndefined(name)) { return; } sli = new MoleculeListItem(); sli.Name = name; sli.Molecule = mol; sli.UpdateDate = DateTime.Now; sli.MoleculeType = StructureSearchTypeUtil.StructureSearchTypeToExternalName(searchType); FavoritesList.ItemList.Insert(0, sli); SaveStructureList(FavoritesList, FavoritesPreferencesParmName); return; }
public static string StructureSearchTypeToExternalName(StructureSearchType sst) { if (sst == StructureSearchType.Unknown) return ""; string txt = sst.ToString(); // default name if (sst == StructureSearchType.Substructure) txt = "Substructure"; else if (sst == StructureSearchType.MolSim) txt = "Similar"; else if (sst == StructureSearchType.MatchedPairs) txt = "Matched Pair"; return txt; }
/// <summary> /// AddToMruList /// </summary> /// <param name="molEditorCtl"></param> /// <param name="searchType"></param> public static void AddToMruList( MoleculeControl molEditorCtl, StructureSearchType searchType) { MoleculeListItem sli = null; DialogResult dr; MoleculeMx mol = molEditorCtl.Molecule; if (Lex.IsUndefined(mol.PrimaryValue)) { return; } mol = mol.Clone(); // make a copy of the mol sli = FindStructure(mol, GetMruMoleculesList()); if (sli != null) { MruList.ItemList.Remove(sli); } sli = new MoleculeListItem(); sli.Name = molEditorCtl.GetTemporaryStructureTag(); // get any associated pre-edit mol name sli.Molecule = mol; sli.UpdateDate = DateTime.Now; sli.MoleculeType = StructureSearchTypeUtil.StructureSearchTypeToExternalName(searchType); MruList.ItemList.Insert(0, sli); while (MruList.Count > MaxMruItems) { MruList.ItemList.RemoveAt(MaxMruItems - 1); } SaveStructureList(MruList, MruPreferencesParmName); return; }
object IInvokeServiceOps.InvokeServiceOperation(int opCode, object[] args) { MobiusCompoundUtilService op = (MobiusCompoundUtilService)opCode; switch (op) { case MobiusCompoundUtilService.DoesCidExist: { string cid = (string)args[0]; string mtName = (string)args[1]; Mobius.Data.MetaTable mt = (mtName == null) ? null : Mobius.Data.MetaTableCollection.Get(mtName); bool cidExists = Qel.CompoundIdUtil.Exists(cid, mt); return(cidExists); } case MobiusCompoundUtilService.SelectMoleculeFromCid: { string cid = (string)args[0]; string mtName = (string)args[1]; Mobius.Data.MetaTable mt = (mtName == null) ? null : Mobius.Data.MetaTableCollection.Get(mtName); Data.MoleculeMx nativeMolecule = Qel.MoleculeUtil.SelectMoleculeForCid(cid, mt); if (ClientState.MobiusClientVersionIsAtLeast(6, 0)) // Helm version or newer { byte[] ba = MobiusDataType.SerializeBinarySingle(nativeMolecule); return(ba); } else { ChemicalStructure transferMolecule = _transHelper.Convert <Mobius.Data.MoleculeMx, ChemicalStructure>(nativeMolecule); return(transferMolecule); } } case MobiusCompoundUtilService.SelectMoleculesForCidList: { List <string> cidList = (List <string>)args[0]; string mtName = (string)args[1]; Mobius.Data.MetaTable mt = (mtName == null) ? null : Mobius.Data.MetaTableCollection.Get(mtName); Dictionary <string, Data.MoleculeMx> csDict = Qel.MoleculeUtil.SelectMoleculesForCidList(cidList, mt); return(csDict); } case MobiusCompoundUtilService.GetAllSaltForms: { string cid = (string)args[0]; string normalizedCid = Data.CompoundId.Normalize(cid); List <string> cidList = new List <string>(new string[] { normalizedCid }); Dictionary <string, List <string> > cidDict = Qel.MoleculeUtil.GetAllSaltForms(cidList); List <string> results = null; if (cidDict.ContainsKey(cid)) { results = cidDict[cid] as List <string>; } return(results); } case MobiusCompoundUtilService.GetAllSaltFormsForList: { List <string> cidList = (List <string>)args[0]; Dictionary <string, List <string> > allSaltIds = Qel.MoleculeUtil.GetAllSaltForms(cidList); return(allSaltIds); } case MobiusCompoundUtilService.InsertSalts: { List <string> cidList = (List <string>)args[0]; List <string> result = Qel.MoleculeUtil.InsertSalts(cidList); return(result); } case MobiusCompoundUtilService.GroupSalts: { List <string> cidList = (List <string>)args[0]; List <string> result = Qel.MoleculeUtil.GroupSalts(cidList); return(result); } case MobiusCompoundUtilService.ValidateList: { string listText = (string)args[0]; string rootTableName = (string)args[1]; string result = Qel.CompoundIdUtil.ValidateList(listText, rootTableName); return(result); } case MobiusCompoundUtilService.GetRelatedCompoundIds: { StructureSearchType searchTypes = // default for old client that doesn't supply this parm StructureSearchType.FullStructure | StructureSearchType.MolSim | StructureSearchType.MatchedPairs | StructureSearchType.SmallWorld; int argIdx = 0; string cid = (string)args[argIdx++]; string mtName = (string)args[argIdx++]; string chime = (string)args[argIdx++]; if (args.Length > 4) { searchTypes = (StructureSearchType)args[argIdx++]; } int searchId = (int)args[argIdx++]; string result = Qel.MoleculeUtil.GetRelatedMatchCounts(cid, mtName, chime, searchTypes, searchId); return(result); } case MobiusCompoundUtilService.GetRelatedStructures: { string cid = (string)args[0]; string mtName = (string)args[1]; string result = Qel.MoleculeUtil.GetRelatedMatchRowsSerialized(cid, mtName); return(result); } case MobiusCompoundUtilService.ExecuteSmallWorldPreviewQuery: { string serializedQuery = (string)args[0]; object[] oa = Qel.MoleculeUtil.ExecuteSmallWorldPreviewQuerySerialized(serializedQuery); return(oa); } } return(null); }
public static bool IsSSS(StructureSearchType searchTypes) => (searchTypes & StructureSearchType.Substructure) != 0;
public static bool IsSim(StructureSearchType searchTypes) => (searchTypes & StructureSearchType.MolSim) != 0;
public static bool IsSw(StructureSearchType searchTypes) => (searchTypes & StructureSearchType.SmallWorld) != 0;
public static bool IsMmp(StructureSearchType searchTypes) => (searchTypes & StructureSearchType.MatchedPairs) != 0;
public static bool IsFull(StructureSearchType searchTypes) => (searchTypes & StructureSearchType.FullStructure) != 0;