Пример #1
0
        /// <summary>
        /// Load the mapping between ResultID and Protein Name
        /// </summary>
        /// <param name="resultToSeqMap">Output: ResultToSeqMap list; keys are ResultID, Values as SeqID</param>
        /// <param name="seqToProteinMap">Output: SeqToProteinMap list; keys are SeqID, Values are list of ProteinInfo objects</param>
        /// <param name="seqInfo">Output: SeqInfo list; keys are SeqID, Values are seq details stored in SeqInfo objects</param>
        /// <param name="pepToProteinMap">Output: PepToProteinMap list; keys are clean peptide sequences (no mods), Values are Protein name and residue start/end locations for the peptide</param>
        /// <returns>True if successful, false if an error</returns>
        public bool GetProteinMapping(
            SortedList <int, int> resultToSeqMap,
            SortedList <int, List <ProteinInfo> > seqToProteinMap,
            SortedList <int, SequenceInfo> seqInfo,
            Dictionary <string, PepToProteinMapInfo> pepToProteinMap)
        {
            bool   success;
            string filePath;

            resultToSeqMap.Clear();
            seqToProteinMap.Clear();
            seqInfo.Clear();
            pepToProteinMap.Clear();

            // Note: do not put a Try/Catch handler in this method
            //       Instead, allow LoadResultToSeqMapping or LoadSeqToProteinMapping to raise exceptions

            if (string.IsNullOrEmpty(ResultToSeqMapFilename))
            {
                success = false;
            }
            else
            {
                filePath = Path.Combine(InputDirectoryPath, ResultToSeqMapFilename);
                if (!File.Exists(filePath))
                {
                    ErrorMessage = "SeqInfo file not found: " + filePath;
                    success      = false;
                }
                else
                {
                    success = LoadResultToSeqMapping(filePath, resultToSeqMap);
                }
            }

            if (!success)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(mSeqInfoFilename))
            {
                filePath = Path.Combine(InputDirectoryPath, mSeqInfoFilename);
                if (File.Exists(filePath))
                {
                    LoadSeqInfo(filePath, seqInfo);
                }
            }

            if (!string.IsNullOrEmpty(SeqToProteinMapFilename))
            {
                filePath = Path.Combine(InputDirectoryPath, SeqToProteinMapFilename);
                if (!File.Exists(filePath))
                {
                    ErrorMessage = "SeqInfo file not found: " + filePath;
                    success      = false;
                }
                else
                {
                    success = LoadSeqToProteinMapping(filePath, seqToProteinMap);
                }
            }
            else
            {
                success = false;
            }

            if (!success || string.IsNullOrEmpty(PepToProteinMapFilename))
            {
                return(success);
            }

            filePath = Path.Combine(InputDirectoryPath, PepToProteinMapFilename);
            if (!File.Exists(filePath))
            {
                var filePathAlternate = ReaderFactory.AutoSwitchToLegacyMSGFDBIfRequired(filePath, "Dataset_msgfdb.txt");
                if (File.Exists(filePathAlternate))
                {
                    filePath = filePathAlternate;
                }
            }

            if (!File.Exists(filePath))
            {
                Console.WriteLine("Warning: PepToProtMap file not found; protein residue start/end values will be zero");
                Console.WriteLine("         " + filePath);
            }
            else
            {
                success = LoadPepToProtMapData(filePath, pepToProteinMap);
            }

            return(success);
        }
Пример #2
0
 public static string AutoSwitchToLegacyMSGFDBIfRequired(string filePath, string basePHRPFileName)
 {
     return(ReaderFactory.AutoSwitchToLegacyMSGFDBIfRequired(filePath, basePHRPFileName));
 }