/// <summary> /// ShowFavoriteMoleculeMenu /// </summary> /// <param name="location"></param> /// <param name="molEditorCtl"></param> /// <param name="qc"></param> public static void SelectFavoriteMolecule( MoleculeControl molEditorCtl, QueryColumn qc = null) { MoleculeSelectorControl i = new MoleculeSelectorControl(); i.MolEditorCtl = molEditorCtl; i.Qc = qc; i.SelectFavoriteMolecule(); }
public void SetupControl( MoleculeMx molecule) { InSetup = true; MoleculeControl.SetupAndRenderMolecule(molecule); MolDisplayFormatEdit.Text = molecule.PrimaryDisplayFormat == MoleculeRendererType.Helm ? "Biopolymer" : "Structure"; InSetup = false; return; }
/// <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> /// Retrieve a saved molecule and store in Renditor /// </summary> /// <param name="ctl"></param> public static void RetrieveSavedMolecule(MoleculeControl molCtl) { MoleculeMx cs; string fileName = null; if (!UIMisc.ReadMoleculeFileDialog(out cs, out fileName)) { return; } molCtl.SetupAndRenderMolecule(cs); molCtl.SetTemporaryMoleculeTag(Path.GetFileNameWithoutExtension(fileName)); // associate the file name in case saved as history/favorite 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; }
/// <summary> /// Copy the structure associated with the specified compound id to the clipboard /// </summary> /// <param name="cn"></param> /// <param name="mt"></param> /// <returns></returns> public static bool CopyCompoundIdStructureToClipBoard( string cn, MetaTable mt) { MoleculeMx mol = MoleculeUtil.SelectMoleculeForCid(cn, mt); if (mol != null) { MoleculeControl.CopyMoleculeToClipboard(mol); return(true); } else { MessageBoxMx.Show("Unable to retrieve structure"); return(false); } }
/// <summary> /// ShowMruMoleculeMenu /// </summary> /// <param name="location"></param> /// <param name="molEditorCtl"></param> /// <param name="qc"></param> public static void SelectMruMolecule( MoleculeControl molEditorCtl, QueryColumn qc = null) { MoleculeSelectorControl i = new MoleculeSelectorControl(); i.MolEditorCtl = molEditorCtl; i.Qc = qc; MoleculeList sl = GetMruMoleculesList(); i.Text = "Recent Query Structures"; //for (int i1 = 0; i1 < sl.Count; i1++) // rename to integers 1 to N //{ // sl[i1].Name = (i1 + 1).ToString(); //} i.StructureListControl.Setup(sl, i.ListItemSelectedCallback); i.ShowDialog(SessionManager.ActiveForm); return; }
/// <summary> /// Retrieve an existing molecule and store in MoleculeControl /// </summary> /// <param name="molCtl"></param> /// <param name="mc"></param> public static void RetrieveDatabaseStructure( MoleculeControl molCtl, MetaColumn mc) { MetaTable mt = null; string cid = "", txt; txt = "compound id"; if (mc != null) { mt = mc.MetaTable; txt += " (" + mt.KeyMetaColumn.Label + ", etc.)"; } txt = "Enter the " + txt + " that you want to use as a model."; while (true) { cid = InputCompoundId.Show(txt, "Retrieve Molecule from Database", cid, mt); if (String.IsNullOrEmpty(cid)) { return; } string molString = InputCompoundId.Molecule.PrimaryValue; if (String.IsNullOrEmpty(molString)) { MessageBoxMx.ShowError("Compound number is not in the database, try again."); continue; } MoleculeMx cs = InputCompoundId.Molecule; cs.RemoveStructureCaption(); // remove any caption molCtl.SetPrimaryTypeAndValue(cs.PrimaryFormat, cs.PrimaryValue); // set mol molCtl.SetTemporaryMoleculeTag(cid); // associate the cid in case saved as history/favorite break; } }
/// <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; }
void Initialize2( MRUEdit clc, Form parentForm, ContentsTreeControl contentsTree, bool newPopup) { QuickSearchPopup qsp = this; // debug //if (newPopup) // just created? if (!Initialized) { Visible = false; //Width = 236; // set proper size //Height = 186; Point p = clc.PointToScreen(new Point(0, clc.Bottom)); Point p2 = parentForm.PointToClient(p); Left = p.X; // position below input control Top = p.Y + clc.Height * 2; BringToFront(); ContentsTree = contentsTree; RelatedStructuresControl rsp = RelatedStructuresControl; InitialStructurePanelWidth = StructurePanel.Width; //rsp.Width + 12; // initial StructurePanel width InitialStructurePanelWidthWithoutRelatedStructureOptions = rsp.MoleculeControl.Right + 10; //InitialStructurePanelWidth = 400; // debug InitialStructurePanelHeight = rsp.Top + rsp.MoleculeControl.Height + 15; // initial StructurePanel height to just below structure box StructurePanel.Dock = DockStyle.Fill; OtherCidsList.Visible = false; MoleculeControl strBox = RelatedStructuresControl.MoleculeControl; // make structure box wider to the left int newBoxLeft = 4; int dx = strBox.Left - newBoxLeft; // amount to widen structure box int w2 = strBox.Width + dx; int h2 = strBox.Height; RSM = new RelatedStructureControlManager(); RelatedStructuresControl.RSM = RSM; RSM.RSC = RelatedStructuresControl; RSM.HideUndefinedStructureList = true; // don't show structure panel until after search complete RelatedStructuresControl.RenderSearchResultsCompleteCallBack = RenderSearchResultsCompleteCallBack; RelatedStructuresControl.SetupCheckmarks(); Initialized = true; } CommandLineControl = clc; // associated command line comtrol clc.GotFocus += CommandLine_GotFocus; clc.KeyDown += CommandLine_KeyDown; // add command line events for us clc.KeyUp += CommandLine_KeyUp; clc.PreviewKeyDown += CommandLine_PreviewKeyDown; if (!Timer.Enabled) { Timer.Enabled = true; PreviousInput = ""; // need to clear to get redisplay of structure } return; }
/// <summary> /// Add criteria to query to do a related structure search /// </summary> /// <param name="q"></param> void ModifyQueryForRelatedStructureSearch( Query q, MoleculeControl queryMolCtl) { q.KeyCriteria = q.KeyCriteriaDisplay = ""; // always remove any existing key criteria QueryTable sqt = AddStructureTableToQuery(q); // be sure we have a structure table in the query QueryColumn sqc = sqt.FirstStructureQueryColumn; sqc.Selected = true; sqc.DisplayFormatString = "Highlight=true"; if (AlignMatches.Checked) { sqc.DisplayFormatString += ";Align=true"; } QueryColumn qc = sqt.GetQueryColumnByName("molSrchType"); // include search type if (qc != null) { qc.Selected = true; } qc = sqt.GetSimilarityScoreQueryColumn(); // and match score if (qc != null) { qc.Selected = true; } ParsedStructureCriteria pssc = new ParsedStructureCriteria(); pssc.SearchType = StructureSearchType.Related; //string mfText = sqt.KeyQueryColumn.ActiveLabel + ": " + queryCid; // (queryCid no longer be accurate) //pssc.Structure = // just store a comment with the CID in the structure // new ChemicalStructureMx(StructureFormat.MolFile, ChemicalStructureMx.GetTextMessageMolFile(mfText)); MoleculeMx m = QueryMolCtl.Molecule; pssc.Molecule = new MoleculeMx(m.PrimaryFormat, m.PrimaryValue); if (AltForms.Checked) { pssc.SearchTypeUnion |= StructureSearchType.FullStructure; } if (MatchedPairs.Checked) { pssc.SearchTypeUnion |= StructureSearchType.MatchedPairs; } if (SmallWorld.Checked) { pssc.SearchTypeUnion |= StructureSearchType.SmallWorld; } if (SimilarSearch.Checked) { pssc.SearchTypeUnion |= StructureSearchType.MolSim; } if (Substructure.Checked) { pssc.SearchTypeUnion |= StructureSearchType.Substructure; } pssc.MinimumSimilarity = .75; pssc.MaxSimHits = 100; pssc.Highlight = true; pssc.Align = AlignMatches.Checked; pssc.ConvertToQueryColumnCriteria(sqc); if (ExcludeCurrentResultsCids.Checked && CurrentBaseQueryCidHitList != null) // add not in list criteria { string queryStrName = queryMolCtl.GetTemporaryStructureTag(); // see if we can get the cid q.KeysToExclude = new HashSet <string>(CurrentBaseQueryCidHitList); if (q.KeysToExclude.Contains(queryStrName)) // keep query id { q.KeysToExclude.Remove(queryStrName); } } else { q.KeyCriteria = q.KeyCriteriaDisplay = ""; // no key criteria } return; }