NAMD
Public Member Functions | Public Attributes | List of all members
ResidueLookupElem Class Reference

#include <Molecule.h>

Public Member Functions

 ResidueLookupElem (void)
 
 ~ResidueLookupElem (void)
 
int lookup (const char *segid, int resid, int *begin, int *end) const
 
ResidueLookupElemappend (const char *segid, int resid, int aid)
 

Public Attributes

char mySegid [11]
 
ResidueLookupElemnext
 
int firstResid
 
int lastResid
 
ResizeArray< int > atomIndex
 

Detailed Description

Definition at line 88 of file Molecule.h.

Constructor & Destructor Documentation

ResidueLookupElem::ResidueLookupElem ( void  )
inline

Definition at line 97 of file Molecule.h.

References firstResid, lastResid, and next.

97 { next = 0; firstResid = -1; lastResid = -1; }
ResidueLookupElem * next
Definition: Molecule.h:92
ResidueLookupElem::~ResidueLookupElem ( void  )
inline

Definition at line 98 of file Molecule.h.

References next.

98 { delete next; }
ResidueLookupElem * next
Definition: Molecule.h:92

Member Function Documentation

ResidueLookupElem * ResidueLookupElem::append ( const char *  segid,
int  resid,
int  aid 
)

Definition at line 89 of file Molecule.C.

References atomIndex, endi(), iout, iWARN(), and next().

90  {
91  ResidueLookupElem *rval = this;
92  if ( firstResid == -1 ) { // nothing added yet
93  strcpy(mySegid,segid);
94  firstResid = resid;
95  lastResid = resid;
96  atomIndex.add(aid);
97  atomIndex.add(aid+1);
98  } else if ( ! strcasecmp(mySegid,segid) ) { // same segid
99  if ( resid == lastResid ) { // same resid
100  atomIndex[lastResid - firstResid + 1] = aid + 1;
101  } else if ( resid < lastResid ) { // error
102  // We can work around this by creating a new segment.
103  iout << iWARN << "Residue " << resid <<
104  " out of order in segment " << segid <<
105  ", lookup for additional residues in this segment disabled.\n" << endi;
106  rval = next = new ResidueLookupElem;
107  next->append(segid,resid,aid);
108  } else { // new resid
109  for ( ; lastResid < resid; ++lastResid ) atomIndex.add(aid);
110  atomIndex[lastResid - firstResid + 1] = aid + 1;
111  }
112  } else { // new segid
113  rval = next = new ResidueLookupElem;
114  next->append(segid,resid,aid);
115  }
116  return rval;
117 }
std::ostream & iWARN(std::ostream &s)
Definition: InfoStream.C:108
#define iout
Definition: InfoStream.h:87
ResidueLookupElem * next
Definition: Molecule.h:92
ResidueLookupElem(void)
Definition: Molecule.h:97
char mySegid[11]
Definition: Molecule.h:91
ResidueLookupElem * append(const char *segid, int resid, int aid)
Definition: Molecule.C:89
int add(const Elem &elem)
Definition: ResizeArray.h:97
infostream & endi(infostream &s)
Definition: InfoStream.C:38
ResizeArray< int > atomIndex
Definition: Molecule.h:95
int ResidueLookupElem::lookup ( const char *  segid,
int  resid,
int *  begin,
int *  end 
) const

Definition at line 76 of file Molecule.C.

References atomIndex, firstResid, mySegid, and next.

Referenced by Molecule::prepare_qm().

77  {
78  const ResidueLookupElem *elem = this;
79  int rval = -1; // error
80  while ( elem && strcasecmp(elem->mySegid,segid) ) elem = elem->next;
81  if ( elem && (resid >= elem->firstResid) && (resid <= elem->lastResid) ) {
82  *begin = elem->atomIndex[resid - elem->firstResid];
83  *end = elem->atomIndex[resid - elem->firstResid + 1];
84  rval = 0; // no error
85  }
86  return rval;
87 }
ResidueLookupElem * next
Definition: Molecule.h:92
char mySegid[11]
Definition: Molecule.h:91
ResizeArray< int > atomIndex
Definition: Molecule.h:95

Member Data Documentation

ResizeArray<int> ResidueLookupElem::atomIndex

Definition at line 95 of file Molecule.h.

Referenced by lookup().

int ResidueLookupElem::firstResid

Definition at line 93 of file Molecule.h.

Referenced by lookup(), and ResidueLookupElem().

int ResidueLookupElem::lastResid

Definition at line 94 of file Molecule.h.

Referenced by ResidueLookupElem().

char ResidueLookupElem::mySegid[11]

Definition at line 91 of file Molecule.h.

Referenced by lookup().

ResidueLookupElem* ResidueLookupElem::next

Definition at line 92 of file Molecule.h.

Referenced by lookup(), ResidueLookupElem(), and ~ResidueLookupElem().


The documentation for this class was generated from the following files: