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