Build() public méthode

public Build ( BitStream32 bitmap, short B ) : void
bitmap BitStream32
B short
Résultat void
Exemple #1
0
 public void Save_CSA_BWT(string sa_name, int sample_step)
 {
     Console.WriteLine ("Save_CSA_BWT destroys the SA, if you need the plain SA");
     Console.WriteLine ("first save it and reload it after the call");
     using (var Output = new BinaryWriter (File.Create (sa_name + ".structs"))) {
         RankSelectGenericIO.Save (Output, this.newF);
         PrimitiveIO<int>.WriteVector (Output, this.charT);
     }
     using (var Output = new BinaryWriter (File.Create (sa_name + ".samples"))) {
         Output.Write ((short)sample_step);
         var B = new BitStream32 ();
         int numbits = (int)Math.Ceiling (Math.Log (this.SA.Length, 2));
         var SA_samples = new List<int> ();
         var SA_invsamples = new List<int> ();
         for (int i = 0; i < this.SA.Length; i++) {
             var s = this.SA[i];
             if ((s + 1 == this.SA.Length) || (s % sample_step == 0)) {
                 B.Write (true);
                 SA_samples.Add (s);
                 SA_invsamples.Add (i);
             } else {
                 B.Write (false);
             }
         }
         GGMN G = new GGMN ();
         G.Build (B, 8);
         RankSelectGenericIO.Save (Output, G);
         {
             var _SA_samples = new ListIFS (numbits);
             foreach (var u in SA_samples) {
                 _SA_samples.Add (u);
             }
             _SA_samples.Save (Output);
         }
         {
             Sorting.Sort<int, int> (SA_samples, SA_invsamples);
             var _SA_invsamples = new ListIFS (numbits);
             foreach (var u in SA_invsamples) {
                 _SA_invsamples.Add (u);
             }
             _SA_invsamples.Save (Output);
             SA_samples = null;
             SA_invsamples = null;
         }
     }
     // building bwt
     using (var Output = new BinaryWriter (File.Create (sa_name + ".bwt"))) {
         int alphabet_numbits = (int)Math.Ceiling (Math.Log (this.charT.Count + 1, 2));
         var L = new ListIFS (alphabet_numbits);
         int bwt_len = this.SA.Length;
         for (int i = 0; i < bwt_len; i++) {
             var v = this.SA[i];
             if (v == 0) {
                 L.Add (0);
             } else {
                 // Output.Write ("{0} ", (int)this.Text[v - 1]);
                 var c = this.Text[v - 1];
                 var u = GenericSearch.FindLast<int> (c, this.charT, 1, this.charT.Count);
                 L.Add (u);
             }
         }
         L.Save (Output);
     //				for (int i = 0; i < bwt_len; i++) {
     //					var v = this.SA[i];
     //					if (v == 0) {
     //						Output.Write ("{0} ", -1);
     //					} else {
     //						// Output.Write ("{0} ", (int)this.Text[v - 1]);
     //						var c = this.Text[v - 1];
     //						var u = GenericSearch.FindLast<int> (c, this.charT);
     //						Output.Write ("{0} ", u);
     //					}
     //				}
         // PrimitiveIO<byte>.WriteVector (Output, BWT);
     }
     // building psi
     using (var Output = new BinaryWriter (File.Create (sa_name + ".psi"))) {
         var INV = new int[this.SA.Length];
         for (int i = 0; i < INV.Length; i++) {
             INV[this.SA[i]] = i;
         }
         var PSI = this.SA;
         for (int i = 0; i < PSI.Length; i++) {
             var p = (PSI[i] + 1) % PSI.Length;
             PSI[i] = INV[p];
         }
         PrimitiveIO<int>.WriteVector (Output, PSI);
         /*Console.Write ("charT => ");
         for (int i = 0; i < this.charT.Count; i++) {
             Console.Write ("[{0}] ", (char)this.charT[i]);
         }
         Console.WriteLine ();
         Console.Write ("newF => ");
         for (int i = 0; i < this.newF.Count1; i++) {
             Console.Write ("{0} ", this.newF.Select1(i+1));
         }
         Console.WriteLine ();
         Console.Write ("PSI => ");
         for (int i = 0; i < PSI.Length; i++) {
             Console.Write ("{0} ", PSI[i]);
         }
         Console.WriteLine ();
          */
         INV = null;
     }
     this.SA = null;
 }
Exemple #2
0
 public GGMN GetGGMN(short step)
 {
     var g = new GGMN ();
     g.Build (this.B, step);
     return g;
 }
Exemple #3
0
 public static BitmapFromList GetGGMN(short sample_step)
 {
     return delegate (IList<int> L) {
         var rs = new GGMN ();
         rs.Build (L, sample_step);
         return rs;
     };
 }