///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Example                                //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header
  
  + name      := ACGT;

  - copyright := "2003-2008 Sonntag Benoit";

  - author    := "Sonntag Benoit (sonntag@icps.u-strasbg.fr)";
  - comment   := "The main prototype";

Section Inherit

  - parent_object:OBJECT := OBJECT;

Section Public
  
  - monome_size:INTEGER;
  
  - list:FAST_ARRAY(FAST_ARRAY(BASE));
  
  - base:FAST_ARRAY(BASE) := 
  ( + result:FAST_ARRAY(BASE);    
    + code:UINTEGER_8;
    result := FAST_ARRAY(BASE).create_with_capacity (20*(3+1));
    0.to 2 do { f:INTEGER;
      f.to 3 do { s:INTEGER;
        (f+1).to 3 do { t:INTEGER;
          result.add_last (BASE.create (result.count+1));
          //
          code := ((f << 4) | (s << 2) | t).to_uinteger_8;          
          result.add_last (BASE.create code);
          //
          code := ((t << 4) | (f << 2) | s).to_uinteger_8;
          result.add_last (BASE.create code);
          //
          code := ((s << 4) | (t << 2) | f).to_uinteger_8;
          result.add_last (BASE.create code);
        };
      };
    };
    result        
  );
  
  - print_base <-
  (
    (base.lower).to (base.upper) by 4 do { i:INTEGER;
      base.item (i+1).print; '-'.print;
      base.item (i+2).print; '-'.print;
      base.item (i+3).print; '\n'.print;      
    };
  );
  
  - compute_monome <-
  ( + idx:INTEGER;    
    + new_m:FAST_ARRAY(BASE);
    + b:BASE;
    + v:UINTEGER_8;
    
    new_m := FAST_ARRAY(BASE).create_with_capacity monome_size;
    0.to (monome_size-1) do { i:INTEGER;
      v := base.item idx.value;
      b := base.item (idx + v);
      new_m.add_last b;
    };
    
    list.add_last new_m;
    
  );
  
  - print_monome <-
  ( + m:FAST_ARRAY(BASE);
    (list.lower).to (list.upper) do { i:INTEGER;
      i.print; ':'.print;
      m := list.item i;
      (m.lower).to (m.upper-1) do { j:INTEGER;
        m.item j.print;
        '-'.print;
      };
      m.last.print;
    };
    '\n'.print;
  );
  
  - main <-
  (
    list := FAST_ARRAY(FAST_ARRAY(BASE)).create_with_capacity 262144;
    
    monome_size := 2;
    print_base;
    //compute_monome;
    //print_monome;
  );
  
  
