Beispiel #1
0
 public static double GetPValue(PSM psm, Tolerance prod_tolerance, double cutoff)
 {
     // Get the width of the product ion tolerance at the isolation mz;
     double productToleranceWidth = prod_tolerance.GetRange(psm.IsolationMZ).Width;
     double cutoffThreshold = psm.Spectrum.GetBasePeakIntensity()*cutoff;
     return Math.Min(1.0, psm.Spectrum.Count(peak => peak.Intensity >= cutoffThreshold)*2*productToleranceWidth/psm.ScanWidth);
 }
Beispiel #2
0
 public Lotor(string rawFileDirectory, string inputcsvFile, string outputDirectory, List<Modification> fixedModifications, List<Modification> quantifiedModifications, Tolerance prod_Tolerance, int scoreCutoff, bool separateGroups, double productThreshold,bool ignoreCTerminal,bool reduceSites, FragmentTypes fragType, bool phosphoNeutralLoss = false)
 {
     _rawFileDirectory = rawFileDirectory;
     _csvFile = inputcsvFile;
     _outputDirectory = outputDirectory;
     _fixedModifications = fixedModifications;
     FixedModifications = fixedModifications.OfType<IMass>().ToList();
     QuantifiedModifications = quantifiedModifications;
     _prodTolerance = prod_Tolerance;
     _deltaScoreCutoff = scoreCutoff;
     _separateProteinGroups = separateGroups;
     _productThreshold = productThreshold;
     _fragType = fragType;
     _ignoreCTerminal = ignoreCTerminal;
     _reduceSites = reduceSites;
     //LocalizedHit.AScoreThreshold = ascore_threshold;
     LocalizedHit.ScoreThreshold = scoreCutoff;
     _phosphoNeutralLoss = phosphoNeutralLoss;
 }
Beispiel #3
0
        public TagQuant(string outputDirectory, string rawFileDirectory, IEnumerable<string> inputFiles,
            IEnumerable<TagInformation> tags, Tolerance itTolerance, Tolerance ftTolerance, bool isMS3Quant = false,
            int etdQuantPosition = 0, bool nosiebasecap = false, bool isETDQuantified = true, bool calculatePurity = false)
        {
            RawFileDirectory = rawFileDirectory;
            OutputDirectory = outputDirectory;
            UsedTags = new SortedList<double, TagInformation>(tags.ToDictionary(t => t.MassCAD));
            InputFiles = inputFiles.ToList();
            NoisebandCap = nosiebasecap;
            DontQuantifyETD = isETDQuantified;
            MS3Quant = isMS3Quant;
            CalculatePurity = calculatePurity;

            ItMassTolerance = itTolerance;
            FtMassTolerance = ftTolerance;
            ETDQuantPosition = etdQuantPosition;

            logWriter = new StreamWriter(Path.Combine(outputDirectory, "tagquant_log.txt"));
            logWriter.AutoFlush = true;

            RawFiles =
                Directory.EnumerateFiles(rawFileDirectory, "*.raw")
                    .ToDictionary(file => Path.GetFileNameWithoutExtension(file), file => new ThermoRawFile(file));
        }
Beispiel #4
0
        private List<LocalizedHit> CalculateBestIsoforms(List<PSM> psms, FragmentTypes fragType, Tolerance prod_tolerance, double productThreshold, bool phosphoNeutralLosses)
        {
            Log("Localizing Best Isoforms...");
            int totalisofromscount = 0;
            int count = 0;
            int psm_count = 0;
            int localized_psm = 0;
            List<LocalizedHit> hits = new List<LocalizedHit>();
            foreach (PSM psm in psms)
            {
                psm_count++;
                count++;

                // Generate all the isoforms for the PSM
                int isoformCount = psm.GenerateIsoforms(_ignoreCTerminal);

                if(isoformCount == 0)
                    continue;

                totalisofromscount += isoformCount;

                // Calculate the probability of success for random matches
                //double pvalue = GetPValue(psm, prod_tolerance, productThreshold);

                // Match all the isoforms to the spectrum and log the results
                psm.MatchIsofroms(fragType, prod_tolerance, productThreshold, phosphoNeutralLosses, 1);

                // Perform the localization for all combinations of isoforms
                //double[,] res = psm.Calc(pvalue);

                Tuple<int, int, double> scores = LocalizedIsoformSimple(psm);

                // Check if the localization is above some threshold
                //Tuple<int, int, double> scores = LocalizedIsoform(res);
                int bestIsoform = scores.Item1;
                int secondBestIsoform = scores.Item2;
                double ascore = scores.Item3;
                //int numSDFs = psm.NumSiteDeterminingFragments[bestIsoform, secondBestIsoform];

                List<PeptideIsoform> isoforms = psm.PeptideIsoforms.ToList();
                //LocalizedHit hit = new LocalizedHit(psm, isoforms[bestIsoform], isoforms[secondBestIsoform], numSDFs,
                //    psm.BestSiteDeterminingFragments[bestIsoform, secondBestIsoform],
                //    psm.BestSiteDeterminingFragments[secondBestIsoform, bestIsoform], pvalue, ascore);

                LocalizedHit hit = new LocalizedHit(psm, isoforms[bestIsoform], isoforms[secondBestIsoform], 0,
                   0,
                   0, 0, ascore);
                hits.Add(hit);
                if (hit.IsLocalized)
                {
                    localized_psm++;
                }

                psm.PeptideIsoforms.Clear();

                // Progress Bar Stuff
                if (count <= 50)
                    continue;
                count = 0;
                ProgressUpdate((double)psm_count / psms.Count);
            }
            ProgressUpdate(1.0);
            Log(string.Format("Total Number of Possible Isoforms Considered: {0:N0}",totalisofromscount));
            Log(string.Format("Total Number of PSMs Considered: {0:N0}", psm_count));
            Log(string.Format("Total Number of PSMs Localized: {0:N0} ({1:00.00}%)", localized_psm, localized_psm * 100 / psm_count));
            ProgressUpdate(0);
            return hits;
        }
Beispiel #5
0
 /// <summary>
 /// Creates a range around some mean value with a specified tolerance.
 /// <para>
 /// i.e. 10 ppm at 500 would give you 499.9975 - 500.0025
 /// which has a width of 0.005. Converting back to ppm
 /// (1e6) *0.005 / 500 = 10 ppm.
 /// </para>
 /// <para>
 /// The difference from the mean value to an boundary is exactly
 /// half the tolerance you specified
 /// </para>
 /// </summary>
 /// <param name="mean">The mean value for the range</param>
 /// <param name="tolerance">The tolerance range</param>
 public DoubleRange(double mean, Tolerance tolerance)
 {
     SetTolerance(mean, tolerance);
 }
Beispiel #6
0
 public void MatchIsofroms(FragmentTypes type, Tolerance tolerance, double cutoffThreshold, bool phopshoNeutralLoss, params int[] chargeStates)
 {
     foreach (PeptideIsoform isoform in PeptideIsoforms)
     {
         isoform.MatchSpectrum(type, tolerance, cutoffThreshold,phopshoNeutralLoss, chargeStates);
     }
 }