public override IsobaricResult ReadFromFile(string fileName)
        {
            IsobaricResult result = new IsobaricResult();

            result.PlexType     = IsobaricScanXmlUtils.GetIsobaricType(fileName);
            result.UsedChannels = IsobaricScanXmlUtils.GetUsedChannels(fileName, result.PlexType);
            result.Comments     = IsobaricScanXmlUtils.GetComments(fileName);

            using (var reader = new IsobaricResultXmlFormatReader())
            {
                reader.Progress      = this.Progress;
                reader.ReadReporters = this.HasReporters && result.UsedChannels != null;
                reader.ReadPeaks     = this.ReadPeaks;
                reader.Accept        = this.Accept;

                reader.OpenFile(fileName);
                IsobaricScan item;
                while (null != (item = reader.Next(result.UsedChannels)))
                {
                    result.Add(item);
                }
            }

            return(result);
        }
        private List <IsobaricIndex> GetReferenceFuncs()
        {
            var usedChannels = IsobaricScanXmlUtils.GetUsedChannels(iTraqFile.FullName);
            var result       = refChannels.GetFuncs();

            foreach (var refFunc in result)
            {
                bool bFound = false;
                for (int i = 0; i < usedChannels.Count; i++)
                {
                    if (usedChannels[i].Name.Equals(refFunc.Name))
                    {
                        refFunc.Index = i;
                        bFound        = true;
                        break;
                    }
                }

                if (!bFound)
                {
                    throw new Exception(string.Format("Channel {0} was not used in sample and cannot be used as reference, valid channels are {1}",
                                                      refFunc.Name,
                                                      usedChannels.ConvertAll(l => l.Name).Merge("/")));
                }
            }

            return(result);
        }
        protected IsobaricLabelingExperimentalDesign GetStatisticOption()
        {
            var option = new IsobaricLabelingExperimentalDesign();

            option.DatasetMap   = pnlClassification.GetClassificationSet();
            option.IsobaricFile = iTraqFile.FullName;
            option.References   = GetReferenceFuncs();
            option.PlexType     = IsobaricScanXmlUtils.GetIsobaricType(txtIsobaricXmlFile.Text);

            return(option);
        }
 private void txtXmlFile_TextChanged(object sender, EventArgs e)
 {
     if (File.Exists(txtIsobaricXmlFile.Text))
     {
         try
         {
             refChannels.PlexType = IsobaricScanXmlUtils.GetIsobaricType(txtIsobaricXmlFile.Text);
         }
         catch (Exception ex)
         {
             MessageBox.Show(this, string.Format("Failed to get isobaric type from {0}, error: {1}", txtIsobaricXmlFile.Text, ex.Message));
         }
     }
 }
Exemplo n.º 5
0
        public List <IsobaricIndex> GetSamples()
        {
            var result = new List <IsobaricIndex>();
            var used   = IsobaricScanXmlUtils.GetUsedChannels(this.IsobaricFile);

            for (int i = 0; i < used.Count; i++)
            {
                var channel = used[i];
                if (References.Any(m => m.Name.Equals(channel.Name)))
                {
                    continue;
                }
                result.Add(new IsobaricIndex(used[i].Name, i));
            }

            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 从isobaricFile中读取spectra对应的isobaric labelling信息。
        /// </summary>
        /// <param name="spectra"></param>
        /// <param name="isobaricFile"></param>
        /// <param name="progress"></param>
        public static void Load(List <IIdentifiedSpectrum> spectra, string isobaricFile, bool readPeaks = false, IProgressCallback progress = null)
        {
            if (progress == null)
            {
                progress = new EmptyProgressCallback();
            }

            var fileNames = new HashSet <string>(from s in spectra
                                                 let fs = s.Query.FileScan
                                                          select fs.Experimental + "," + fs.FirstScan.ToString());

            using (var reader = IsobaricResultFileFormatFactory.GetXmlReader(true, readPeaks))
            {
                var usedChannels = IsobaricScanXmlUtils.GetUsedChannels(isobaricFile);

                reader.Open(isobaricFile);

                progress.SetMessage("Reading Isobaric from {0} ...", isobaricFile);
                progress.SetRange(1, spectra.Count);

                foreach (var spectrum in spectra)
                {
                    if (progress.IsCancellationPending())
                    {
                        throw new UserTerminatedException();
                    }

                    progress.Increment(1);

                    var fs = spectrum.Query.FileScan;
                    if (reader.Has(fs.Experimental, fs.FirstScan))
                    {
                        spectrum.SetIsobaricItem(reader.Read(fs.Experimental, fs.FirstScan, usedChannels));
                    }
                    else
                    {
                        spectrum.SetIsobaricItem(null);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public IsobaricScan Next(List <UsedChannel> used)
        {
            Progress.SetPosition(_stream.Position);

            return(IsobaricScanXmlUtils.Parse(_reader, used, ReadReporters, ReadPeaks, Accept, true));
        }
        public IsobaricScan Read(string experimental, int scan, List <UsedChannel> used)
        {
            var xml = ReadXmlBytes(experimental, scan);

            return(IsobaricScanXmlUtils.Parse(xml, used, this.ReadReporters, this.ReadPeaks, this.Accept));
        }