
/*
	file:		print.c
	purpose:	print file for area. 
*/

#include "area.h" 

char 	*get_date();

/*************************************************************/
/* Print info about this run. 
*/
void print_run()
{

	fprintf(resfp, "\n");
	fprintf(resfp, "************************************************************\n");
	fprintf(resfp, "\n");
	fprintf(resfp, "   Program.....................: area (version %s)\n", VERSION);
	fprintf(resfp, "   Description.................: Calculate Area\n");
	fprintf(resfp, "   Date........................: %s\n\n", get_date());
	fprintf(resfp, "   Probe Radius................: %1.3f\n\n", probeRadius);
	fprintf(resfp, "   Vanderwaals Radius Values...: ");
	if (radType == CHOTH_RAD)
		fprintf(resfp, "Chothia\n");
	else if (radType == EIS_RAD)
		fprintf(resfp, "Eisenberg\n");
	else if (radType == RICH_RAD)
		fprintf(resfp, "Richards\n");
	else if (radType == SHRAKE_RAD)
		fprintf(resfp, "Shrake\n");
	fprintf(resfp, "\n");
	fprintf(resfp, "************************************************************\n");
	fprintf(resfp, "\n");

}	/* print_run */


/*************************************************************/
/* print header for residues 
*/
void print_res_header()
{

	fprintf(resfp, "R.NUM R.NAME  ResASA   FracASA  ResVol   FracVol  SideASA  SideFracASA   SFE   Hydrophobicity\n\n");

}	/* print_res_header */


/*************************************************************/
/* print header for atoms 
*/
void print_atom_header()

{
	fprintf(atomfp, "         ATOM  RES   RES                           VAN.   COV.       ASA\n");
	fprintf(atomfp, "         NAME  NAME  NUM   X       Y       Z       RADII  RADII      ASA\n");
	fprintf(atomfp, "         ----  ----  ----  ------  ------  ------  -----  -----   --------\n\n");
	fprintf(atomfp, "BEGIN\n");

}	/* print_atom_header */


/*************************************************************/
/* print output for one atom.
*/
void output_atom(atom)
ATOM_REC	atom;
{

	fprintf(atomfp, "00 00 00 %-3s   %-3s   %-4d%8.3f%8.3f%8.3f  %5.2f  %5.2f  %8.3f 0\n", 
		atom.atomName, atom.resName, atom.resNum,
		atom.x, atom.y, atom.z,
		atom.rad[VAN], atom.rad[COV], atom.contactArea);
			// Number format for x, y, z coordinates changed from %6.3f to %8.3f, with spaces
			// deleted to compensate. The Fortran code in Volume.F, line 199, was also changed.
			// This allows for atom coordinates occupying more than 6 digits, e.g.
			// -26.198 or -126.198.
			// Changed by David Arndt, Nov 23, 2007.

}	/* output_atom */


/*************************************************************/
/* print output for one residue.
*/
void output_res()
{

	fprintf(resfp, "%-4d  %-3s   %8.3f\n",
			lastNum, lastName, contactTotal);

}	/* output_res */



/*************************************************************/
/* print output for one residue.
*/
void output_res_all( ofres, n )
OUT_FEATURE_REC *ofres;
int n;
{
    int i;
    char label[8];
    int lastResNum = -999999;

	print_res_header();

    for (i=0; i < n; i++) {
        if (ofres[i].resNum != lastResNum) {
            lastResNum = ofres[i].resNum;
            // sprintf(label, "%d%c",ofres[i].resNum, ofres[i].insCode);
            sprintf(label, "%d",ofres[i].resNum);  // right now, only use 1st case of residue
            // add incCode    
            fprintf(resfp, "%-5s  %-3s  %8.1f  %8.2f  %8.1f  %8.2f  %8.1f  %8.2f  %8.1f  %8.3f\n",
                            label, ofres[i].resName,
                           // ofres[i].ss,
                            ofres[i].resASA, ofres[i].resFracASA, 
                            ofres[i].resVol, ofres[i].resFracVol,
                            ofres[i].sideASA, ofres[i].sideFracASA, ofres[i].sfe,
                            ofres[i].hydrophobicity);
        }
    }
}	/* output_res */
