Exemple #1
0
        public void DisplayEmptyCidCountsGrid()
        {
            RelatedStructureSearchResults rss2 = new RelatedStructureSearchResults();

            DisplayRelatedCidCounts(rss2);

            return;
        }
Exemple #2
0
        /// <summary>
        /// Update the match counts panel and structure view
        /// </summary>
        /// <param name="excludeCurrentHitList"></param>
        /// <param name="rssrs"></param>

        public void DisplayRelatedCidCountsAndStructures(
            RelatedStructureSearchResults rssrs)
        {
            if (!RSC.Visible)
            {
                return;                           // just return if the match count panel is not visible
            }
            List <StructSearchMatch> fml =        // get filtered results bases on current checkbox settings
                                           RSC.FilterMatchList(rssrs);

            RSC.DisplayRelatedCidCounts(RelatedStructuresResults);

            DisplayRelatedStructures(fml);

            return;
        }
Exemple #3
0
/// <summary>
/// Get related compound ids & update display
/// </summary>
/// <param name="parm"></param>

        void SearchAndRetrieveRelatedStructuresThreadMethod(object parm)
        {
            try
            {
                int searchId = 0;                 // id for search associated with this thread

                lock (RSMLock)
                {
                    SearchCounter++;                     // assign id for the search associated with this thread
                    searchId = SearchCounter;
                }

                RelatedStructureSearchResults rss = RelatedStructureSearchResults.SearchHistory(Cid, CidMtName);
                if (rss == null || Lex.IsUndefined(Cid) || Lex.IsUndefined(CidMtName) || !UseCachedResults)
                {
                    PendingStatusMessage = "Searching...";

                    rss           = new RelatedStructureSearchResults();
                    rss.Cid       = Cid;
                    rss.CidMtName = CidMtName;

                    if (Debug)
                    {
                        DebugLog.Message("=== Client === " + searchId + ". Starting search  for CID: " + Cid + " =========");
                    }

                    string hitString = MoleculeUtil.GetRelatedMatchCounts(Cid, CidMtName, QueryStruct.GetChimeString(), SearchTypes, searchId);

                    if (Superseded(searchId))
                    {
                        return;                                           // return now if superceded and no longer needed
                    }
                    if (Debug)
                    {
                        DebugLog.Message("=== Client === " + searchId + ". Search step complete: " + hitString);
                    }
                    if (Lex.IsUndefined(hitString))
                    {
                        if (Debug)
                        {
                            DebugLog.Message("=== Client === " + searchId + ". Hit string is undefined.");
                        }
                        return;
                    }

                    string[] sa = hitString.Split(';');
                    if (sa.Length != 10)
                    {
                        return;
                    }

                    rss.AltCorpDbCnt = int.Parse(sa[0]);
                    rss.SimCorpDbCnt = int.Parse(sa[1]);
                    rss.MmpCorpDbCnt = int.Parse(sa[2]);
                    rss.SwCorpDbCnt  = int.Parse(sa[3]);
                    rss.CorpDbCnt    = int.Parse(sa[4]);

                    rss.AltChemblCnt = int.Parse(sa[5]);
                    rss.SimChemblCnt = int.Parse(sa[6]);
                    rss.MmpChemblCnt = int.Parse(sa[7]);
                    rss.SwChemblCnt  = int.Parse(sa[8]);
                    rss.ChemblCnt    = int.Parse(sa[9]);

                    RelatedStructureSearchResults.History.Add(rss);
                }

                RelatedStructuresResults = rss;
                RenderResultsRequested   = true;               // request render of initial results

                if (rss.CorpDbCnt <= 0 && rss.ChemblCnt <= 0)  // if no hits then assign empty structure list and don't do retrieve
                {
                    rss.MatchList = new List <StructSearchMatch>();
                }

                if (rss.MatchList == null)                 // retrieve structures if structure list doesn't exist
                {
                    if (Debug)
                    {
                        DebugLog.Message("=== Client === " + searchId + ". Starting structure retrieval...");
                    }

                    PendingStatusMessage = "Retrieving...";

                    rss.Cid       = Cid;
                    rss.CidMtName = CidMtName;

                    List <StructSearchMatch> ssml = MoleculeUtil.GetRelatedMatchRows(Cid, CidMtName);
                    if (Superseded(searchId))
                    {
                        return;                                           // return now if superceded and no longer needed
                    }
                    rss.MatchList = ssml;

                    if (Debug)
                    {
                        DebugLog.Message("=== Client === " + searchId + ". Structure retrieval complete");
                    }
                }

                else
                {
                    if (Debug)
                    {
                        DebugLog.Message("=== Client === " + searchId + ". Already have structures");
                    }
                }

                PendingStatusMessage = "";

                RenderResultsRequested = true;                 // request render of associated structures
                StructureRetrievalCompletedRenderRequest = true;

                if (Debug)
                {
                    DebugLog.Message("=== Client === " + searchId + ". Search and retrieval complete");
                }
                return;
            }

            catch (Exception ex)             // log any exception since any thrown exception for thread can't be caught
            {
                DebugLog.Message(ex);
            }
        }
