Beispiel #1
0
        // Read Configuration file
        private void InitTest(ConfigFileReader reader)
        {
            // Read program variables
            var config = reader.GetNodes("vars").First();
            var actStr = config.Contents["activationmethod"].ToLower();

            _noiseFiltration = Convert.ToDouble(config.Contents["noisefiltration"]);
            _precursorCharge = Convert.ToInt32(config.Contents["precursorcharge"]);
            _searchWidth = Convert.ToDouble(config.Contents["searchwidth"]);
            _binWidth = Convert.ToDouble(config.Contents["binwidth"]);

            // 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;
        }
Beispiel #2
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        = _defaultToleranceMz;
                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 = _defaultToleranceMz;

            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"];
        }
Beispiel #3
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"];
        }
Beispiel #4
0
        // 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;
        }