Generated on Tue Dec 16 12:49:16 2008 for BIU-2.2.0 by doxygen 1.5.1

src/biu/OffLatticeProtein.cc

Go to the documentation of this file.
00001 #include <biu/OffLatticeProtein.hh>
00002 #include <fstream>
00003 #include <stdlib.h>
00004 
00005 
00006 namespace biu
00007 {
00008     OffLatticeProtein::OffLatticeProtein(const std::string& coordinatesFileName,
00009                         const Alphabet* const _alphabet)
00010         :   pData(new DPointVec()), 
00011             alphabet(_alphabet), 
00012             sequence(NULL) 
00013      {
00014         std::ifstream ifs;
00015         ifs.open(coordinatesFileName.c_str());
00016         if (!ifs) {
00017             std::cerr<< "ERROR OffLatticeProtein::OffLatticeProtein : "+
00018              coordinatesFileName+" kann nicht ge�ffnet werden.";
00019             delete pData;
00020             exit(-1);
00021         }
00022 
00023         double x, y, z;
00024         char aa;
00025         std::string remark, seqStr = "";
00026         
00027         // ignore remarks (#...)
00028         while(ifs.peek() == '#') {
00029             getline(ifs, remark);
00030         }
00031         while(ifs >> aa >> x >> y >> z) {
00032             pData->push_back(DblPoint(x, y, z));
00033             seqStr += aa;
00034         }
00035         ifs.close();
00036 
00037         assertbiu(alphabet->isAlphabetString(seqStr),
00038          "AA sequence contains characters which are not in the alphabet.");
00039         sequence = new Sequence(alphabet->getSequence(seqStr));
00040     }
00041 
00042     OffLatticeProtein::OffLatticeProtein(   const DPointVec& data3D, 
00043                                             const Alphabet* const _alphabet, 
00044                                             const std::string& seqStr) 
00045      : pData(new DPointVec(data3D)), alphabet(_alphabet), sequence(NULL) 
00046     {
00047         assertbiu(alphabet != NULL,  "alphabet is not allowed to be NULL.");
00048         sequence = new Sequence(alphabet->getSequence(seqStr));
00049         assertbiu(pData->size() == sequence->size(),
00050             "Structure and sequence have to have the same length.");
00051     }
00052 
00053     OffLatticeProtein::OffLatticeProtein( const OffLatticeProtein& offLatPro)
00054      :  pData(new DPointVec(*(offLatPro.pData))), 
00055         alphabet(offLatPro.alphabet),
00056         sequence(new Sequence(*(offLatPro.sequence))) 
00057     {
00058         assertbiu(alphabet != NULL,  "alphabet is not allowed to be NULL.");
00059         assertbiu(pData->size() == sequence->size(),
00060          "Structure and sequence have to have the same length.");
00061     }
00062     
00063     OffLatticeProtein::~OffLatticeProtein() {
00064         delete pData; pData = NULL;
00065         delete sequence; sequence = NULL;
00066     }
00067 
00068     
00069     OffLatticeProtein& 
00070     OffLatticeProtein::operator= ( const OffLatticeProtein& offLatPro2) 
00071     {
00072         if (this != &offLatPro2) {
00073             delete pData;
00074             pData = new DPointVec(*(offLatPro2.pData));
00075             delete sequence;
00076             sequence = new Alphabet::Sequence(*(offLatPro2.sequence));
00077             alphabet = offLatPro2.alphabet;
00078         }
00079         return *this;
00080     }
00081 
00082     void        
00083     OffLatticeProtein::writePDB(const std::string& pdbFileName) {
00084     //TODO
00085     }
00086     
00087     LatticeProtein* 
00088     OffLatticeProtein::approximateToLattice(const LatticeModel* const lattice,  
00089                 const DistanceEnergyFunction* const energy) const 
00090     {
00091     //TODO
00092         return NULL;
00093     }
00094 
00095     DPointVec   
00096     OffLatticeProtein::get3Ddata() const{
00097         return *pData;  
00098     }
00099     
00100     double      
00101     OffLatticeProtein::getDRMSD(const BackboneStructure3D& other) const{
00102 // TODO implementieren
00103     /*  DPointVec other3Ddata = other.get3Ddata();
00104         assertbiu(pData->size() == other3Ddata->size(),
00105          "Structure and sequence have to have the same length.");
00106         double rmsd = 0;
00107         for(int k=0; k<i; k++)
00108                 for(int l=k+1; l<=i; l++)
00109                         rmsd += pow( pos[k].dist(pos[l]) - (scaling * conformation[k].dist(conformation[l])), 2);
00110         rmsd /= ((i+1)*i /2);   // Index i => Kettenlaenge i+1
00111         return sqrt(rmsd);*/
00112         return 0.0;
00113 
00114     }
00115 
00116 
00117 
00118 
00119 }