////////////////////////////////////////////////////////////////////////
//
// testmain.C - 
//
// $Id: testmain.C,v 1.15 2002/01/12 11:05:29 goetz Exp $
//
////////////////////////////////////////////////////////////////////////

#include "Exception.h"
#include "Alignment.h"
#include <iostream.h>
#include "iomanip.h"
#include <fstream.h>
#include "Score.h"
#include "matrices.h"
#include "iotools.h"

int main (int argc, char **argv)
{
  if (argc == 4) {
    ifstream ifs(argv[1]);
    ifstream ftb(argv[2]);
    ifstream refal(argv[3]);

    ifstream ifs2(argv[1]);

    ifstream refal2(argv[3]);
    ifstream ftb2(argv[2]);
    ifstream refal3(argv[3]);

    try {
      Alignment al(ifs, ftb, refal, "Test" );
      cout << al << endl;

      Alignment al2(ifs2, "Test2");
      cout << al2 << endl;
      /*
      BlockScaleFixed falpha( 3 ), fbeta( 2 );
      IndepSecW dSecW( &falpha, &fbeta );
          
      SPScore s(al, EditDistMatrix());
      cout << (const string)s << ": " << (int)s << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << s.colVal[i] << " ";
      cout << endl;

      SPScore ses(al, EditDistMatrix(), dSecW );
      cout << (const string)ses << ": " << (int)ses << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << ses.colVal[i] << " ";
      cout << endl;

      SPScore ws(al, EditDistMatrix(), DefaultSecW(), PwIndDist() );
      cout << (const string)ws << ": " << (int)ws << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << ws.colVal[i] << " ";
      cout << endl;

      SPScore sews(al, EditDistMatrix(), dSecW, PwIndDist() );
      cout << (const string)sews << ": " << (int)sews << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << sews.colVal[i] << " ";
      cout << endl;

      SPScore id(al, PredefScore(idmat, -10));
      cout << (const string)id << ": " << (int)id << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << id.colVal[i] << " ";
      cout << endl;

      SPScore bl(al, PredefScore(blosum30mt, -10));
      cout << (const string)bl << ": " << (int)bl << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << bl.colVal[i] << " ";
      cout << endl;

      SPScore pa(al, PredefScore(pam250mt, -5));
      cout << (const string)pa << ": " << (int)pa << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << pa.colVal[i] << " ";
      cout << endl;

      Alignment refali(refal2, ftb2, refal3, "Reference");
      cout << refali << endl;

      DiffScore ds(al, refali);
      cout << (const string)ds << ": " << (int)ds << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << ds.colVal[i] << " ";
      cout << endl;
 
      DiffScore dses(al, refali, dSecW );
      cout << (const string)dses << ": " << (int)dses << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << dses.colVal[i] << " ";
      cout << endl;

      DiffScore dws(al, refali, DefaultSecW(), PwIndDist() );
      cout << (const string)dws << ": " << (int)dws << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << dws.colVal[i] << " ";
      cout << endl;

      DiffScore dsews(al, refali, dSecW, PwIndDist() );
      cout << (const string)dsews << ": " << (int)dsews << endl;
      for (unsigned int i=0; i< al.aliLength(); i++)
	cout << dsews.colVal[i] << " ";
      cout << endl;

      PwDistDynPrg pwdu(al, EditDistMatrix());
      cout << (const string)pwdu << " scale: " << pwdu.scaleMaxTo << endl;
      for (unsigned int i=0; i < al.numOfSeq(); i++) {
	for (unsigned int j=0; j < al.numOfSeq(); j++)
	  cout << setprecision(6) << setw(10) << pwdu.d(i,j);
	cout << endl;
      }

      PwDistDynPrg pwds(al, EditDistMatrix(), 1);
      cout << (const string)pwds << " scale: " << pwds.scaleMaxTo << endl;
      for (unsigned int i=0; i < al.numOfSeq(); i++) {
	for (unsigned int j=0; j < al.numOfSeq(); j++)
	  cout << setprecision(6) << setw(10) << pwds.d(i,j);
	cout << endl;
      }

      printAlignmentParam( cerr, al ) << endl;
      printAlignmentWithScore( cerr, al, dsews ) << endl;
      printAlignmentSecWithScore( cerr, al, dsews ) << endl;
      */
    } catch (Exception e) {
      cerr << (const string)e << endl;
    }
    } 
  /*
  Alchar a1('A', 0, SecStructure(SecStructure::ALPHA, 5, 15)),
    a2('A', 0, SecStructure(SecStructure::BETA, 5, 15));

  SecWeightFunc *blsf2= new LinearFixed( 3 ),
    *blsf1 = new LinearFixed( 2 ),
    *blsf22= new LinearFixed( 3, 2 ), 
    *blsf12= new LinearFixed( 2, 2 ),
    *blsp2= new LinearProp( 3 ),
    *blsp1= new LinearProp( 2 ),
    *blsp225= new LinearProp( 3, .25 ), 
    *blsp113= new LinearProp( 2, 1./3 );	    

  IndepSecW bl0( blsf2, blsf1 ),
    bl2( blsf22, blsf12 ),
    blp0( blsp2, blsp1 ),
    blp25( blsp225, blsp113 );

  for (unsigned int i=0; i < 20; i++) {
    a1.pos= a2.pos= i;
    cout << setw(2) << i << ": " << setw(6) << setprecision(4) << bl0.w(a1)
	 << setw(6) << setprecision(4) << bl0.w(a2)
	 << setw(6) << setprecision(4) << bl2.w(a1) 
	 << setw(6) << setprecision(4) << bl2.w(a2) 
	 << setw(6) << setprecision(4) << blp0.w(a1) 
	 << setw(6) << setprecision(4) << blp0.w(a2) 
	 << setw(6) << setprecision(4) << blp25.w(a1) 
	 << setw(6) << setprecision(4) << blp25.w(a2) << endl;
  }
  */

}
