|
bpp-seq 2.0.3
|
00001 // 00002 // File: AbstractISequence2.h 00003 // Created by: Julien Dutheil 00004 // Created on: mon 27 jun 16:30 2005 00005 // 00006 00007 /* 00008 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004) 00009 00010 This software is a computer program whose purpose is to provide classes 00011 for sequences analysis. 00012 00013 This software is governed by the CeCILL license under French law and 00014 abiding by the rules of distribution of free software. You can use, 00015 modify and/ or redistribute the software under the terms of the CeCILL 00016 license as circulated by CEA, CNRS and INRIA at the following URL 00017 "http://www.cecill.info". 00018 00019 As a counterpart to the access to the source code and rights to copy, 00020 modify and redistribute granted by the license, users are provided only 00021 with a limited warranty and the software's author, the holder of the 00022 economic rights, and the successive licensors have only limited 00023 liability. 00024 00025 In this respect, the user's attention is drawn to the risks associated 00026 with loading, using, modifying and/or developing or reproducing the 00027 software by the user in light of its specific status of free software, 00028 that may mean that it is complicated to manipulate, and that also 00029 therefore means that it is reserved for developers and experienced 00030 professionals having in-depth computer knowledge. Users are therefore 00031 encouraged to load and test the software's suitability as regards their 00032 requirements in conditions enabling the security of their systems and/or 00033 data to be ensured and, more generally, to use and operate it in the 00034 same conditions as regards security. 00035 00036 The fact that you are presently reading this means that you have had 00037 knowledge of the CeCILL license and that you accept its terms. 00038 */ 00039 00040 #ifndef _ABSTRACTISEQUENCE2_H_ 00041 #define _ABSTRACTISEQUENCE2_H_ 00042 00043 #include "../Container/AlignedSequenceContainer.h" 00044 #include "../Alphabet/Alphabet.h" 00045 #include "ISequence.h" 00046 00047 // From the STL: 00048 #include <string> 00049 #include <iostream> 00050 #include <fstream> 00051 00052 namespace bpp 00053 { 00054 00058 class AbstractIAlignment: 00059 public virtual IAlignment 00060 { 00061 00062 public: 00063 AbstractIAlignment() {} 00064 virtual ~AbstractIAlignment() {} 00065 00066 public: 00067 00081 virtual void read(std::istream& input, SiteContainer& sc) const throw (Exception) 00082 { 00083 appendFromStream(input, sc); 00084 } 00085 00086 protected: 00096 virtual void appendFromStream(std::istream& input, SiteContainer& sc) const throw (Exception) = 0; 00097 00098 public: 00106 virtual void read(const std::string& path, SiteContainer& sc) const throw (Exception) 00107 { 00108 appendFromFile(path, sc); 00109 } 00110 00111 protected: 00119 virtual void appendFromFile(const std::string& path , SiteContainer& sc) const throw (Exception) 00120 { 00121 std::ifstream input(path.c_str(), std::ios::in); 00122 read(input, sc); 00123 input.close(); 00124 } 00125 00126 public: 00127 virtual 00128 #if defined(NO_VIRTUAL_COV) 00129 SequenceContainer* 00130 #else 00131 AlignedSequenceContainer* 00132 #endif 00133 read(std::istream& input, const Alphabet* alpha) const throw (Exception) 00134 { 00135 return readFromStream(input, alpha); 00136 } 00137 00138 protected: 00147 virtual 00148 #if defined(NO_VIRTUAL_COV) 00149 SequenceContainer* 00150 #else 00151 AlignedSequenceContainer* 00152 #endif 00153 readFromStream(std::istream& input, const Alphabet* alpha) const throw (Exception) 00154 { 00155 AlignedSequenceContainer* asc = new AlignedSequenceContainer(alpha); 00156 appendFromStream(input, *asc); 00157 return asc; 00158 } 00159 00160 public: 00161 virtual 00162 #if defined(NO_VIRTUAL_COV) 00163 SequenceContainer* 00164 #else 00165 AlignedSequenceContainer* 00166 #endif 00167 read(const std::string& path , const Alphabet* alpha) const throw (Exception) 00168 { 00169 AlignedSequenceContainer* asc = new AlignedSequenceContainer(alpha); 00170 read(path, *asc); 00171 return asc; 00172 } 00173 00174 protected: 00183 virtual 00184 #if defined(NO_VIRTUAL_COV) 00185 SequenceContainer* 00186 #else 00187 AlignedSequenceContainer* 00188 #endif 00189 readFromFile(const std::string& path , const Alphabet* alpha) const throw (Exception) 00190 { 00191 AlignedSequenceContainer* asc = new AlignedSequenceContainer(alpha); 00192 appendFromFile(path, *asc); 00193 return asc; 00194 } 00196 }; 00197 00198 } //end of namespace bpp. 00199 00200 #endif // _ABSTRACTISEQUENCE2_H_ 00201