Beispiel #1
0
        /// <summary>
        /// Looks for a key in the array of key/values of the parameter string.  If not found, return the specified default value
        /// </summary>
        /// <param name="items">The list to look in</param>
        /// <param name="key">The key to find</param>
        /// <param name="defValue">The default value to return if the key is not found</param>
        /// <returns>The value corresponding to the specified key, or the default value if not found.</returns>
        static internal string FindKey(System.Collections.Generic.SortedList <string, string> items, string key, string defValue)
        {
            string ret;

            if (items.TryGetValue(key, out ret))
            {
                return(ret);
            }

            return(defValue);
        }
Beispiel #2
0
        /// <summary>
        /// Sort the index of SequenceAlignmentMap by QName.
        /// Fill the index (sorted by QName) into a list, when the list size reaches
        /// the maximum limit, write the list to file and clear the list.
        /// </summary>
        private IList <string> SortByReadNames()
        {
            IList <string> files = new List <string>();

            var sortedList = new System.Collections.Generic.SortedList <object, string>();

            for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++)
            {
                SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index];
                string             indices    = string.Empty;
                if (!sortedList.TryGetValue(alignedSeq.QName, out indices))
                {
                    sortedList.Add(alignedSeq.QName, index.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture));
                    sortedList[alignedSeq.QName] = indices;
                }

                if (sortedList.Count >= SortedListMaxCount)
                {
                    if (files == null)
                    {
                        files = new List <string>();
                    }

                    files.Add(WriteToFile(sortedList));
                    sortedList.Clear();
                }
            }

            if (sortedList.Count > 0)
            {
                files.Add(WriteToFile(sortedList));
                sortedList.Clear();
            }

            return(files);
        }
Beispiel #3
0
        /// <summary>
        /// Sort the index of SequenceAlignmentMap by QName.
        /// Fill the index (sorted by QName) into a list, when the list size reaches
        /// the maximum limit, write the list to file and clear the list.
        /// </summary>
        private IList<string> SortByReadNames()
        {
            IList<string> files = new List<string>();

            var sortedList = new System.Collections.Generic.SortedList<object,string>();

            for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++)
            {
                SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index];
                string indices = string.Empty;
                if (!sortedList.TryGetValue(alignedSeq.QName, out indices))
                {
                    sortedList.Add(alignedSeq.QName, index.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture));
                    sortedList[alignedSeq.QName] = indices;
                }

                if (sortedList.Count >= SortedListMaxCount)
                {
                    if (files == null)
                    {
                        files = new List<string>();
                    }

                    files.Add(WriteToFile(sortedList));
                    sortedList.Clear();
                }
            }

            if (sortedList.Count > 0)
            {
                files.Add(WriteToFile(sortedList));
                sortedList.Clear();
            }
            
            return files;
        }