public KnrFP(KnrFP inputDB, int new_n, int new_K = -1) { this.K = new_K; this.Fingerprints = new StringSpace<int> (); this.Fingerprints.seqs.Capacity = new_n; this.IdxRefs = inputDB.IdxRefs; if (new_K <= 0) { for (int i = 0; i < new_n; ++i) { var u = inputDB.Fingerprints.seqs [i]; this.Fingerprints.Add (u); } } else { if (new_K > inputDB.Fingerprints.seqs [0].Length) { throw new ArgumentOutOfRangeException("new_K > old_K need a complete re-construction of the transformation"); } for (int i = 0; i < new_n; ++i) { var u = inputDB.Fingerprints.seqs [i]; var v = new int[new_K]; for (int j = 0; j < new_K; ++j) { v [j] = u [j]; } this.Fingerprints.Add (v); } } }
public void Load(BinaryReader Input) { this.Name = Input.ReadString (); this.IdxRefs = IndexGenericIO.Load (Input); this.Fingerprints = SpaceGenericIO.SmartLoad (Input, false) as StringSpace<int>; this.K = Input.ReadInt32 (); }
public virtual void Build(MetricDB original, Index refs, int k) { this.K = k; this.Fingerprints = new StringSpace<int> (); this.Fingerprints.seqs.Capacity = original.Count; this.IdxRefs = refs; var n = original.Count; var A = new int[n][]; int blocksize = 10000; int pc = original.Count / 100 + 1; int advance = 0; var create_block = new Action<int> (delegate(int blockID) { var sp = blockID * blocksize; var ep = Math.Min (n, sp + blocksize); for (; sp < ep; ++sp) { var fp = this.GetFP(original[sp]); A[sp] = fp; if (advance % pc == 0) { Console.WriteLine ("KnrFP {0} ({1}/{2}), db: {3}, num_refs: {4}, timestamp: {5}", this, advance, n, original.Name, this.IdxRefs.DB.Count, DateTime.Now); } advance++; } }); ParallelOptions ops = new ParallelOptions(); ops.MaxDegreeOfParallelism = -1; Parallel.For (0, 1+n/blocksize, create_block); foreach (var fp in A) { this.Fingerprints.Add( fp ); } }