ResidueLookupElem Class Reference

#include <Molecule.h>

List of all members.

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.

00097 { next = 0; firstResid = -1; lastResid = -1; }

ResidueLookupElem::~ResidueLookupElem ( void   )  [inline]

Definition at line 98 of file Molecule.h.

References next.

00098 { delete next; }


Member Function Documentation

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

Definition at line 89 of file Molecule.C.

References ResizeArray< Elem >::add(), append(), atomIndex, endi(), firstResid, iout, iWARN(), lastResid, mySegid, and next.

Referenced by append().

00090                                                {
00091     ResidueLookupElem *rval = this;
00092     if ( firstResid == -1 ) {  // nothing added yet
00093       strcpy(mySegid,segid);
00094       firstResid = resid;
00095       lastResid = resid;
00096       atomIndex.add(aid);
00097       atomIndex.add(aid+1);
00098     } else if ( ! strcasecmp(mySegid,segid) ) {  // same segid
00099       if ( resid == lastResid ) {  // same resid
00100         atomIndex[lastResid - firstResid + 1] = aid + 1;
00101       } else if ( resid < lastResid ) {  // error
00102         // We can work around this by creating a new segment.
00103         iout << iWARN << "Residue " << resid <<
00104           " out of order in segment " << segid <<
00105           ", lookup for additional residues in this segment disabled.\n" << endi;
00106         rval = next = new ResidueLookupElem;
00107         next->append(segid,resid,aid);
00108       } else {  // new resid
00109         for ( ; lastResid < resid; ++lastResid ) atomIndex.add(aid);
00110         atomIndex[lastResid - firstResid + 1] = aid + 1;
00111       }
00112     } else {  // new segid
00113       rval = next = new ResidueLookupElem;
00114       next->append(segid,resid,aid);
00115     }
00116     return rval;
00117 }

int ResidueLookupElem::lookup ( const char *  segid,
int  resid,
int *  begin,
int *  end 
) const

Definition at line 76 of file Molecule.C.

References atomIndex, firstResid, lastResid, mySegid, and next.

Referenced by Molecule::get_atom_from_index_in_residue(), Molecule::get_atom_from_name(), and Molecule::get_residue_size().

00077                                                                   {
00078     const ResidueLookupElem *elem = this;
00079     int rval = -1;  // error
00080     while ( elem && strcasecmp(elem->mySegid,segid) ) elem = elem->next;
00081     if ( elem && (resid >= elem->firstResid) && (resid <= elem->lastResid) ) {
00082       *begin = elem->atomIndex[resid - elem->firstResid];
00083       *end = elem->atomIndex[resid - elem->firstResid + 1];
00084       rval = 0;  // no error
00085     }
00086     return rval;
00087 }


Member Data Documentation

ResizeArray<int> ResidueLookupElem::atomIndex

Definition at line 95 of file Molecule.h.

Referenced by append(), and lookup().

int ResidueLookupElem::firstResid

Definition at line 93 of file Molecule.h.

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

int ResidueLookupElem::lastResid

Definition at line 94 of file Molecule.h.

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

char ResidueLookupElem::mySegid[11]

Definition at line 91 of file Molecule.h.

Referenced by append(), and lookup().

ResidueLookupElem* ResidueLookupElem::next

Definition at line 92 of file Molecule.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Nov 21 01:17:20 2017 for NAMD by  doxygen 1.4.7