예제 #1
0
        /// <summary>
        /// convert sequence basket (repeats and hairpins) to region indexes
        /// </summary>
        /// <param name="sourceList">the source sequence basket (list of sequences)</param>
        /// <returns>the list of regions of the source basket</returns>
        protected static iDnaRegionIndexList SequenceListToRegionList(IEnumerable <iDnaSequence> sourceList)
        {
            iDnaRegionIndexList list = new iDnaRegionIndexList();

            if (sourceList == null || sourceList.Count() <= 0)
            {
                return(list);
            }

            foreach (var seq in sourceList)
            {
                int min      = seq.Min(i => i.Index),
                         max = seq.Max(i => i.Index);

                list.Add(new iDnaRegionIndex(seq.Name, min, max, seq.SequenceFileInfo)
                {
                    Occurrences = seq._nOccurrences
                });
            }
            return(list);
        }
예제 #2
0
        /// <summary>
        /// rebuild sequence basket (repeats and hairpins) from region indexes
        /// </summary>
        /// <param name="sourceSequence">the parent sequence to which the basket should be attached</param>
        /// <param name="sourceList">the region index list</param>
        /// <returns>the list of sequence basket</returns>
        protected static List <iDnaSequence> RegionListToSequenceList(iDnaSequence sourceSequence, iDnaRegionIndexList sourceList)
        {
            List <iDnaSequence> list = new List <iDnaSequence>();

            if (sourceList == null || sourceList.Count() <= 0 || sourceSequence == null)
            {
                return(list);
            }

            foreach (var region in sourceList)
            {
                var nodes = sourceSequence.Where(i => i.Index >= region.MinValue && i.Index <= region.MaxValue);

                if (nodes == null || nodes.Count() <= 0)
                {
                    continue;
                }

                list.Add(new iDnaSequence(region.Name, nodes, refOnly: true, nOccurrences: region.Occurrences));
            }
            return(list);
        }