コード例 #1
0
        public DatabaseSearcherThreadLocalStorage(bool minimize_memory_usage, int psms_length)
        {
            this.num_target_peptides = 0;
            this.num_decoy_peptides = 0;
            this.proteins = 0;

            if (!minimize_memory_usage)
                this.peptides_observed = new Dictionary<FastSubstring, bool>(new LeucineSequenceEqualityComparer());
            else
                this.peptides_observed = null;

            digested_peptides_buf = new FastListOfBoxes<Peptide>(1000);
            modified_peptides_buf = new FastListOfBoxes<Peptide>(1000);
            fixed_modifications_buf = new Dictionary<int, List<Modification>>(1000);
            possible_modifications_buf = new Dictionary<int, List<Modification>>(1000);
            mass_spectra_indices_buf = new List<int>(1000);
            product_masses_buf = new double[1000];
            fast_q_sorter = new FastQSorter();
            psm = new PeptideSpectrumMatch();
            psms = new PeptideSpectrumMatch[psms_length];
        }
コード例 #2
0
ファイル: Peptide.cs プロジェクト: nfillmore/morpheus_speedup
        // This method figures out the variable modifications of the current
        // peptide and stores them in the argument out_peptides. (The
        // out_peptides list is cleared before the new variably modified
        // peptides are added to it.)
        //
        // The variable out_possible_modifications is used for temporary,
        // intermediate storage. We pass in this dictionary instead of
        // allocating a new one inside the method because profiling showed that
        // a large number of dictionaries were allocated by this method.
        // (However, since each dictionary entry is itself a list of
        // modifications, and these are still newly allocated by this method,
        // it isn't clear how much is really saved, in practice, by reusing
        // only the dictionary. Further optimization might be beneficial here.)
        // This dictionary is not useful outside this method, only internally.
        //
        // To be clear: The arguments out_peptides and
        // out_possible_modifications are modified by this method.
        public void GetVariablyModifiedPeptides(IEnumerable<Modification> variableModifications, int maximumVariableModificationIsoforms,
            FastListOfBoxes<Peptide> out_peptides,
            Dictionary<int, List<Modification>> out_possible_modifications)
        {
            out_peptides.Clear();
            out_possible_modifications.Clear();

            foreach(Modification variable_modification in variableModifications)
            {
                if(variable_modification.Type == ModificationType.ProteinNTerminus && (StartResidueNumber == 1 || (StartResidueNumber == 2 && Parent[0] == 'M'))
                    && (variable_modification.AminoAcid == char.MinValue || this[0] == variable_modification.AminoAcid))
                {
                    List<Modification> prot_n_term_variable_mods;
                    if(!out_possible_modifications.TryGetValue(0, out prot_n_term_variable_mods))
                    {
                        prot_n_term_variable_mods = new List<Modification>();
                        prot_n_term_variable_mods.Add(variable_modification);
                        out_possible_modifications.Add(0, prot_n_term_variable_mods);
                    }
                    else
                    {
                        prot_n_term_variable_mods.Add(variable_modification);
                    }
                }

                if(variable_modification.Type == ModificationType.PeptideNTerminus && (variable_modification.AminoAcid == char.MinValue || this[0] == variable_modification.AminoAcid))
                {
                    List<Modification> pep_n_term_variable_mods;
                    if(!out_possible_modifications.TryGetValue(1, out pep_n_term_variable_mods))
                    {
                        pep_n_term_variable_mods = new List<Modification>();
                        pep_n_term_variable_mods.Add(variable_modification);
                        out_possible_modifications.Add(1, pep_n_term_variable_mods);
                    }
                    else
                    {
                        pep_n_term_variable_mods.Add(variable_modification);
                    }
                }

                for(int r = 0; r < Length; r++)
                {
                    if(variable_modification.Type == ModificationType.AminoAcidResidue && this[r] == variable_modification.AminoAcid)
                    {
                        List<Modification> residue_variable_mods;
                        if(!out_possible_modifications.TryGetValue(r + 2, out residue_variable_mods))
                        {
                            residue_variable_mods = new List<Modification>();
                            residue_variable_mods.Add(variable_modification);
                            out_possible_modifications.Add(r + 2, residue_variable_mods);
                        }
                        else
                        {
                            residue_variable_mods.Add(variable_modification);
                        }
                    }
                }

                if(variable_modification.Type == ModificationType.PeptideCTerminus && (variable_modification.AminoAcid == char.MinValue || this[Length - 1] == variable_modification.AminoAcid))
                {
                    List<Modification> pep_c_term_variable_mods;
                    if(!out_possible_modifications.TryGetValue(Length + 2, out pep_c_term_variable_mods))
                    {
                        pep_c_term_variable_mods = new List<Modification>();
                        pep_c_term_variable_mods.Add(variable_modification);
                        out_possible_modifications.Add(Length + 2, pep_c_term_variable_mods);
                    }
                    else
                    {
                        pep_c_term_variable_mods.Add(variable_modification);
                    }
                }

                if(variable_modification.Type == ModificationType.ProteinCTerminus && (EndResidueNumber == Parent.Length - 1)
                    && (variable_modification.AminoAcid == char.MinValue || this[Length - 1] == variable_modification.AminoAcid))
                {
                    List<Modification> prot_c_term_variable_mods;
                    if(!out_possible_modifications.TryGetValue(Length + 3, out prot_c_term_variable_mods))
                    {
                        prot_c_term_variable_mods = new List<Modification>();
                        prot_c_term_variable_mods.Add(variable_modification);
                        out_possible_modifications.Add(Length + 3, prot_c_term_variable_mods);
                    }
                    else
                    {
                        prot_c_term_variable_mods.Add(variable_modification);
                    }
                }
            }

            int variable_modification_isoforms = 0;
            foreach(Dictionary<int, Modification> kvp in GetVariableModificationPatterns(out_possible_modifications))
            {
                Peptide added_peptide = out_peptides.Add();
                added_peptide.CopyFrom(this);
                added_peptide.FixedModifications = FixedModifications;
                added_peptide.VariableModifications = kvp;
                variable_modification_isoforms++;
                if(variable_modification_isoforms == maximumVariableModificationIsoforms)
                {
                    break;
                }
            }
        }