Пример #1
0
 private void DoCompoundChanged(CompoundItem compound)
 {
     if (compoundInList != compound)
     {
         compoundInList = compound;
         currentItems   = GetFileItems(compound);;
         gvFiles.Rows.Clear();
         gvFiles.RowCount = currentItems.Count;
     }
 }
        private void gvCompounds_SelectionChanged(object sender, EventArgs e)
        {
            if (gvCompounds.SelectedRows.Count == 0)
            {
                return;
            }

            currentCompound = visibleCompounds[gvCompounds.SelectedRows[0].Index];

            DoCompoundChanged();
        }
Пример #3
0
        public void ExportCompound(string filename, bool removeDecoy, bool validOnly)
        {
            using (StreamWriter sw = new StreamWriter(filename))
            {
                sw.Write("ObjectName,CompoundFormula,LightMz,HeavyMz,Enabled");
                var filenames = (from pr in allFiles.Items
                                 orderby pr.PairedResult.PureFileName
                                 select pr.PairedResult.PureFileName).Distinct().ToList();
                filenames.ForEach(m => sw.Write(",{0}_Ratio,{0}_SD,{0}_ValidTransCount", m));
                sw.WriteLine();

                for (int i = 0; i < lvPeptides.Items.Count; i++)
                {
                    if (validOnly && !lvPeptides.GetItemChecked(i))
                    {
                        continue;
                    }

                    CompoundItem item = lvPeptides.Items[i] as CompoundItem;
                    if (removeDecoy && item.IsDecoy)
                    {
                        continue;
                    }

                    sw.Write("{0},{1},{2:0.0000},{3:0.0000},{4}", item.ObjectName, item.PrecursurFormula, item.LightMz, item.HeavyMz, lvPeptides.GetItemChecked(i));
                    foreach (var file in filenames)
                    {
                        var pep = (from t in item.TransitionItems
                                   from m in t.FileItems
                                   where m.PairedResult.PureFileName.Equals(file)
                                   select m.PairedPeptide).FirstOrDefault();
                        if (pep == null || pep.Ratio == -1)
                        {
                            sw.Write(",#N/A,0,0");
                        }
                        else
                        {
                            var transCount = pep.ProductIonPairs.Count(m => m.Enabled);
                            if (double.IsNaN(pep.SD) || double.IsInfinity(pep.SD))
                            {
                                sw.Write(",{0:0.0000},0,{1}", pep.Ratio, transCount);
                            }
                            else
                            {
                                sw.Write(",{0:0.0000},{1:0.0000},{2}", pep.Ratio, pep.SD, transCount);
                            }
                        }
                    }
                    sw.WriteLine();
                }
            }
        }
        public void BuildList()
        {
            _compounds = new List <CompoundItem>();

            foreach (var m in Items)
            {
                CompoundItem citem = null;
                foreach (var c in _compounds)
                {
                    if (IsSameCompound(c, m))
                    {
                        citem = c;
                        break;
                    }
                }

                if (citem == null)
                {
                    citem = new CompoundItem();
                    AssignSrmFileItemTo(m, citem);
                    _compounds.Add(citem);
                }

                TransitionItem titem = null;
                foreach (var t in citem.TransitionItems)
                {
                    if (t.TransitionEquals(m, this.MzTolerance))
                    {
                        titem = t;
                        break;
                    }
                }

                if (titem == null)
                {
                    titem = new TransitionItem();
                    AssignSrmFileItemTo(m, titem);
                    citem.TransitionItems.Add(titem);
                }

                titem.FileItems.Add(m);
            }

            var fileNames = GetFileNames();

            _compounds.ForEach(m => m.InitializeFileItems(fileNames));
            _compounds.Sort((m1, m2) => m1.ToString().CompareTo(m2.ToString()));
            _compounds.ForEach(m => m.TransitionItems.Sort((n1, n2) => n1.LightMz.CompareTo(n2.LightMz)));
        }
Пример #5
0
        private List <FileItems> GetFileItems(CompoundItem compound)
        {
            List <FileItems> tmpItems = new List <FileItems>();

            foreach (var titem in compound.TransitionItems)
            {
                var item = new FileItems();
                item.Precursor = GetString(titem);
                item.Items     = new List <SrmFileItem>();

                for (int i = FirstProductIonColumn; i < gvFiles.Columns.Count; i++)
                {
                    var fileitem = titem.FileItems.Find(m => m.PairedResult.PureFileName.Equals(gvFiles.Columns[i].Name));
                    item.Items.Add(fileitem);
                }

                tmpItems.Add(item);
            }
            return(tmpItems);
        }
Пример #6
0
        public void ExportTransition(string filename, bool removeDecoy, bool validOnly)
        {
            using (StreamWriter sw = new StreamWriter(filename))
            {
                sw.Write("ObjectName,CompoundFormula,LightPrecursorMz,LightProductIon,HeavyPrecursorMz,HeavyProductIon,Enabled");
                var filenames = (from pr in allFiles.Items
                                 orderby pr.PairedResult.PureFileName
                                 select pr.PairedResult.PureFileName).Distinct().ToList();
                filenames.ForEach(m => sw.Write(",{0}_Ratio,{0}_R2,{0}_LightArea,{0}_HeavyArea,{0}_ValidScanCount", m));
                sw.WriteLine();

                for (int i = 0; i < lvPeptides.Items.Count; i++)
                {
                    if (validOnly && !lvPeptides.GetItemChecked(i))
                    {
                        continue;
                    }

                    CompoundItem item = lvPeptides.Items[i] as CompoundItem;
                    if (removeDecoy && item.IsDecoy)
                    {
                        continue;
                    }

                    var fileitems = GetFileItems(item);

                    foreach (var fitem in fileitems)
                    {
                        if (validOnly && !fitem.Enabled)
                        {
                            continue;
                        }
                        var product = (from f in fitem.Items
                                       where f != null
                                       select f).First().PairedProductIon;

                        sw.Write("{0},{1},{2:0.0000},{3:0.0000},{4:0.0000},{5:0.0000},{6}", item.ObjectName, item.PrecursurFormula, item.LightMz, product.LightProductIon, item.HeavyMz, product.HeavyProductIon, fitem.Enabled);
                        foreach (var file in filenames)
                        {
                            var pep = (from t in fitem.Items
                                       where t.PairedResult.PureFileName.Equals(file)
                                       select t.PairedProductIon).FirstOrDefault();
                            if (pep == null || pep.Ratio == -1)
                            {
                                sw.Write(",#N/A,0,#N/A,#N/A,0");
                            }
                            else
                            {
                                var scanCount = pep.EnabledScanCount;
                                if (double.IsNaN(pep.RegressionCorrelation) || double.IsInfinity(pep.RegressionCorrelation))
                                {
                                    sw.Write(",{0:0.0000},0,{1:0.0},{2:0.0},{3}", pep.Ratio, pep.LightArea, pep.HeavyArea, scanCount);
                                }
                                else
                                {
                                    sw.Write(",{0:0.0000},{1:0.0000},{2:0.0},{3:0.0},{4}", pep.Ratio, pep.RegressionCorrelation, pep.LightArea, pep.HeavyArea, scanCount);
                                }
                            }
                        }
                        sw.WriteLine();
                    }
                }
            }
        }
 public static bool AlwaysFalse(CompoundItem item)
 {
     return(false);
 }
 public static bool IsInvalid(CompoundItem item)
 {
     return(!item.Enabled);
 }
 public static bool IsDecoy(CompoundItem item)
 {
     return(item.IsDecoy);
 }