Exemplo n.º 1
0
        public override IEnumerable <string> Process(string filename)
        {
            string msLevelFilename = filename + ".msLevel";

            using (IRawFile rawFile = new RawFileImpl(filename))
            {
                using (var sw = new StreamWriter(msLevelFilename))
                {
                    int firstScan = rawFile.GetFirstSpectrumNumber();
                    int lastScan  = rawFile.GetLastSpectrumNumber();
                    Progress.SetRange(rawFile.GetFirstSpectrumNumber(), rawFile.GetLastSpectrumNumber());
                    Progress.SetMessage("Processing " + filename + "...");

                    sw.WriteLine("Scan\tMsLevel");
                    for (int scan = firstScan; scan <= lastScan; scan++)
                    {
                        if (Progress.IsCancellationPending())
                        {
                            throw new UserTerminatedException();
                        }

                        sw.WriteLine(scan + "\t" + rawFile.GetMsLevel(scan));
                        Progress.SetPosition(scan);
                    }

                    Progress.SetPosition(lastScan);
                    Progress.SetMessage("Processing " + filename + " finished.");
                }
            }

            return(new[] { msLevelFilename });
        }
Exemplo n.º 2
0
 public void TestSetup()
 {
   this.fullRawFile = new RawFileImpl();
   this.fullRawFile.Open(@"../../../data/Standard_Protein_FT2_Lock_Re5.RAW");
   this.ms2OnlyRawFile = new RawFileImpl();
   this.ms2OnlyRawFile.Open(@"../../../data/Full_scan_apiginin_ms2.RAW");
 }
Exemplo n.º 3
0
 public Raw2MzXmlMultipleProcessor(RawFileImpl rawFile, bool fullMsOnly, bool doCentroid, string targetDirectoryName,
                                   string dataProcessingSoftware, string dataProcessingSoftwareVersion,
                                   Dictionary <string, string> dataProcessingOperations)
 {
     this.processor = new Raw2MzXmlProcessor(rawFile, fullMsOnly, doCentroid, targetDirectoryName,
                                             dataProcessingSoftware, dataProcessingSoftwareVersion,
                                             dataProcessingOperations);
 }
Exemplo n.º 4
0
        public override IEnumerable <string> Process(string fileName)
        {
            string resultFilename = fileName + ".tic";

            if (ignoreWhenResultExist && File.Exists(resultFilename))
            {
                return(new string[] { resultFilename });
            }

            using (IRawFile reader = new RawFileImpl(fileName))
            {
                Progress.SetMessage(MyConvert.Format("Processing {0} ...", new FileInfo(fileName).Name));

                using (StreamWriter sw = new StreamWriter(resultFilename))
                {
                    sw.WriteLine("Scan\tMode\tPrecursor\tTIC");
                    int firstScan = reader.GetFirstSpectrumNumber();
                    int lastScan  = reader.GetLastSpectrumNumber();

                    Progress.SetRange(firstScan, lastScan);
                    for (int i = firstScan; i <= lastScan; i++)
                    {
                        if (Progress.IsCancellationPending())
                        {
                            sw.Close();
                            File.Delete(resultFilename);

                            throw new UserTerminatedException();
                        }

                        if (1 == reader.GetMsLevel(i))
                        {
                            continue;
                        }

                        PeakList <Peak> pkl       = reader.GetPeakList(i);
                        Peak            precursor = reader.GetPrecursorPeak(i);

                        double tic = (from p in pkl
                                      select p.Intensity).Sum();

                        string mode = reader.GetScanMode(i);
                        sw.WriteLine("{0}\t{1}\t{2:0.0000}\t{3:0.0}", i, mode.ToUpper(), precursor.Mz, tic);

                        Progress.SetPosition(i);
                    }
                    Progress.End();
                }
                Progress.SetMessage(MyConvert.Format("Processing {0} finished.", new FileInfo(fileName).Name));
            }

            return(new string[] { resultFilename });
        }
