#ifndef __GET_ANGLES_H__
#define __GET_ANGLES_H__


#define CA_CA_GAP_THRESHOLD 4.0
	// If two neighboring residues in a sequence have a C-alpha to C-alpha distance greater than this value
	// (in Angstroms), we call a gap between the two residues.
#define ANGLE_NA -1000000

#define MAX_FNAME_LEN  256    

/* this structure is going to hold the information of H bonds btw two residues*/
typedef struct Hcontainer{
		int  index;// current res index that will donate C==O
		int  oppo_index[20];  // res index that will donate H atoms from back bone or side chain
		char  oppo_atom_name[20][15][5]; // H atom name of res that will donate H atoms 
		double theta[20][15]; // theta angles for above H bonds
		double kappa[20][15]; // angle bw H bond and C==O plan
		double HO_dist[20][15]; // distance of hydrogen bond.
		int  oppo_res_count; // number of H bonds found for current res
		int single_res_atom_count[20]; // count atom num of  each res with h bonds
}Hcontainer;
/*
 * Note: Comments based on observation by David Arndt.
 *
 * Represents a hydrogen bond. Both residues forming the hydrogen bond will (normally?) have an
 * Hbonds struct.
 */
typedef struct Hbonds {
	int partner;
		// The index of the residue that forms this hydrogen bond with the current residue (where
		// the "current residue" is the one containing this Hbonds struct). -1 means no partner,
		// i.e. this Hbonds struct does not specify a hydrogen bond.
	//int type;
		// The role the current residue plays in the formation of this hydrogen bond. 1 means
		// ACCEPTOR, 2 means DONOR, -1 means that this Hbonds struct does not specify a hydrogen bond.
	float distance;
		// The distance in angstroms between the O atom and the H atom between which the hydrogen
		// bond is formed. -1 means that this Hbonds struct does not specify a hydrogen bond.
	float energy; // The energy for this hydrogen bond.
	int hbond_is_valid; // TRUE if this is a valid hydrogen bond; FALSE if this is an "almost formed" hydrogen bond.
	double theta_angle;// angle of H bond : C==O--H
} Hbonds;


/*
 * Represents a single residue of a peptide.
 */
typedef struct ResData {
	double phi, psi, omega, chi, chi2, chi3, chi4, chi5, N_CA_C1_angle; // chi is chi1
		// N_CA_C1_angle is the angle formed by the N of the previous residue and the CA and C1 of the current residue.
	double theta_donar, theta_recp, kappa_donar, kappa_recp;
        double theta, kappa;
	int id;
		// The residue number as it appears in the PDB file (or Preditor output file if no PDB file is available).
		// This is NOT the same as the index into an array of ResData structs.

    int origResNum;    // original residue number (add. 2011.08.24)
    char insCode; // insertion code if one exist (add. 2011.08.24)

	int max_atom_index;
		// The maximum index into atoms and names of an entry with meaningful data.
	Vec3D atoms[MAX_ATOMS];
		// If fixed_position is FALSE, 'atoms' represents the computed coordinates of each atom of this residue
		// in the overall peptide chain. If fixed_position is TRUE, 'atoms' represents the fixed 3-D coordinates
		// of this residue.
	char names[MAX_ATOMS][5]; // The 4-character names of each atom in this residue.
	Vec3D template[MAX_ATOMS];
		// The coordinates for each atom in this residue, in canonical form. Backbone and sidechain.
		// If PepMake is called without a PDB file, the program will use the default backbone coordinates, as well
		// as the default side-chain coordinates from the template database. If, on the other hand, PepMake is called
		// with a PDB file, then PepMake will call phipsi with the --db flag to generate a residue coordinates file
		// with all residues in canonical form, and then read in this file and save the canonical coordinates in
		// this field.
		// "Canonical form" is: C-alpha at the origin, C on the x-axis, and N below the x-axis (negative y-coordinate)
		// and in the xy plane.
	char resName[4]; // The name of this residue (3-letter residue abbreviation).
	int fixed_position;
		// Boolean. Whether this residue has a fixed position. If it does, then this residue's fixed position
		// will be set in the 'atoms' member variable, and buildPeptide() should not change the position but
		// rather use this residue as a starting position onto which downstream residues (i.e. those closer to
		// the C-terminsu) are built.
	Hbonds hbonds_acceptor[2]; // Hydrogen bonds in which this residue participates as an acceptor.
	Hbonds hbonds_donor[2]; // Hydrogen bonds in which this residue participates as a donor.
	Hbonds hbonds_intended_acc[2];
		// Hydrogen bonds which the program will try to form or optimize, in which this residue participates as an
		// acceptor.
	Hbonds hbonds_intended_don[2];
		// Hydrogen bonds which the program will try to form or optimize, in which this residue participates as a
		// donor. Note: This means that the N-H group for "this" residue ID will be involved in the hydrogen bond,
		// and the coordinates of this N-H group are usually in the previous ResData struct within an array of
		// ResData structs representing a peptide, unless the current ResData is the first one in the array.

	char ss_info; // used to store secondary structure informatioin from secondary structure file. should be 'H', 'L', or 'B'.
	char noe_ss_info; // used to store secondary structure derived from NOE information, should be 'H', 'l', or 'B"
	int ss_frag_index[2]; // to store the start and stop index of the current secondary structure which current residue belongs to.
	int rama_table[36][36]; // point to the corresponding rama talbe that will be used for this residue.
	int noe_ss_score; // use to store the secondary structure score 
} ResData;




#endif
