Beispiel #1
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;
        }