Exemplo n.º 5
0
 public MzXmlFormat(RawFileImpl rawFile, bool fullMsOnly, bool doCentroid, string targetDirectoryName,
                    string dataProcessingSoftware, string dataProcessingSoftwareVersion,
                    Dictionary <string, string> dataProcessingOperations)
 {
     this.rawFile    = rawFile;
     this.fullMsOnly = fullMsOnly;
     this.doCentroid = doCentroid;
     if (null == targetDirectoryName || 0 == targetDirectoryName.Length)
     {
         this.saveToSourceDirectory = true;
     }
     else
     {
         this.saveToSourceDirectory = false;
         this.targetDirectory       = new DirectoryInfo(targetDirectoryName);
         if (!this.targetDirectory.Exists)
         {
             this.targetDirectory.Create();
         }
     }
     this.dataProcessingSoftware        = dataProcessingSoftware;
     this.dataProcessingSoftwareVersion = dataProcessingSoftwareVersion;
     this.dataProcessingOperations      = dataProcessingOperations;
 }
        public override IEnumerable <string> Process(string fileName)
        {
            SequestResultTextFormat format = new SequestResultTextFormat();

            IIdentifiedResult sr = format.ReadFromFile(fileName);

            Dictionary <string, HashSet <IIdentifiedSpectrum> > peptideMap = sr.GetExperimentalPeptideMap();

            Dictionary <IIdentifiedSpectrum, int> confused = new Dictionary <IIdentifiedSpectrum, int>();
            List <IIdentifiedSpectrum>            wrongMs2 = new List <IIdentifiedSpectrum>();
            List <IIdentifiedSpectrum>            wrongMs3 = new List <IIdentifiedSpectrum>();

            int pepcount = 0;

            List <string> exps = new List <string>(peptideMap.Keys);

            exps.Sort();
            foreach (string exp in exps)
            {
                Console.Out.WriteLine(exp);

                HashSet <IIdentifiedSpectrum> peps = peptideMap[exp];
                pepcount += peps.Count;
                using (IRawFile rawFile = new RawFileImpl(expRawMap[exp]))
                {
                    foreach (IIdentifiedSpectrum pep in peps)
                    {
                        int msLevel = rawFile.GetMsLevel(pep.Query.FileScan.FirstScan);

                        bool bMs2 = ms2seqPattern.Match(pep.Sequence).Success;
                        bool bMs3 = ms3seqPattern.Match(pep.Sequence).Success;

                        if (bMs2 && bMs3)
                        {
                            confused[pep] = msLevel;
                            continue;
                        }

                        if (bMs3)
                        {
                            if (msLevel != 3)
                            {
                                wrongMs3.Add(pep);
                                continue;
                            }
                        }
                        else if (bMs2)
                        {
                            if (msLevel != 2)
                            {
                                wrongMs2.Add(pep);
                                continue;
                            }
                        }
                    }
                }
            }

            string incorrectFilename = FileUtils.ChangeExtension(fileName, ".incorrect.peptides.txt");

            using (StreamWriter sw = new StreamWriter(incorrectFilename))
            {
                sw.WriteLine("Type\tFilename\tSequence\tScore\tDeltaScore\tmsLevel");
                foreach (IIdentifiedSpectrum pep in confused.Keys)
                {
                    sw.WriteLine(MyConvert.Format("Confused\t{0}\t{1}\t{2:0.00}\t{3:0.00}\t{4}",
                                                  pep.Query.FileScan.LongFileName,
                                                  pep.Sequence,
                                                  pep.Score,
                                                  pep.DeltaScore,
                                                  confused[pep]));
                }

                foreach (IIdentifiedSpectrum pep in wrongMs2)
                {
                    sw.WriteLine(MyConvert.Format("WrongMS2\t{0}\t{1}\t{2:0.00}\t{3:0.00}\t3",
                                                  pep.Query.FileScan.LongFileName,
                                                  pep.Sequence,
                                                  pep.Score,
                                                  pep.DeltaScore));
                }

                foreach (IIdentifiedSpectrum pep in wrongMs3)
                {
                    sw.WriteLine(MyConvert.Format("WrongMS3\t{0}\t{1}\t{2:0.00}\t{3:0.00}\t2",
                                                  pep.Query.FileScan.LongFileName,
                                                  pep.Sequence,
                                                  pep.Score,
                                                  pep.DeltaScore));
                }

                sw.WriteLine();
                sw.WriteLine("Total\t" + pepcount);
                sw.WriteLine("Confused\t" + confused.Count);
                sw.WriteLine("WrongMs2\t" + wrongMs2.Count);
                sw.WriteLine("WrongMs3\t" + wrongMs3.Count);
            }

            List <string> incorrectDtafilenames = new List <string>();

            foreach (IIdentifiedSpectrum pep in confused.Keys)
            {
                incorrectDtafilenames.Add(pep.Query.FileScan.LongFileName);
            }
            foreach (IIdentifiedSpectrum pep in wrongMs2)
            {
                incorrectDtafilenames.Add(pep.Query.FileScan.LongFileName);
            }
            foreach (IIdentifiedSpectrum pep in wrongMs3)
            {
                incorrectDtafilenames.Add(pep.Query.FileScan.LongFileName);
            }

            for (int i = sr.Count - 1; i >= 0; i--)
            {
                foreach (IIdentifiedProtein sp in sr[i])
                {
                    for (int j = sp.Peptides.Count - 1; j >= 0; j--)
                    {
                        if (incorrectDtafilenames.Contains(sp.Peptides[j].Spectrum.Query.FileScan.Experimental))
                        {
                            sp.Peptides.RemoveAt(j);
                        }
                    }
                }

                if (sr[i][0].Peptides.Count == 0)
                {
                    sr.RemoveAt(i);
                }
            }

            string correctFilename = FileUtils.ChangeExtension(fileName, ".correct.txt");

            //BuildSummaryResultUtils.Write(correctFilename, cr);
            return(new[] { correctFilename });
        }