private void SetModifications(PhosphoRSInput input)
        {
            _modifications = input.Modifications;

            _aminoAcidModifications = _modifications.Select(
                modification => new AminoAcidModification(
                    modification.Symbol,
                    modification.Name,
                    modification.Abbreviation,
                    modification.NeutralLossAbbreviation,
                    modification.MassDelta,
                    modification.NeutralLoss,
                    AminoAcidSequence.ParseAASequence(modification.TargetAminoAcids)
                    )
                ).ToList();

            _phosphoModification = _aminoAcidModifications
                                   .Where(modification => modification.ID == _options.PhosphorylationSymbol)
                                   .First();

            _phosphoTargetAminoAcids = _phosphoModification.TargetAminoAcids
                                       .Select(a => a.OneLetterCode)
                                       .ToArray();
        }
        private void SetSpectra(PhosphoRSInput input)
        {
            _spectra = input.Spectra;

            _spectrumMap    = new Dictionary <int, Spectrum>();
            _peptideMap     = new Dictionary <int, Peptide>();
            _phosphoSiteMap = new Dictionary <int, List <int> >();

            _items = new List <Tuple <PeptideSpectrumMatch, List <Tuple <int, List <int> > > > >();

            var count = 0;

            foreach (var spectrum in input.Spectra)
            {
                var rank = 0;
                foreach (var peptide in spectrum.IdentifiedPhosphorPeptides)
                {
                    if (_options.MaxHitRank > 0 && rank >= _options.MaxHitRank)
                    {
                        break;
                    }
                    rank += 1;

                    var isoformMap = new List <Tuple <int, List <int> > >();

                    var aas = AminoAcidSequence.Create(
                        peptide.ID,
                        peptide.Sequence,
                        _aminoAcidModifications,
                        peptide.Modification
                        );

                    var psm = new PeptideSpectrumMatch(
                        peptide.ID,
                        spectrum.ActivationType,
                        spectrum.PrecursorCharge,
                        1,
                        spectrum.Peaks.ToArray(),
                        aas
                        );

                    var phosphoCount = peptide.Modification
                                       .Skip(2).SkipLast(2)
                                       .Where(c => c == _options.PhosphorylationSymbol)
                                       .Count();

                    if (phosphoCount == 0)
                    {
                        continue;
                    }

                    var targetSites = peptide.Sequence
                                      .Select((c, i) => _phosphoTargetAminoAcids.Contains(c) ? i : -1)
                                      .Where(i => i >= 0)
                                      .ToList();

                    targetSites.Combinations(phosphoCount).Take(_options.MaxIsoformCount).ForEach(sites =>
                    {
                        var list = sites.ToList();
                        isoformMap.Add(
                            new Tuple <int, List <int> >(
                                count,
                                list
                                )
                            );

                        _spectrumMap.Add(count, spectrum);
                        _peptideMap.Add(count, peptide);
                        _phosphoSiteMap.Add(count, list);
                        count += 1;
                    });

                    _items.Add(Tuple.Create <PeptideSpectrumMatch, List <Tuple <int, List <int> > > >(
                                   psm,
                                   isoformMap
                                   ));
                }
            }
        }
 private void SetOptions(PhosphoRSInput input)
 {
     _options = input.Options;
 }
 public PhosphoRSDataSource(PhosphoRSInput input)
 {
     SetOptions(input);
     SetModifications(input);
     SetSpectra(input);
 }