Exemplo n.º 1
0
        /// <summary>
        /// Returns a node for a given k-mer
        /// </summary>
        /// <param name="kmer">The kmer</param>
        /// <returns>true if the item has previously been assigned a serial number; otherwise, false.</returns>
        public DeBruijnNode TryGetOld(KmerData32 kmer)
        {
            int bucketIndex = AssignBucket(kmer);
            BinaryTreeOfDebrujinNodes tree = _buckets[bucketIndex];

            return(tree.SearchTree(kmer));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new dictionary to store and search for deBruijin Nodes
 /// </summary>
 public KmerDictionary()
 {
     var maxSize = (ulong) Math.Pow(2, HashLength);
     
     // Create a list of buckets up to that size
     _buckets = new BinaryTreeOfDebrujinNodes[maxSize];
     
     // Create a new tree in each bucket position 
     Enumerable.Range(0, (int) maxSize).ForEach(x => _buckets[x] = new BinaryTreeOfDebrujinNodes());
     
     // Make a mask for incoming bits
     _hashingMask = maxSize - 1; // This should be all bits up to the length of the buckets array.
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new dictionary to store and search for deBruijin Nodes
        /// </summary>
        public KmerDictionary()
        {
            var maxSize = (ulong)Math.Pow(2, HashLength);

            // Create a list of buckets up to that size
            _buckets = new BinaryTreeOfDebrujinNodes[maxSize];

            // Create a new tree in each bucket position
            Enumerable.Range(0, (int)maxSize).ForEach(x => _buckets[x] = new BinaryTreeOfDebrujinNodes());

            // Make a mask for incoming bits
            _hashingMask = maxSize - 1; // This should be all bits up to the length of the buckets array.
        }
Exemplo n.º 4
0
        /// <summary>
        /// Either returns the DeBrujin node associated with the ulong, or
        /// sets it if an old one does not exist
        /// Parallel Note: Is thread safe
        /// </summary>
        /// <returns>The node representing this value</returns>
        public DeBruijnNode SetNewOrGetOld(KmerData32 value)
        {
            int bucket = AssignBucket(value);
            BinaryTreeOfDebrujinNodes curBucket = _buckets[bucket];

            //keep it thread safe for additions
            DeBruijnNode toReturn;

            lock (curBucket)
            {
                toReturn = curBucket.AddOrReturnCurrent(value);
            }
            return(toReturn);
        }