Exemple #4
0
        /// <summary>
        /// Display the related counts
        /// </summary>
        /// <param name="rss"></param>
        ///
        public void DisplayRelatedCidCounts(
            RelatedStructureSearchResults rss)
        {
            int altCnt, mmpCnt, swCnt, simCnt, allMatchCnt;

            //MoleculeGridPageControl.Width = this.Width - 3;
            //MoleculeGridPageControl.Height = this.Height - MoleculeGridPageControl.Top - 3;

            MoleculeGridPageControl mgpc = MoleculeGridPageControl;

            if (mgpc.EditQueryButton.Visible)             // adjust tool panel for proper display
            {
                mgpc.EditQueryButton.Visible = false;
                //mgpc.MarkDataButton.Visible = false;
                mgpc.FormattingButton.Visible = false;
                mgpc.AdjustToolPanelButtonSpacing();
            }

            if (rss == null)
            {
                DisplayEmptyCidCountsGrid();
                return;
            }

            altCnt = SetRelatedCidCount(AltForms, SumByDb(rss.AltCorpDbCnt, rss.AltChemblCnt));             // alternate forms

            mmpCnt = SetRelatedCidCount(MatchedPairs, SumByDb(rss.MmpCorpDbCnt, rss.MmpChemblCnt));         // matched pairs, no ChEMBL for now

            if (SmallWorldAvailable)
            {
                swCnt = SetRelatedCidCount(SmallWorld, SumByDb(rss.SwCorpDbCnt, rss.SwChemblCnt));                 // SmallWorld
            }
            else
            {
                SmallWorld.Checked = false;
                if (MatchCountsPanel.RowCount == 5)                 // remove SmallWorld from the MatchCountsPanel
                {
                    MatchCountsPanel.SetRow(labelControl3, 2);
                    MatchCountsPanel.SetRow(SimilarStructure, 2);
                    MatchCountsPanel.SetRow(labelControl6, 3);
                    MatchCountsPanel.SetRow(AllMatches, 3);

                    MatchCountsPanel.SetRow(SmallWorldLabel, 4);
                    MatchCountsPanel.SetRow(SmallWorld, 4);
                    SmallWorldLabel.Visible   = SmallWorld.Visible = false;
                    SmallWorld.Checked        = false;
                    MatchCountsPanel.RowCount = 4;
                }

                swCnt = 0;
            }

            simCnt = SetRelatedCidCount(SimilarStructure, SumByDb(rss.SimCorpDbCnt, rss.SimChemblCnt)); // similar

            allMatchCnt = SetRelatedCidCount(AllMatches, altCnt + mmpCnt + swCnt + simCnt);             // total

            SetRelatedCidCount(CorpDB, rss.CorpDbCnt);                                                  // these values don't change during life of search results
            SetRelatedCidCount(ChemblDB, rss.ChemblCnt);

            return;
        }
