コード例 #1
0
//        private const string DebugFileName = @"C:\Users\wilk011\Documents\DataFiles\TestFolder\debug_HCD_QCShew_Precursor.txt";
        private IEnumerable<SpectrumMatch> InitTest()
        {
            var ionTypeFactory = new IonTypeFactory(_baseIons, _neutralLosses, MaxCharge);

            _ionTypes = ionTypeFactory.GetAllKnownIonTypes().ToList();

            var lcms = new LazyLcMsRun(RawFile, NoiseFiltration, NoiseFiltration);

            var spectrumMatches = (new SpectrumMatchList(lcms, TsvFile, DataFileFormat.IcBottomUp));

            return spectrumMatches;
        }
コード例 #2
0
ファイル: PrecursorFilter.cs プロジェクト: javamng/GitHUB
        public PrecursorFilter(PrecursorOffsets offsets, Tolerance tolerance)
        {
            _offsets = offsets;
            _tolerance = tolerance;

            var maxCharge = offsets.Charge;

            BaseIonType[] baseIons = { BaseIonType.Y };
            NeutralLoss[] neutralLosses = { NeutralLoss.NoLoss };

            var ionTypeFactory = new IonTypeFactory(baseIons, neutralLosses, maxCharge);

            _precursorIonTypes = ionTypeFactory.GetAllKnownIonTypes().ToList();
        }
コード例 #3
0
        public PrecursorOffsetFrequencyTable(double searchWidth, int charge = 1, double binWidth = 1.005)
        {
            _offsetCounts = new Histogram<double>();
            _searchWidth = searchWidth;
            _binWidth = binWidth;
            Charge = charge;
            Total = 0;
            GenerateEdges();
            BaseIonType[] baseIons = { BaseIonType.Y };
            NeutralLoss[] neutralLosses = { NeutralLoss.NoLoss };

            var ionTypeFactory = new IonTypeFactory(baseIons, neutralLosses, charge);

            _precursorIonTypes = ionTypeFactory.GetAllKnownIonTypes().ToList();
        }
