Ejemplo n.º 1
0
        private void LoadAndFindTaxonomy()
        {
            var dc = RcadSequenceProvider.CreateDbContext(ConnectionString);

            _rootTaxonomy = new TaxonomyEntry(dc, true);

            // Get a list of the taxids leading up to the selected one.
            string sql = @"with cte as (select ParentTaxID from Taxonomy where TaxID={0} " +
                         @"union all select t.ParentTaxID from Taxonomy t join cte tp on t.TaxID = tp.ParentTaxID) " +
                         @"select * from cte";

            var taxIds = dc.ExecuteQuery <int>(sql, ParentTaxId).Reverse().ToList();

            taxIds.RemoveAt(0); // Remove root entry
            taxIds.Add(ParentTaxId);

            TaxonomyEntry current = _rootTaxonomy;

            foreach (int tid in taxIds)
            {
                // Skip root (level 0)
                if (tid <= 1)
                {
                    continue;
                }

                current.IsExpanded = true;
                foreach (var child in current.Children)
                {
                    if (child.Id == tid)
                    {
                        current = child;
                        break;
                    }
                }
            }

            if (current.Id == ParentTaxId)
            {
                current.IsSelected = true;
            }
            else
            {
                _rootTaxonomy = null;
                dc.Dispose();
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <IBioSymbol> LoadRange(int startIndex, int count)
        {
            using (var dc = RcadSequenceProvider.CreateDbContext(_connectionString))
            {
                startIndex++;

                // select ColumnNumber, Base from sequence
                //    where seqid = @id and ColumnNumber >= @startIndex
                //    order by columnNumber
                //KJD (10/21/2009) - Change query to use vAlignmentGridUngapped which takes into account column indirection supported by the rCAD schema
                //we use the ungapped view to avoid transmitting gap characters from the db to the view (which would happen with vAlignmentGrid).
                var data = (from seq in dc.vAlignmentGridUngappeds
                            where seq.SeqID == _id && seq.AlnID == _aid && seq.LogicalColumnNumber >= startIndex
                            orderby seq.LogicalColumnNumber
                            select new { seq.LogicalColumnNumber, seq.BioSymbol }).Take(count);

                // Push back the requested count, fill in gaps in the sequence
                int i  = 0;
                var ie = data.GetEnumerator();
                if (ie.MoveNext())
                {
                    var entry = ie.Current;

                    for (; i < count; i++)
                    {
                        int currentIndex = i + startIndex;

                        Debug.Assert(entry.LogicalColumnNumber >= currentIndex);
                        if (entry.LogicalColumnNumber == currentIndex)
                        {
                            Debug.Assert(_startingSequenceColumn <= currentIndex);

                            yield return(new BioSymbol(BioSymbolType.Nucleotide, entry.BioSymbol));

                            if (!ie.MoveNext())
                            {
                                break;
                            }

                            entry = ie.Current;
                        }
                        else
                        {
                            if (_startingSequenceColumn > currentIndex)
                            {
                                yield return(BioSymbol.None);
                            }
                            else
                            {
                                yield return(BioSymbol.Gap);
                            }
                        }
                    }
                }

                // Pad to end
                for (; i < count; i++)
                {
                    yield return(BioSymbol.None);
                }
            }
        }