Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
 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.");
     }
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
 public PeptideEnumerator(Enzyme enzyme, int ntt)
 {
     _enzyme = enzyme;
     _ntt = ntt;
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 public IEnumerable<AnnotationAndOffset> AnnotationsAndOffsets(int minLength, int maxLength, int numTolerableTermini,
                                               int numMissedCleavages, Enzyme enzyme)
 {
     return AnnotationsAndOffsets(minLength, maxLength, numTolerableTermini, numMissedCleavages, enzyme.Residues,
                        enzyme.IsNTerm);
 }
Esempio n. 7
0
        /// <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}", 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(residue);
                                decoySequence.Append(residueToBeReplaced);
                            }
                            else
                            {
                                decoySequence.Append(residue);
                            }
                        }
                        decoyWriter.WriteLine(decoySequence);
                    }
                    else
                    {
                        // Shuffled protein sequences
                        decoyWriter.WriteLine(SimpleStringProcessing.Mutate(SimpleStringProcessing.Shuffle(sequence), NumMutations));
                    }
                }
                reader.CloseFile();
            }
        }
Esempio n. 8
0
        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);
        }