コード例 #4
0
        public void ReadConfigurationFile(string configurationFile)
        {
            var reader = new ConfigFileReader(configurationFile);
            // Read program variables
            var config = reader.GetNodes("vars").First();
            PrecursorCharge = Convert.ToInt32(config.Contents["precursorcharge"]);
            PrecursorOffsetThreshold = Convert.ToDouble(config.Contents["precursoroffsetthreshold"]);
            WindowWidth = Convert.ToInt32(config.Contents["searchwidth"]);
            PrecursorOffsetWidth = Convert.ToInt32(config.Contents["precursoroffsetwidth"]);
            RetentionCount = Convert.ToInt32(config.Contents["retentioncount"]);
            RelativeIntensityThreshold = Convert.ToDouble(config.Contents["relativeintensitythreshold"]);
            SelectedIonThreshold = Convert.ToDouble(config.Contents["selectedionthreshold"]);
            MassBinSize = Convert.ToInt32(config.Contents["massbinsize"]);
            var actStr = config.Contents["activationmethod"].ToLower();
            switch (actStr)
            {
                case "hcd":
                    ActivationMethod = ActivationMethod.HCD;
                    Tolerance = _defaultTolerancePpm;
                    break;
                case "cid":
                    ActivationMethod = ActivationMethod.CID;
                    Tolerance = _defaultToleranceTh;
                    break;
                case "etd":
                    ActivationMethod = ActivationMethod.ETD;
                    Tolerance = _defaultTolerancePpm;
                    break;
                default:
                    throw new FormatException("Invalid Activation Method.");
            }

            var acqStr = config.Contents["acquisitionmethod"].ToLower();
            switch (acqStr)
            {
                case "dia":
                    AcquisitionMethod = AcquisitionMethod.Dia;
                    break;
                case "dda":
                    AcquisitionMethod = AcquisitionMethod.Dda;
                    break;
                default:
                    throw new FormatException("Invalid Acquisition Method.");
            }

            MassErrorTolerance = _defaultToleranceTh;

            MaxRanks = Convert.ToInt32(config.Contents["maxranks"]);

            var smoothingRanksStr = config.Contents["smoothingranks"].Split(',');
            SmoothingRanks = new int[smoothingRanksStr.Length];
            var smoothingWindowSizeStr = config.Contents["smoothingwindowsize"].Split(',');
            SmoothingWindowSize = new int[smoothingWindowSizeStr.Length];
            if (SmoothingRanks.Length != SmoothingWindowSize.Length)
                throw new ArgumentException("SmoothingRanks and SmoothingWindowSize unequal lengths.");
            for (int i = 0; i < SmoothingRanks.Length; i++)
            {
                if (smoothingRanksStr[i] == "Max") SmoothingRanks[i] = Int32.MaxValue;
                else SmoothingRanks[i] = Convert.ToInt32(smoothingRanksStr[i]);
                SmoothingWindowSize[i] = Convert.ToInt32(smoothingWindowSizeStr[i]);
            }

            // Read ion data
            var ionInfo = reader.GetNodes("ion").First();
            int totalCharges = Convert.ToInt32(ionInfo.Contents["totalcharges"]);
            var ionTypeStr = ionInfo.Contents["iontype"].Split(',');
            var ions = new BaseIonType[ionTypeStr.Length];
            for (int i = 0; i < ionTypeStr.Length; i++)
            {
                switch (ionTypeStr[i].ToLower())
                {
                    case "a":
                        ions[i] = BaseIonType.A;
                        break;
                    case "b":
                        ions[i] = BaseIonType.B;
                        break;
                    case "c":
                        ions[i] = BaseIonType.C;
                        break;
                    case "x":
                        ions[i] = BaseIonType.X;
                        break;
                    case "y":
                        ions[i] = BaseIonType.Y;
                        break;
                    case "z":
                        ions[i] = BaseIonType.Z;
                        break;
                }
            }
            var ionLossStr = ionInfo.Contents["losses"].Split(',');
            var ionLosses = new NeutralLoss[ionLossStr.Length];
            for (int i = 0; i < ionLossStr.Length; i++)
            {
                switch (ionLossStr[i].ToLower())
                {
                    case "noloss":
                        ionLosses[i] = NeutralLoss.NoLoss;
                        break;
                    case "nh3":
                        ionLosses[i] = NeutralLoss.NH3;
                        break;
                    case "h2o":
                        ionLosses[i] = NeutralLoss.H2O;
                        break;
                }
            }
            _ionTypeFactory = new IonTypeFactory(ions, ionLosses, totalCharges);
            IonTypes = _ionTypeFactory.GetAllKnownIonTypes().ToArray();
            var tempIonList = new List<IonType>();
            if (ionInfo.Contents.ContainsKey("exclusions"))
            {
                var ionExclusions = ionInfo.Contents["exclusions"].Split(',');
                tempIonList.AddRange(IonTypes.Where(ionType => !ionExclusions.Contains(ionType.Name)));
                IonTypes = tempIonList.ToArray();
            }

            // Read input and output file names
            var fileInfo = reader.GetNodes("fileinfo").First();
            DataSets = fileInfo.Contents["name"].Split(',');
            var dataFormat = fileInfo.Contents["format"];
            switch (dataFormat)
            {
                case "mgf":
                    DataFormat = DataFileFormat.Mgf;
                    break;
                case "icbottomup":
                    DataFormat = DataFileFormat.IcBottomUp;
                    break;
                case "dia":
                    DataFormat = DataFileFormat.Dia;
                    break;
                default:
                    throw new FormatException("Invalid Acquisition Method.");
            }

            TsvPath = fileInfo.Contents["tsvpath"];
            DataPath = fileInfo.Contents["datapath"];
            var outPathtemp = fileInfo.Contents["outpath"];
            OutputPath = outPathtemp;

            OutputFileName = OutputPath + fileInfo.Contents["outputfile"];
        }
コード例 #5
0
ファイル: TestUtils.cs プロジェクト: javamng/GitHUB
        public void TestPpmErrorCalculation(string seqText, string rawFilePath, int scanNum)
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            ShowStarting(methodName, rawFilePath);

            var tolerance = new Tolerance(10, ToleranceUnit.Ppm);
            const int maxCharge = 15;
            const double relIntThres = 0.1;

            if (!File.Exists(rawFilePath))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, rawFilePath);
            }

            // init
            var sequence = Sequence.GetSequenceFromMsGfPlusPeptideStr(seqText);
            var lcms = PbfLcMsRun.GetLcMsRun(rawFilePath);
            var spectrum = lcms.GetSpectrum(scanNum);

            var ionTypeFactory = new IonTypeFactory(maxCharge);
            var iontypes = ionTypeFactory.GetAllKnownIonTypes();

            foreach (var iontype in iontypes)
            {
                var ion = iontype.GetIon(sequence.Composition);
                var obsPeaks = spectrum.GetAllIsotopePeaks(ion, tolerance, relIntThres);
                if (obsPeaks == null) continue;
                var isotopes = ion.GetIsotopes(relIntThres).ToArray();
                for (int i = 0; i < isotopes.Length; i++)
                {
                    if (obsPeaks[i] == null) continue;
                    var obsMz = obsPeaks[i].Mz;
                    var theoMz = ion.GetIsotopeMz(isotopes[i].Index);
                    var ppmError = (obsMz - theoMz)/theoMz*1e6;
                    Assert.True(ppmError <= tolerance.GetValue());
                }
            }
        }
