public List <string> DigestSequence(string sequence, Enzyme enzyme, int minPepLength) { List <string> peptides = new List <string>(); //Get the cleavage sites List <int> pos = new List <int>() { 0 }; pos.AddRange(FindDigestionPositions(sequence, enzyme)); if (!pos.Contains(sequence.Length)) { pos.Add(sequence.Length); } string peptide = ""; for (int i = 0; i < pos.Count - 1; i++) { string peptideTmp = sequence.Substring(pos[i], pos[i + 1] - pos[i]); peptide += peptideTmp; if (peptide.Length >= minPepLength) { peptides.Add(peptide); Console.WriteLine(peptide); peptide = ""; } } return(peptides); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Kod,Hacim")] Enzyme enzyme) { if (id != enzyme.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(enzyme); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EnzymeExists(enzyme.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(enzyme)); }
private void Awake() { enzyme = Instantiate(enzymePrefab, transform).GetComponent <Enzyme>(); enzyme.transform.SetAsFirstSibling(); eventSystem = EventSystem.current.GetComponent <EventSystem>(); }
public void MakeEnzyme(Enzyme e) { SetPosition(); Enzyme ce = Instantiate(enzPrefab, transform).GetComponent <Enzyme>(); ce.transform.localPosition = new Vector2(ce.transform.localPosition.x, 110f); ce.SetColor(e.color); ce.SetName(e.enzymeName); }
// N.B. leaving this level of indirection in place as it will be useful in speeding up the Unique Peptides dialog /// <summary> /// Examine the background proteome for uniqueness information about the peptides of interest /// </summary> /// <param name="peptidesOfInterest">this is a dict instead of a list only because upstream callers have already prepared this, which can be large and expensive to construct</param> /// <param name="enzyme">how we digest</param> /// <param name="settings">details like max missed cleavages</param> /// <param name="progressMonitor">cancellation checker</param> /// <returns></returns> public Dictionary <string, DigestionPeptideStatsDetailed> GetPeptidesAppearances( Dictionary <Target, bool> peptidesOfInterest, Enzyme enzyme, PeptideSettings settings, SrmSettingsChangeMonitor progressMonitor) { if (string.IsNullOrEmpty(DatabasePath)) { return(null); } var results = peptidesOfInterest.ToDictionary(pep => pep.Key.Sequence, pep => new DigestionPeptideStatsDetailed()); if (results.Count == 0) { return(results); } var protease = new ProteaseImpl(enzyme); var maxPeptideLength = peptidesOfInterest.Max(p => p.Key.Sequence.Length); // No interest in any peptide longer than the longest one of interest const int DIGEST_CHUNKSIZE = 1000; // Check for cancel every N proteins var proteinCount = 0; using (var proteomeDb = OpenProteomeDb()) { var goal = Math.Max(proteomeDb.GetProteinCount(), 1); var batchCount = 0; var minimalProteinInfos = new ProteomeDb.MinimalProteinInfo[DIGEST_CHUNKSIZE]; foreach (var minimalProteinInfo in proteomeDb.GetMinimalProteinInfo()) // Get list of sequence, proteinID, gene, species from the protdb file { minimalProteinInfos[batchCount++] = minimalProteinInfo; var pct = Math.Max(1, 100 * proteinCount++ / goal); // Show at least a little progressat start to give user hope if (batchCount == 0 && !UpdateProgressAndCheckForCancellation(progressMonitor, pct)) { return(null); } else if (((minimalProteinInfo == null) && --batchCount > 0) || batchCount == DIGEST_CHUNKSIZE) { ParallelEx.For(0, batchCount, ii => { var protein = minimalProteinInfos[ii]; foreach (var peptide in protease.DigestSequence(protein.Sequence, settings.DigestSettings.MaxMissedCleavages, maxPeptideLength)) { DigestionPeptideStatsDetailed appearances; if (results.TryGetValue(peptide.Sequence, out appearances)) { lock (appearances) { appearances.Proteins.Add(protein.Id); appearances.Genes.Add(protein.Gene); // HashSet eliminates duplicates appearances.Species.Add(protein.Species); // HashSet eliminates duplicates } } } }); batchCount = 0; } } } return(results); }
public Digestion Digest(Enzyme enzyme, DigestSettings digestSettings, ILoadMonitor loader) { IProgressStatus progressStatus = new ProgressStatus(string.Format(Resources.BackgroundProteomeSpec_Digest_Digesting__0__, enzyme.Name)); loader.UpdateProgress(progressStatus); using (var proteomeDb = OpenProteomeDb()) { return(proteomeDb.Digest(new ProteaseImpl(enzyme), digestSettings.MaxMissedCleavages, loader, ref progressStatus)); } }
public ImportFastaSettings(Enzyme enzyme, int maxMissedCleavages, string fastaFile, string fastaText, string decoyGenerationMethod, double?numDecoys, bool autoTrain) { Enzyme = enzyme; MaxMissedCleavages = maxMissedCleavages; FastaFile = AuditLogPath.Create(fastaFile); FastaText = fastaText; DecoyGenerationMethod = decoyGenerationMethod; NumDecoys = numDecoys; AutoTrain = autoTrain; }
public async Task <IActionResult> Create([Bind("Id,Kod,Hacim")] Enzyme enzyme) { if (ModelState.IsValid) { _context.Add(enzyme); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(enzyme)); }
/// <summary> /// Not working well /// </summary> /// <param name="sequence"></param> /// <param name="enzyme"></param> /// <param name="noEnzymaticTermini"></param> /// <param name="allowedMisscleavages"></param> /// <param name="minPepLength"></param> /// <returns></returns> public List <string> DigestSequenceAllPossibilities(string sequence, Enzyme enzyme, int noEnzymaticTermini, int allowedMisscleavages, int minPepLength) { //Get the cleavage sites List <int> pos = new List <int>() { 0 }; pos.AddRange(FindDigestionPositions(sequence, enzyme)); if (!pos.Contains(sequence.Length)) { pos.Add(sequence.Length); } List <string> peptides = new List <string>(50); //First Lets Generate the ones with two enzymatic termini for (int i = 0; i < pos.Count; i++) { for (int j = i + 1; j <= i + allowedMisscleavages + 1; j++) { if (j >= pos.Count) { continue; } int length = pos[j] - pos[i]; if (length >= minPepLength) { if (noEnzymaticTermini == 2) { peptides.Add(sequence.Substring(pos[i], length)); } else if (noEnzymaticTermini == 1) { string peptide = sequence.Substring(pos[i], length); string reversePeptide = ReverseString(peptide); for (int k = minPepLength; k <= peptide.Length; k++) { peptides.Add(peptide.Substring(0, k)); peptides.Add(reversePeptide.Substring(0, k)); } } } } } peptides = peptides.Distinct().ToList(); return(peptides); }
/// <summary> /// Create the decoy version of this databse /// </summary> /// <param name="enzyme"></param> /// <param name="shuffle"></param> public void CreateDecoyDatabase(Enzyme enzyme, bool shuffle) { var reader = new FastaFileReader(); if (!reader.OpenFile(_databaseFilePath)) { return; } var decoyDatabaseFileName = GetDecoyDatabasePath(enzyme, shuffle); Console.WriteLine("Creating " + decoyDatabaseFileName); using (var decoyWriter = new StreamWriter(decoyDatabaseFileName)) { while (reader.ReadNextProteinEntry()) { var name = reader.ProteinName; var description = reader.ProteinDescription; var sequence = reader.ProteinSequence; decoyWriter.WriteLine(">{0}_{1} {2}", FastaDatabaseConstants.DecoyProteinPrefix, name, description); if (!shuffle) { // Reversed protein sequence var decoySequence = new StringBuilder(); for (var i = sequence.Length - 1; i >= 0; i--) { var residue = sequence[i]; if (enzyme != null && enzyme.Residues.Length > 0 && enzyme.IsCleavable(residue) && decoySequence.Length > 0) { var residueToBeReplaced = decoySequence[decoySequence.Length - 1]; decoySequence.Remove(decoySequence.Length - 1, 1); decoySequence.Append((char)residue); decoySequence.Append(residueToBeReplaced); } else { decoySequence.Append((char)residue); } } decoyWriter.WriteLine(decoySequence); } else { // Shuffled protein sequences decoyWriter.WriteLine(SimpleStringProcessing.Mutate(SimpleStringProcessing.Shuffle(sequence), NumMutations)); } } reader.CloseFile(); } }
protected override void Context() { _individual = BatchToolFactoryForSpecs.Individual(); _enzyme = new Enzyme { Name = "CYP", ReferenceConcentration = 5 }; _enzyme.Expressions.Add("Liver", 0.5); _enzyme.Expressions.Add("Kidney", 0.9); _individual.Enzymes.Add(_enzyme); _settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; }
public Digestion Digest(Enzyme enzyme, DigestSettings digestSettings, ILoadMonitor loader) { ProgressStatus progressStatus = new ProgressStatus(string.Format(Resources.BackgroundProteomeSpec_Digest_Digesting__0__, enzyme.Name)); using (var proteomeDb = OpenProteomeDb()) { return(proteomeDb.Digest(new ProteaseImpl(enzyme), (s, i) => { loader.UpdateProgress(progressStatus.ChangePercentComplete(i)); return !loader.IsCanceled; })); } }
/// <summary> /// Get the Decoy version of this database (create it if missing) /// </summary> /// <param name="enzyme"></param> /// <param name="shuffle"></param> /// <returns></returns> public FastaDatabase Decoy(Enzyme enzyme, bool shuffle = false) { if (IsDecoy) { throw new InvalidOperationException("Already a decoy database"); } var decoyDatabasePath = GetDecoyDatabasePath(enzyme, shuffle); if (!File.Exists(decoyDatabasePath)) { CreateDecoyDatabase(enzyme, shuffle); } return(new FastaDatabase(decoyDatabasePath, true)); }
public IcBottomUpLauncher( string specFilePath, string dbFilePath, string outputDir, AminoAcidSet aaSet, Enzyme enzyme) { ErrorMessage = string.Empty; SpecFilePath = specFilePath; DatabaseFilePath = dbFilePath; AminoAcidSet = aaSet; Enzyme = enzyme; if (outputDir == null) { OutputDir = Path.GetDirectoryName(SpecFilePath); } else { if (!Directory.Exists(outputDir)) { if (File.Exists(outputDir) && !File.GetAttributes(outputDir).HasFlag(FileAttributes.Directory)) { throw new Exception(outputDir + " is not a directory!"); } Directory.CreateDirectory(outputDir); } OutputDir = outputDir; } OutputDir = outputDir; MinSequenceLength = 6; MaxSequenceLength = 30; MinPrecursorIonCharge = 1; MaxPrecursorIonCharge = 4; MinProductIonCharge = 1; MaxProductIonCharge = 3; PrecursorIonTolerance = new Tolerance(10); ProductIonTolerance = new Tolerance(10); RunTargetDecoyAnalysis = DatabaseSearchMode.Both; NumTolerableTermini = 1; NumMatchesPerSpectrum = 10; }
/* * public IEnumerable<PepV01> GetPeptides(SrmSettings settings, bool useFilter) * { * PeptideSettings pepSettings = settings.PeptideSettings; * Enzyme enzyme = pepSettings.Enzyme; * DigestSettings digest = pepSettings.DigestSettings; * IPeptideFilter filter = (useFilter ? pepSettings.Filter : PeptideFilter.UNFILTERED); * SequenceMassCalc massCalc = settings.GetPrecursorCalc(IsotopeLabelType.none); * RetentionTimeRegression rtRegression = pepSettings.Prediction.RetentionTime; * * IEnumerable<PepV01> peptides = PeptideList ? * GetPeptideList(enzyme) : enzyme.Digest(this, digest, filter); * * foreach (PepV01 peptide in peptides) * { * peptide.CalcMass(massCalc); * peptide.CalcRetentionTime(rtRegression); * yield return peptide; * } * } */ /// <summary> /// Get the list of peptides from a <see cref="FastaSeqV01"/> where /// <see cref="PeptideList"/> is true. /// </summary> /// <param name="enzyme">The enzyme used to detect missed cleavages in the peptides</param> /// <returns>An enumerable list of <see cref="PepV01"/></returns> public IEnumerable <PepV01> GetPeptideList(Enzyme enzyme) { if (!PeptideList) { throw new InvalidOperationException(Resources.FastaSeqV01_GetPeptideList_Attempt_to_get_peptide_list_from_uncleaved_FASTA_sequence); } int begin = 1; int end = begin; while (end < AA.Length - 1) { end = AA.IndexOf(PEPTIDE_SEPARATOR, begin); string seqPep = AA.Substring(begin, end - begin); int missedCleavages = enzyme.CountCleavagePoints(seqPep); yield return(new PepV01(this, begin, end, missedCleavages)); begin = end + 1; } }
public void TestProteomeDb() { using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE)) { string fastaPath = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta"); string protDbPath = testFilesDir.GetTestPath("test.protdb"); using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath)) { Enzyme trypsin = EnzymeList.GetDefault(); using (var reader = new StreamReader(fastaPath)) { proteomeDb.AddFastaFile(reader, (msg, progress) => true); } // perform digestion proteomeDb.Digest(new ProteaseImpl(trypsin), (msg, progress) => true); Digestion digestion = proteomeDb.GetDigestion(trypsin.Name); var digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100); Assert.IsTrue(digestedProteins0.Count >= 1); } } }
public void TestProteomeDb() { using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE)) { string fastaPath = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta"); string protDbPath = testFilesDir.GetTestPath("test.protdb"); using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath)) { Enzyme trypsin = EnzymeList.GetDefault(); IProgressStatus status = new ProgressStatus(string.Empty); using (var reader = new StreamReader(fastaPath)) { proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, true); // Delay indexing } // perform digestion proteomeDb.Digest(new ProteaseImpl(trypsin), ProteomeDb.PROTDB_MAX_MISSED_CLEAVAGES, new SilentProgressMonitor(), ref status); Digestion digestion = proteomeDb.GetDigestion(trypsin.Name); var digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100); Assert.IsTrue(digestedProteins0.Count >= 1); } } }
/// <summary> /// The numbers report the position counting from index 0 and match the same results as in http://expasy.org/cgi-bin/peptidecutter/peptidecutter.pl /// </summary> /// <param name="sequence"></param> /// <param name="enzyme"></param> /// <param name="noEnzymaticTermini"></param> /// <returns></returns> public List <int> FindDigestionPositions(string sequence, Enzyme enzyme) { List <int> pos = new List <int>(30); MatchCollection mc = enzimeRegexDictForSequences[enzyme].Matches(sequence); foreach (Match match in mc) { if (match.Groups[0].Index + 1 < sequence.Length) { char nextAA = sequence[match.Groups[0].Index + 1]; if (!nextAA.Equals("P")) { pos.Add(match.Groups[0].Index + 1); } } else { pos.Add(match.Groups[0].Index + 1); } } return(pos); }
/// <summary> /// Generate the path for the decoy database according to the supplied parameters /// </summary> /// <param name="enzyme"></param> /// <param name="shuffle"></param> /// <returns></returns> public string GetDecoyDatabasePath(Enzyme enzyme, bool shuffle = false) { string newExtension; if (!shuffle) { // Reverse the sequences if (enzyme != null && enzyme.Residues.Length > 0) { newExtension = ".icdecoy." + new string(enzyme.Residues) + ".fasta"; } else { newExtension = DecoyDatabaseFileExtension; } } else { // Shuffle the sequences newExtension = ShuffleDecoyFileExtension; } return(Path.ChangeExtension(_databaseFilePath, newExtension)); }
/// <summary> /// For a peptide peptide string /// </summary> /// <param name="peptide"></param> /// <param name="enzyme"></param> /// <returns></returns> public MatchCollection NoEnzymaticCleavages(string peptide, Enzyme enzyme) { return(enzimeRegexDictForPeps[enzyme].Matches(peptide)); }
public abstract void SetEnzyme(Enzyme enzyme, int maxMissedCleavages);
public Dictionary <Target, DigestionPeptideStats> GetPeptidesAppearanceCounts(Dictionary <Target, bool> peptidesOfInterest, Enzyme enzyme, PeptideSettings settings, SrmSettingsChangeMonitor progressMonitor) { var appearances = GetPeptidesAppearances(peptidesOfInterest, enzyme, settings, progressMonitor); if (appearances == null) { return(null); // Cancelled } return(appearances.ToDictionary(pep => new Target(pep.Key), pep => new DigestionPeptideStats(pep.Value.Proteins.Count, pep.Value.Genes.Count, pep.Value.Species.Count))); }
public RankScore(ActivationMethod activationMethod, Ms2DetectorType ms2DetectorType, Enzyme enzyme, Protocol protocol) { if (activationMethod == ActivationMethod.HCD && enzyme == Enzyme.Trypsin) { var paramFile = Properties.Resources.HCD_Trypsin; var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(paramFile); writer.Flush(); stream.Position = 0; _trainingParameters = new TrainingParameters(stream); } else { throw new ArgumentException("No parameter file available for selected arguments."); } }
/// <summary> /// Get the annotation and offset data from the database for all sequences that comply with the parameters /// </summary> /// <param name="minLength"></param> /// <param name="maxLength"></param> /// <param name="numTolerableTermini"></param> /// <param name="numMissedCleavages"></param> /// <param name="enzyme"></param> /// <returns></returns> public IEnumerable <AnnotationAndOffset> AnnotationsAndOffsets(int minLength, int maxLength, int numTolerableTermini, int numMissedCleavages, Enzyme enzyme) { return(AnnotationsAndOffsets(minLength, maxLength, numTolerableTermini, numMissedCleavages, enzyme.Residues, enzyme.IsNTerm)); }
public override void SetEnzyme(Enzyme enz, int mmc) { enzyme = ENZYMES.IndexOf(o => string.Equals(o, enz.Name, StringComparison.InvariantCultureIgnoreCase)); ntt = enz.IsSemiCleaving ? 1 : 2; maxMissedCleavages = mmc; }
/// <summary> /// Get the annotation and offset data from the database for all sequences that comply with the parameters /// </summary> /// <param name="minLength"></param> /// <param name="maxLength"></param> /// <param name="numTolerableTermini"></param> /// <param name="numMissedCleavages"></param> /// <param name="enzyme"></param> /// <param name="threads"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public IEnumerable <AnnotationAndOffset> AnnotationsAndOffsetsParallel(int minLength, int maxLength, int numTolerableTermini, int numMissedCleavages, Enzyme enzyme, int threads, CancellationToken?cancellationToken = null) { return(AnnotationsAndOffsetsParallel(minLength, maxLength, numTolerableTermini, numMissedCleavages, enzyme.Residues, enzyme.IsNTerm, threads, cancellationToken)); }
public void OkDialog() { var helper = new MessageBoxHelper(this); string name; if (!helper.ValidateNameTextBox(textName, out name)) { return; } string cleavageC; if (!helper.ValidateAATextBox(textCleavage, false, out cleavageC)) { return; } string restrictC; if (!helper.ValidateAATextBox(textRestrict, true, out restrictC)) { return; } string cleavageN; string restrictN; if (comboDirection.SelectedIndex == 2) { if (!helper.ValidateAATextBox(textCleavageN, false, out cleavageN)) { return; } if (!helper.ValidateAATextBox(textRestrictN, true, out restrictN)) { return; } } else if (comboDirection.SelectedIndex == 1) { cleavageN = cleavageC; cleavageC = null; restrictN = restrictC; restrictC = null; } else { cleavageN = null; restrictN = null; } Enzyme enzyme = new Enzyme(name, cleavageC, restrictC, cleavageN, restrictN); if (_enzyme == null && _existing.Contains(enzyme)) { helper.ShowTextBoxError(textName, Resources.EditEnzymeDlg_OnClosing_The_enzyme__0__already_exists, name); return; } _enzyme = enzyme; DialogResult = DialogResult.OK; }
public ProteaseImpl(Enzyme enzyme) { _enzyme = enzyme; }
public ProteaseImpl(Enzyme enzyme) { // Background proteome databases cannot yet deal with semi-cleaving enzymes _enzyme = !enzyme.IsSemiCleaving ? enzyme : enzyme.ChangeSemiCleaving(false); }
/// <summary> /// Constructor /// </summary> /// <param name="enzyme"></param> /// <param name="ntt"></param> public PeptideEnumerator(Enzyme enzyme, int ntt) { _enzyme = enzyme; _ntt = ntt; }