Пример #1
0
        /// <summary>
        /// Sort the index of SequenceAlignmentMap by RName then by Pos.
        /// Fill the index (sorted by RName then by Pos) into a list, when the list size reaches
        /// the maximum limit, write the list to file and clear the list.
        /// </summary>
        private SortedDictionary <string, IList <string> > SortByChromosomeCoordinates()
        {
            SortedDictionary <string, IList <string> > sortedFiles = new SortedDictionary <string, IList <string> >();
            IList <string> files = null;

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

            System.Collections.Generic.SortedList <object, string> sortedList = null;

            for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++)
            {
                SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index];
                if (!groups.TryGetValue(alignedSeq.RName, out sortedList))
                {
                    sortedList = new System.Collections.Generic.SortedList <object, string>();
                    groups.Add(alignedSeq.RName, sortedList);
                }

                string indices = string.Empty;
                if (!sortedList.TryGetValue(alignedSeq.Pos, out indices))
                {
                    sortedList.Add(alignedSeq.Pos, index.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture));
                    sortedList[alignedSeq.Pos] = indices;
                }

                if (sortedList.Count >= SortedListMaxCount)
                {
                    if (!sortedFiles.TryGetValue(alignedSeq.RName, out files))
                    {
                        files = new List <string>();
                        sortedFiles.Add(alignedSeq.RName, files);
                    }

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

            foreach (KeyValuePair <string, System.Collections.Generic.SortedList <object, string> > group in groups)
            {
                if (group.Value.Count > 0)
                {
                    if (!sortedFiles.TryGetValue(group.Key, out files))
                    {
                        files = new List <string>();
                        sortedFiles.Add(group.Key, files);
                    }

                    files.Add(WriteToFile(group.Value));
                    group.Value.Clear();
                }
            }

            return(sortedFiles);
        }
Пример #2
0
        private void btnRunSearch_Click(object sender, EventArgs e)
        {
            UInt32 id = 0;

            try
            {
                id = UInt32.Parse(txtSearchID.Text);
            }
            catch (Exception)
            {
                MessageBox.Show(this,
                                "Error parsing search id.", "Invalid ID");
                lvResults.Clear();
                return;
            }

            lvResults.Clear();

            ContentObject o = null; //ContentManager.Instance.FindEntry(id);

            if (o != null)
            {
                ListViewItem item = new ListViewItem(o.Name);
                item.Tag = o.Object;
                lvResults.Items.Add(item);
            }

            if (m_CRCList != null)
            {
                string val;

                if (m_CRCList.TryGetValue(id, out val))
                {
                    ListViewItem item =
                        new ListViewItem("CRC Match: \"" + val + "\"");

                    lvResults.Items.Add(item);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Sort the index of SequenceAlignmentMap by RName then by Pos.
        /// Fill the index (sorted by RName then by Pos) into a list, when the list size reaches
        /// the maximum limit, write the list to file and clear the list.
        /// </summary>
        private SortedDictionary<string, IList<string>> SortByChromosomeCoordinates()
        {
            SortedDictionary<string, IList<string>> sortedFiles = new SortedDictionary<string, IList<string>>();
            IList<string> files = null;

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

            for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++)
            {
                SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index];
                if (!groups.TryGetValue(alignedSeq.RName, out sortedList))
                {
                    sortedList = new System.Collections.Generic.SortedList<object, string>();
                    groups.Add(alignedSeq.RName, sortedList);
                }

                string indices = string.Empty;
                if (!sortedList.TryGetValue(alignedSeq.Pos, out indices))
                {
                    sortedList.Add(alignedSeq.Pos, index.ToString(CultureInfo.InvariantCulture));
                }
                else
                {
                    indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture));
                    sortedList[alignedSeq.Pos] = indices;
                }

                if (sortedList.Count >= SortedListMaxCount)
                {
                    if (!sortedFiles.TryGetValue(alignedSeq.RName, out files))
                    {
                        files = new List<string>();
                        sortedFiles.Add(alignedSeq.RName, files);
                    }

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

            foreach (KeyValuePair<string, System.Collections.Generic.SortedList<object, string>> group in groups)
            {
                if (group.Value.Count > 0)
                {
                    if (!sortedFiles.TryGetValue(group.Key, out files))
                    {
                        files = new List<string>();
                        sortedFiles.Add(group.Key, files);
                    }

                    files.Add(WriteToFile(group.Value));
                    group.Value.Clear();
                }
            }

            return sortedFiles;
        }