Exemple #5
0
        /// <summary>
        /// Structure matches are filtered by DB, search type and currentList Membership
        /// Match counts are filtered by currentList Membership.
        /// </summary>
        /// <param name="matchSubsets"></param>
        /// <param name="excludeCurrentHitList"></param>
        /// <param name="rss"></param>
        /// <returns></returns>

        public List <StructSearchMatch> FilterMatchList(
            RelatedStructureSearchResults rss)
        {
            StructSearchMatch ssm;

            List <StructSearchMatch> passList = new List <StructSearchMatch>();
            HashSet <string>         cidSet   = new HashSet <string>();

            //if (excludeCurrentHitList) cidsToExclude = GetCurrentHitList();

            rss.ResetBaseSearchTypeCounts();

            //if (IncludeQueryStruct.Checked)
            //{
            //	ssm = new StructSearchMatch();
            //	ssm.UCI = 0; // Query structure
            //	ssm.SrcDbId = StructSearchMatch.SrcNameToId(RSM.CidMtName);
            //	ssm.SrcCid = RSM.Cid; // source compound id
            //	ssm.MolString = RenditorControl.ChimeString;
            //	ssm.MolStringFormat = StructureFormat.Chime;
            //	ssm.MatchScore = 1.0f;

            //	passList.Add(ssm);
            //}

            for (int mi = 0; mi < rss.MatchList.Count; mi++)             // check the possible db/search type combinations and add to passList if matches and allowed
            {
                ssm = rss.MatchList[mi];
                bool include = false;

                if (Lex.Eq(ssm.SrcCid, RSM.Cid))                 // query cid
                {
                    if (IncludeQueryStruct.Checked && !cidSet.Contains(ssm.SrcCid))
                    {
                        include = true;                         // include Query cid
                    }
                }

                else if (ssm.SrcDbId == CorpDbId && CorpDB.Checked)
                {
                    if (cidSet.Contains(ssm.SrcCid))                     // dup cid?
                    {
                        rss.DupCnt++;
                        //if (RemoveDups.Checked) continue;
                    }

                    if (FilterMatch(ssm, CorpDbId, SST_FullStructure, AltForms, ref rss.AltCorpDbCnt, ref include))
                    {
                        ;
                    }
                    else if (FilterMatch(ssm, CorpDbId, SST_MatchedPairs, MatchedPairs, ref rss.MmpCorpDbCnt, ref include))
                    {
                        ;
                    }
                    else if (FilterMatch(ssm, CorpDbId, SST_SmallWorld, SmallWorld, ref rss.SwCorpDbCnt, ref include))
                    {
                        ;
                    }
                    else if (FilterMatch(ssm, CorpDbId, SST_MolSim, SimilarStructure, ref rss.SimCorpDbCnt, ref include))
                    {
                        ;
                    }
                }

                else if (ssm.SrcDbId == ChemblDbId && ChemblDB.Checked)
                {
                    if (cidSet.Contains(ssm.SrcCid))                     // dup cid?
                    {
                        rss.DupCnt++;
                        //if (RemoveDups.Checked) continue;
                    }

                    if (FilterMatch(ssm, ChemblDbId, SST_MatchedPairs, MatchedPairs, ref rss.MmpChemblCnt, ref include))
                    {
                        ;
                    }
                    else if (FilterMatch(ssm, ChemblDbId, SST_SmallWorld, SmallWorld, ref rss.SwChemblCnt, ref include))
                    {
                        ;
                    }
                    else if (FilterMatch(ssm, ChemblDbId, SST_MolSim, SimilarStructure, ref rss.SimChemblCnt, ref include))
                    {
                        ;
                    }
                }

                if (include)
                {
                    passList.Add(ssm);
                    cidSet.Add(ssm.SrcCid);
                }
            }

            return(passList);
        }