#ifndef __StrandPDB_H

#define __StrandPDB_H

#include <iostream>

using std::endl;
using std::cerr;

/*
CLASS
  StrandPDB
  
  This class defines a set of tools to be used when trying to read beta sheet
  secondary structure from the Protein Data Bank file format.
  

KEYWORDS
  PDB, protein, strand, sheet, parallelism, record, atom, residue, 
  structure, coordinate, field

AUTHORS
  Zipi Fligelamn (zipo@math.tau.ac.il)

  Copyright: SAMBA group, Tel-Aviv Univ. Israel, 1999.

CHANGES LOG
<UL>
<LI> 2.09.01 All PDB indices are shifted, minus one.
</UL>

GOALS
  Class Strand PDB is designed to serve as an encapsulation to reading 
  secondary structure of the beta sheet kind from the PDB file format. 
  Methods are static requiring no object instantiation before their use.

USAGE
  The user is highly recommended not to use this class directly but through
  the Sheet or SecondStruct class. Though regarding that a line in the PDB
  record has a length of 80 chars. Acoording to the latest submittion manual 
  the differnt fields and their charechteristic type were defined.
*/
class StrandPDB 
{
public:
  // GROUP: relative parallelism between the strand in the sheets defintion
  const static short Parallel = 1;
  const static short AntiParallel = -1;
  const static short FirstStrand = 0;
  typedef short RelativeParallelism;
  
  // GROUP: SHEET record constants and methods

  const static short strandNumberField = 7;
  const static short sheetIDField = 11;
  const static short numStrandsField = 14;
  const static short initResNameField = 17;
  const static short initChainIdField = 21;
  const static short initSeqNumField = 22;
  const static short initICodeField = 26;
  const static short endResNameField = 28;
  const static short endChainIdField = 32;
  const static short endSeqNumField = 33;
  const static short endICodeField = 37;
  const static short senseField = 38;
  const static short curAtomField = 41;
  const static short curResNameField =45;
  const static short curChainIdField = 49;
  const static short curResSeqField = 50;
  const static short curICodeField = 54;
  const static short prevAtomField = 56;
  const static short prevResNameField = 60;
  const static short prevChainIdField = 64;
  const static short prevResSeqField = 65;
  const static short prevICodeField = 69;

  // GROUP: the Strand and the Sheet infromation and methods
  
  //// Returns whether the record is of the desired type
  static bool isStrand(const char* const PDBrec);

  //// Returns the strand number inside the sheet
  static short strandNum(const char* const PDBrec);

  //// Copies a three chars that indicate the Sheet Id inside the molecule 
  static void strandSheetId(const char* const PDBrec, char id[]);

  //// Returns the number of strands in this sheet should be consistent
  // in all the Sheet records
  static short numOfStrandsInSheet(const char* const PDBrec);

  //// Returns the name of the amino acid in the 3 letter code 
  // that begins this particular starnd.
  static void initResName(const char* const PDBrec,char res[]);
  
  //// Returns the chain Id (if exist) of the begining of the strand.
  static char initChainId(const char* const PDBrec);
  
  //// Returns the sequence number of the starting residue of the Strand
  // please notice! that this residue is relative to the chain 
  // if you read the atoms through the Atom class you might find
  // that atom 25 in chain B has a different numbering there
  static int initSeqNum(const char* const PDBrec);
  
  static char initICode(const char* const PDBrec);
  
  //// Returns the name of the amino acid in the 3 letter code 
  // that ends this particular strand.
  static void endResName(const char* const PDBrec,char res[]);
  
  //// Returns the chain Id (if exist) of the ending of the strand.
  static char endChainId(const char* const PDBrec);
  
  //// Returns the sequence number of the ending residue of the Strand
  // please notice! that this residue is relative to the chain 
  // if you read the atoms through the Atom class you might find
  // that atom 25 in chain B has a different numbering there
  static int endSeqNum(const char* const PDBrec);
  
  static char endICode(const char* const PDBrec);
  
  //// This will return the appropriate constant on the strand's parallelism
  // relative to the previous strand in the sheet
  // NOTICE: the first strand has no previosu strand to realte to
  static RelativeParallelism sense(const char* const PDBrec);

  // Group : the Strand Connection Information
  
  //// Returns the first atom in the current strand to create the chemical
  // bond with the previous strand. Asuumed to be either N (the hydrogen 
  // that is connected to the nytrogen group) or O. Notice no assertion
  // is made regarding this since in the first strand this line is empty
  static char currAtom(const char* const PDBrec);

  //// The name of the residue in which the atom making the connection reside
  static void currResName(const char* const PDBrec, char res[]);
  
  //// The appropriate chain Id of the atom and the related resiue
  static char currChainId(const char* const PDBrec);
  
  //// The residue relative number in the chain
  static int  currResSeq(const char* const PDBrec);
  
  static char currICode(const char* const PDBrec);
  
  //// Returns the first atom in the previous strand to create the chemical
  // bond with the previous strand. Asuumed to be either N (the hydrogen 
  // that is connected to the nytrogen group) or O. Notice no assertion
  // is made regarding this since in the first strand this line is empty
  static char prevAtom(const char* const PDBrec);
  
  //// The name of the residue in which the atom making the connection reside
  static void prevResName(const char* const PDBrec, char res[]);
  
  //// The appropriate chain Id of the atom and the related residue
  static char prevChainId(const char* const PDBrec);
  
  //// The residue relative number in the chain. Please notice that
  // this number is in the range of the previous strand atom numbers
  static int  prevResSeq(const char* const PDBrec);
  
  static char prevICode(const char* const PDBrec);
  
private:
  StrandPDB() {}
};
#endif



