Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        /// <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;
        }
Exemplo n.º 3
0
/// <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;
        }