Exemplo n.º 1
0
        /// <summary>
        /// Get possible ions for <paramref name="sequence"/>
        /// </summary>
        /// <param name="sequence"></param>
        /// <returns></returns>
        public IEnumerable <Ion> GetPossibleIons(Sequence sequence)
        {
            var cutComposition  = sequence.Composition;
            var terminalResidue = IsPrefixIon ? sequence[sequence.Count - 1] : sequence[0];

            return(BaseIonType.GetPossibleCompositions(terminalResidue)
                   .Select(offsetComposition => cutComposition + offsetComposition - NeutralLoss.Composition)
                   .Select(comp => new Ion(comp, Charge)));
        }
Exemplo n.º 2
0
        static BaseIonType()
        {
            // For A, B, C, X, Y, Z ions: sum of all amino acids + offset
            A  = new BaseIonType("a", true, new Composition(-1, 0, 0, -1, 0)); // -CO
            Ar = new BaseIonType("a.", true, A.OffsetComposition + Composition.Hydrogen);
            B  = new BaseIonType("b", true, Composition.Zero);
            C  = new BaseIonType("c", true, Composition.NH3);

            //X = new BaseIonType("x", false, Composition.H2O + Composition.CO);
            X   = new BaseIonType("x", false, new CompositionWithDeltaMass(44.9977) - Composition.Hydrogen);
            Xr  = new BaseIonType("x.", false, X.OffsetComposition + Composition.Hydrogen);
            Y   = new BaseIonType("y", false, Composition.H2O);
            YM1 = new BaseIonType("y-1", false, Y.OffsetComposition - Composition.Hydrogen);

            Z  = new BaseIonType("z", false, Composition.H2O - Composition.NH2);
            Zr = new BaseIonType("z.", false, Z.OffsetComposition + Composition.Hydrogen);

            var aminoAcidSet = new AminoAcidSet();

            // D ions have additional options for isoleucine and threonine. All offsets defined as sum of previous residues + offset.
            var dIonOffsets = new Dictionary <char, double[]>
            {                                                                                                 // Defined in terms of sum of previous residue weights + offset
                { '*', new [] { 44.0500 - Composition.Hydrogen.Mass } },                                      // For all residues except for V, I and T
                { 'V', new [] { 58.0657 - Composition.Hydrogen.Mass } },
                { 'I', new [] { 58.0657 - Composition.Hydrogen.Mass, 72.0813 - Composition.Hydrogen.Mass } }, // for isoleucine
                { 'T', new [] { 58.0657 - Composition.Hydrogen.Mass, 60.0450 - Composition.Hydrogen.Mass } }  // for threonine
            };

            D = new BaseIonType("d", true, new CompositionWithDeltaMass(44.0500), aminoAcid => DefaultCompositionCalculator(dIonOffsets, aminoAcid));

            // V only has one option for all terminal residues. Sum of previous residues + offset
            V = new BaseIonType("v", false, new CompositionWithDeltaMass(74.0242), r => new List <Composition> {
                r == null ? new CompositionWithDeltaMass(74.0242) : new CompositionWithDeltaMass(74.0242) - r.Composition - Composition.Hydrogen
            });

            // W ions have additional options for isoleucine and threonine. All offsets defined as sum of previous residues + offset.
            var wIonOffsets = new Dictionary <char, double[]>
            {                                                                                                                                       // Defined in terms of sum of previous residue weights + offset
                { '*', new [] { 73.0290 - Composition.Hydrogen.Mass } },                                                                            // For all residues except for V, I and T
                { 'V', new [] { 87.0446 - Composition.Hydrogen.Mass } },
                { 'I', new [] { 87.0446 - Composition.Hydrogen.Mass, aminoAcidSet.GetAminoAcid('I').Mass - 12.0238 - Composition.Hydrogen.Mass } }, // for isoleucine
                { 'T', new [] { 87.0446 - Composition.Hydrogen.Mass, aminoAcidSet.GetAminoAcid('T').Mass - 12.0238 - Composition.Hydrogen.Mass } }  // for threonine
            };

            W = new BaseIonType("w", false, new CompositionWithDeltaMass(73.0290), aminoAcid => DefaultCompositionCalculator(wIonOffsets, aminoAcid));

            AllBaseIonTypes = new List <BaseIonType> {
                A, Ar, B, C, D, V, W, X, Xr, Y, YM1, Z, Zr
            };
        }
Exemplo n.º 3
0
        private readonly double _offsetMass;    // duplication but stored for performance

        internal IonType(
            string name,
            Composition.Composition offsetComposition,
            int charge,
            BaseIonType baseIonType,
            NeutralLoss neutralLoss
            )
        {
            Name              = name;
            _offsetMass       = offsetComposition.Mass;
            OffsetComposition = offsetComposition;
            Charge            = charge;
            IsPrefixIon       = baseIonType.IsPrefix;
            BaseIonType       = baseIonType;
            NeutralLoss       = neutralLoss;
        }
Exemplo n.º 4
0
        private readonly double _offsetMass;    // duplication but stored for performance

        internal IonType(
            string name, 
            Composition.Composition offsetComposition,
            int charge, 
            BaseIonType baseIonType,
            NeutralLoss neutralLoss
            )
        {
            Name = name;
            _offsetMass = offsetComposition.Mass;
            OffsetComposition = offsetComposition;
            Charge = charge;
            IsPrefixIon = baseIonType.IsPrefix;
            BaseIonType = baseIonType;
            NeutralLoss = neutralLoss;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get ion type according to the parameters
        /// </summary>
        /// <param name="baseIonType"></param>
        /// <param name="charge"></param>
        /// <param name="neutralLoss"></param>
        /// <returns></returns>
        public IonType GetIonType(BaseIonType baseIonType, int charge, NeutralLoss neutralLoss)
        {
            var ionTypeName = string.Format("{0}{1}{2}", baseIonType.Symbol, charge, neutralLoss.Name);

            return(_ionTypeMap[ionTypeName]);
        }
Exemplo n.º 6
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"];
        }
Exemplo n.º 7
0
 public int GetIonTypeIndex(BaseIonType ionType)
 {
     return GetIonTypeIndex(ionType.IsPrefix);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Get possible ions for <paramref name="cutComposition"/> and <paramref name="terminalResidue"/>
 /// </summary>
 /// <param name="cutComposition"></param>
 /// <param name="terminalResidue"></param>
 /// <returns></returns>
 public IEnumerable <Ion> GetPossibleIons(Composition.Composition cutComposition, AminoAcid terminalResidue)
 {
     return(BaseIonType.GetPossibleCompositions(terminalResidue)
            .Select(offsetComposition => cutComposition + offsetComposition - NeutralLoss.Composition)
            .Select(comp => new Ion(comp, Charge)));
 }
Exemplo n.º 9
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;
        }
 private static double GetScore(BaseIonType baseIonType, double fitScore, double intensity)
 {
     if (intensity < 0) return -1;
     return 0;
 }