コード例 #6
0
ファイル: TestUtils.cs プロジェクト: javamng/GitHUB
        public void TestIonTypeGeneration()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            ShowStarting(methodName);

            var ionTypeFactory = new IonTypeFactory();
            int index = 0;
            foreach (var ionType in ionTypeFactory.GetAllKnownIonTypes())
            {
                Console.WriteLine(++index + ": " + ionType);
            }
            var yIon = ionTypeFactory.GetIonType("y2-H2O");
            Console.WriteLine(yIon.GetMz(0));
        }
コード例 #7
0
ファイル: TestUtils.cs プロジェクト: javamng/GitHUB
        public void TestGetProductIons()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            ShowStarting(methodName);

            var aaSet = new AminoAcidSet(Modification.Carbamidomethylation);
            var sequence = new Sequence("CCAADDKEACFAVEGPK", aaSet);

            var ionTypeFactory = new IonTypeFactory(
                new[] {BaseIonType.B, BaseIonType.Y}, 
                new[] {NeutralLoss.NoLoss, NeutralLoss.H2O}, 
                maxCharge: 2);

            Console.WriteLine("Precursor Ion: {0}\t{1}", sequence.GetPrecursorIon(2).Composition, sequence.GetPrecursorIon(2).GetMonoIsotopicMz());
            Console.WriteLine("Product ions: ");
            var productIons = sequence.GetProductIons(ionTypeFactory.GetAllKnownIonTypes());
            foreach (var theoIon in productIons)
            {
                var ionTypeAndIndex = theoIon.Key;
                var ionType = ionTypeAndIndex.Item1;
                var index = ionTypeAndIndex.Item2;
                var ion = theoIon.Value;
                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", ionType.Name, index, ion.Composition, ion.Charge, ion.GetMonoIsotopicMz());
            }
        }
コード例 #8
0
ファイル: TestIonFrequency.cs プロジェクト: javamng/GitHUB
        // Read Configuration file
        private void InitTest(ConfigFileReader reader)
        {
            // Read program variables
            var config = reader.GetNodes("vars").First();
            _precursorCharge = Convert.ToInt32(config.Contents["precursorcharge"]);
            var actStr = config.Contents["activationmethod"].ToLower();

            _combineCharges = (config.Contents.ContainsKey("combinecharges") &&
                 config.Contents["combinecharges"].ToLower() == "true");

            _useDecoy = (config.Contents.ContainsKey("usedecoy") &&
                config.Contents["usedecoy"].ToLower() == "true");

            _relativeIntensityThreshold = Convert.ToDouble(config.Contents["relativeintensitythreshold"]);

            // Read ion data
            var ionInfo = reader.GetNodes("ion").First();
            int totalCharges = Convert.ToInt32(ionInfo.Contents["totalcharges"]);
            var ionTypeStr = ionInfo.Contents["iontype"].Split(',');
            var ions = new BaseIonType[ionTypeStr.Length];
            for (int i = 0; i < ionTypeStr.Length; i++)
            {
                switch (ionTypeStr[i].ToLower())
                {
                    case "a":
                        ions[i] = BaseIonType.A;
                        break;
                    case "b":
                        ions[i] = BaseIonType.B;
                        break;
                    case "c":
                        ions[i] = BaseIonType.C;
                        break;
                    case "x":
                        ions[i] = BaseIonType.X;
                        break;
                    case "y":
                        ions[i] = BaseIonType.Y;
                        break;
                    case "z":
                        ions[i] = BaseIonType.Z;
                        break;
                }
            }
            var ionLossStr = ionInfo.Contents["losses"].Split(',');
            var ionLosses = new NeutralLoss[ionLossStr.Length];
            for (int i = 0; i < ionLossStr.Length; i++)
            {
                switch (ionLossStr[i].ToLower())
                {
                    case "noloss":
                        ionLosses[i] = NeutralLoss.NoLoss;
                        break;
                    case "nh3":
                        ionLosses[i] = NeutralLoss.NH3;
                        break;
                    case "h2o":
                        ionLosses[i] = NeutralLoss.H2O;
                        break;
                }
            }
            _ionTypeFactory = new IonTypeFactory(ions, ionLosses, totalCharges);
            _ionTypes = _ionTypeFactory.GetAllKnownIonTypes().ToList();
            var tempIonList = new List<IonType>();
            if (ionInfo.Contents.ContainsKey("exclusions"))
            {
                var ionExclusions = ionInfo.Contents["exclusions"].Split(',');
                tempIonList.AddRange(_ionTypes.Where(ionType => !ionExclusions.Contains(ionType.Name)));
                _ionTypes = tempIonList;
            }

            // Read input and output file names
            var fileInfo = reader.GetNodes("fileinfo").First();
            _names = fileInfo.Contents["name"].Split(',');
            _preTsv = fileInfo.Contents["tsvpath"];
            _preRaw = fileInfo.Contents["rawpath"];
            var outPathtemp = fileInfo.Contents["outpath"];
            _outPre = outPathtemp;
            var outFiletemp = fileInfo.Contents["outfile"];
            _outFileName = _outPre + outFiletemp;
        }