Exemplo n.º 1
0
/// <summary>
/// Load any target map info
/// </summary>

        void LoadTargetMap()
        {
            try
            {
                Tso = TargetSummaryOptions.GetFromMdbAssayOptionsColumn(Qt);
                if (Tso == null || Lex.IsNullOrEmpty(Tso.TargetMapName))
                {
                    return;
                }

                TargetMap = TargetMapDao.GetMapByLabel(Tso.TargetMapName);                 // get the basics
                TargetMap = TargetMapDao.GetMapWithCoords(TargetMap.Name);                 // get the coords
                return;
            }
            catch (Exception ex) { return; }             // just return if "none" or no longer exists
        }
Exemplo n.º 2
0
/// <summary>
/// Summarize unpivoted unsummarized assay data by target
/// </summary>
/// <param name="parms"></param>
/// <param name="qm2"></param>
/// <returns></returns>

        public QueryManager SummarizeByTargetUnpivoted(
            TargetSummaryOptions summaryOptions,
            QueryManager qm2)
        {
            // This method takes an unpivoted input query, summarizes it according to the summarization parameters
            // and then formats the summarized data according to the specified output format.
            // If a targetMap is specified then then coordinates are included in the output, the summarization
            // level must be target, and the output format must be unpivoted.

            QueryTable        qt, qt2;
            DataRowMx         dr, dr2;
            DataRowAttributes dra;
            string            cid = "", currentCid;
            int rti, rfi;

            AssayDict tad = TargetAssayDict;                                                // be sure target assay dict has been loaded

            TargetAssaySummarizationLevel sumLevel  = TargetAssaySummarizationLevel.Target; // target level
            SummarizationType             sumMethod = summaryOptions.UseMeans ? SummarizationType.BioResponseMean : SummarizationType.MostPotent;
            OutputDest outputDest = OutputDest.WinForms;
            TargetMap  targetMap  = TargetMapDao.GetMapWithCoords(summaryOptions.TargetMapName);

            qt = Query.GetQueryTableByName(MultiDbAssayDataNames.CombinedNonSumTableName);
            if (qt == null)
            {
                throw new Exception("Query table not found: " + MultiDbAssayDataNames.CombinedNonSumTableName);
            }

            UnpivotedAssayResultFieldPositionMap voMap = UnpivotedAssayResultFieldPositionMap.NewOriginalMap();             // used for fast indexing of value by col name

            voMap.InitializeFromQueryTableVoPositions(qt, 0);

            if (qm2 == null)             // need to create query manager?
            {
                qm2 = new QueryManager();
                qm2 = InitializeSubqueryQm(MultiDbAssayDataNames.CombinedNonSumTableName);
            }

            Query q2 = qm2.Query;

            qt2 = q2.GetQueryTableByNameWithException(MultiDbAssayDataNames.BaseTableName);

            UnpivotedAssayResultFieldPositionMap voMap2 = UnpivotedAssayResultFieldPositionMap.NewOriginalMap();             // used for fast indexing of value by col name

            voMap2.InitializeFromQueryTableVoPositions(qt2, 0);

// Summarize rows & store in DataSet

            qm2.DataTable.Clear();

            Dictionary <string, object> includedTargets = null;

            if (summaryOptions.TargetsWithActivesOnly)
            {             // scan data & make a list of targets to be included
                includedTargets = new Dictionary <string, object>();
                // ...
            }

            List <UnpivotedAssayResult> tars = new List <UnpivotedAssayResult>();           // build list of TA rows here

            currentCid = "";

            for (int dri = 0; dri <= DataTableMx.Rows.Count; dri++)
            {
                if (dri < DataTableMx.Rows.Count)
                {
                    dr  = DataTableMx.Rows[dri];
                    cid = dr[KeyValueVoPos] as string;
                    dra = GetRowAttributes(dr);
                    if (dra != null && dra.Filtered)
                    {
                        continue;
                    }
                    if (currentCid == "")
                    {
                        currentCid = cid;
                    }
                }
                else
                {
                    dr = null;
                }

                if (dr == null || cid != currentCid)
                {                       // summarize rows for current cid & add to new datatable
                    if (tars.Count > 0) //
                    {
                        List <UnpivotedAssayResult> sumTars = TargetAssayUtil.SummarizeData(
                            tars,
                            sumLevel,
                            sumMethod,
                            true,
                            NullValue.NullNumber,
                            NullValue.NullNumber,
                            targetMap);

                        int voLength2 = qm2.DataTable.Columns.Count;
                        foreach (UnpivotedAssayResult sumTar in sumTars)
                        {
                            object[] vo2 = sumTar.ToValueObject(voLength2, voMap2);
                            dr2 = qm2.DataTable.NewRow();
                            dr2.ItemArrayRef = vo2;                             // copy ref for efficiency since vo won't be changed
                            qm2.DataTable.Rows.Add(dr2);
                        }
                    }
                    if (dr == null)
                    {
                        break;
                    }
                    tars.Clear();
                    currentCid = cid;
                }

                UnpivotedAssayResult tar = UnpivotedAssayResult.FromValueObjectNew(dr.ItemArray, voMap);
                tars.Add(tar);                 // store in form for summarization
            }

            qm2.DataTableManager.InitializeRowAttributes();

            return(qm2);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Selected a new target map
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void TargetMap_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (InSetup)
            {
                return;
            }
            string newTargetMap = TargetMap.Text;

            if (Lex.Eq(newTargetMap, "Retrieve KEGG Pathway...")) // lookup KEGG pathway
            {
                if (Math.Abs(1) == 1)                             // 2/1/2013, best available now e.g. http://www.kegg.jp/kegg-bin/show_pathway?hsa04010
                {
                    MessageBoxMx.ShowError(@"Automated access to pathway maps is now available through subsciption only.");
                    return;
                }

                SetTargetMapText(SelectedTargetMap);                 // keep current map for now

                string pathwayId = InputBoxMx.Show(
                    "Enter the KEGG pathway id (e.g. hsa00010) for the desired pathway. " +
                    "Pathway identifiers can be looked up at: " +
                    "<a href=\"http://www.genome.jp/kegg/pathway.html\" target=\"_blank\">http://www.genome.jp/kegg/pathway.html</a>",
                    "KEGG Pathway Identifier");

                if (String.IsNullOrEmpty(pathwayId))
                {
                    return;
                }

                try
                {
                    Progress.Show("Retrieving KEGG information for pathway: " + pathwayId, UmlautMobius.String, false);
                    TargetMap tm = TargetMapDao.GetKeggPathway(pathwayId);
                    Progress.Hide();
                    if (!MapLabelDict.ContainsKey(tm.Label.ToUpper()))
                    {
                        MapLabelDict[tm.Label.ToUpper()] = null;
                        MapLabelList.Add(tm.Label);
                        UserMapNames.Add(tm.Name);
                    }

                    TargetMap.Properties.Items.Clear();
                    TargetMap.Properties.Items.AddRange(MapLabelList);       // update list
                    SelectedTargetMap = tm.Label;
                    SetTargetMapText(SelectedTargetMap);                     // make current selection
                }

                catch (Exception ex)
                {
                    string msg = ex.Message;
                    Progress.Hide();
                    MessageBoxMx.ShowError("Pathway not found");
                    return;
                }

                return;
            }

            else if (newTargetMap.StartsWith("---"))             // divider selected, ignore
            {
                SetTargetMapText(SelectedTargetMap);
            }

            SetTargetMapText(newTargetMap);             // new map selected
        }
