////////////////////////////////////////////////////////////////////////
//
// iotools.C - 
//
// $Id: iotools.C,v 1.1 2001/12/30 21:02:43 goetz Exp $
//
////////////////////////////////////////////////////////////////////////

#include "iotools.h"

#include <iostream.h>
#include <iomanip.h>

ostream & printAlignmentParam( ostream &os, const Alignment &a)
{
  // determine shortest and longest original length
  unsigned int min(0), max(0);
  for (unsigned int i=1; i < a.numOfSeq(); i++) {
    if (a.origLength[i] < a.origLength[min])
      min= i;
    if (a.origLength[i] > a.origLength[max])
      max= i;
  }

  return os << "Alignment: " << a.name << endl
	    << "Sec_info: " << ( a.hasSecStr ? 1 : 0 ) << endl
	    << "Num_seq: " << a.numOfSeq() << endl
	    << "Ali_len: " << a.aliLength() << endl
	    << "shortest_orig: " << a.origLength[min] << endl
	    << "longest_orig: " << a.origLength[max] << endl;
}

ostream & printAlignmentWithScore( ostream &os, const Alignment &a,
				   const Score &s )
{
  unsigned int alen(a.aliLength()), numseq(a.numOfSeq());
  os << "Alignment: " << a.name << " Score (" << (const string)s 
     << ")= " << (int)s << endl;

  for (unsigned int i=0; i < alen; i++) {
    os << setw(4) << i << " sc= " << setw(7) << s.colVal[i] << "   -   ";
    for (unsigned int j=0; j < numseq; j++) 
      os << a.sequences[j][i].c;
    os << endl;
  }
  return os;
}

ostream & printAlignmentSecWithScore( class ostream &os,
				      const Alignment &a,
				      const Score &s )
{
  unsigned int alen(a.aliLength()), numseq(a.numOfSeq());
  os << "Alignment: " << a.name << " Score (" << (const string)s 
     << ")= " << (int)s << endl;

  for (unsigned int i=0; i < alen; i++) {
    os << setw(4) << i << " sc= " << setw(7) << s.colVal[i] << "   -   ";
    for (unsigned int j=0; j < numseq; j++) 
      os << a.sequences[j][i].c 
	 << a.sequences[j][i].secstr;
    os << endl;
  }
  return os;
}