Exemplo n.º 4
0
/// <summary>
/// Initialize form with map info
/// </summary>
/// <param name="tso"></param>

        void InitializeTargetMapControl(TargetSummaryOptions tso)
        {
            MapLabelList = new List <string>();
            MapLabelDict = new Dictionary <string, object>();
            UserMapNames = new List <string>();                               // pathways specific to this user

            TargetMapNamesAndLabels = TargetMapDao.GetTargetNamesAndLabels(); // get full list of maps
            List <string> commonMapNames = TargetMapDao.GetCommonMapNames();  // get common maps

            foreach (string mapName in commonMapNames)
            {
                if (!TargetMapNamesAndLabels.ContainsKey(mapName))
                {
                    continue;
                }
                string mapLabel = TargetMapNamesAndLabels[mapName];
                MapLabelList.Add(mapLabel);
                MapLabelDict[mapLabel.ToUpper()] = null;
            }

            if (tso.UserMapNames.Length > 0)             // get user-specific pathways
            {
                List <string> sa = Csv.SplitCsvString(tso.UserMapNames);
                foreach (string mapName0 in sa)
                {
                    if (!TargetMapNamesAndLabels.ContainsKey(mapName0))
                    {
                        continue;
                    }
                    string mapLabel = TargetMapNamesAndLabels[mapName0];
                    if (MapLabelDict.ContainsKey(mapLabel.ToUpper()))
                    {
                        continue;                                                                   // don't add if already have
                    }
                    MapLabelList.Add(mapLabel);
                    MapLabelDict[mapLabel.ToUpper()] = null;
                    UserMapNames.Add(mapName0);
                }
            }

            Lex.SortList(MapLabelList);

            MapLabelList.Add("None");
            MapLabelList.Add("---------------");
            MapLabelList.Add("Retrieve KEGG Pathway...");             // allow addition of new pathway
            TargetMap.Properties.Items.Clear();
            TargetMap.Properties.Items.AddRange(MapLabelList);

            if (Lex.IsNullOrEmpty(tso.TargetMapName))
            {
                tso.TargetMapName = "General Multi-platform Dendogram";
            }
            SelectedTargetMap = tso.TargetMapName;
            if (String.IsNullOrEmpty(SelectedTargetMap))
            {
                SelectedTargetMap = MapLabelList[0];
            }
            if (TargetMapNamesAndLabels.ContainsKey(SelectedTargetMap))
            {
                SelectedTargetMap = TargetMapNamesAndLabels[SelectedTargetMap];
            }
            TargetMap.Text = SelectedTargetMap;

            Initialized = true;
        }