00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_IO_ENTITY_IO_PLUGIN_CRD_H
00020 #define OST_IO_ENTITY_IO_PLUGIN_CRD_H
00021
00022
00023
00024
00025
00026 #include <ost/io/mol/entity_io_handler.hh>
00027
00028 #include <boost/iostreams/filtering_stream.hpp>
00029 #include <boost/filesystem/fstream.hpp>
00030
00031 namespace ost { namespace io {
00032
00033 class DLLEXPORT_OST_IO CRDReader {
00034 public:
00035 CRDReader(const boost::filesystem::path& loc);
00036
00037 void Import(mol::EntityHandle& ent);
00038
00039 std::vector<mol::AtomHandle> GetSequentialAtoms() const;
00040
00041 private:
00042
00043 void ParseAndAddAtom(const String& line, mol::EntityHandle& h);
00044
00045 std::vector<mol::AtomHandle> sequential_atom_list_;
00046 mol::ChainHandle curr_chain_;
00047 mol::ResidueHandle curr_residue_;
00048 int chain_count_;
00049 int residue_count_;
00050 int atom_count_;
00051 boost::filesystem::ifstream infile_;
00052 boost::iostreams::filtering_stream<boost::iostreams::input> in_;
00053 };
00054
00055
00056 class DLLEXPORT_OST_IO CRDWriter : public mol::EntityVisitor {
00057 public:
00058 CRDWriter(const String& filename);
00059 CRDWriter(const boost::filesystem::path& filename);
00060 CRDWriter(std::ostream& outstream);
00061
00062 virtual bool VisitAtom(const mol::AtomHandle& atom);
00063
00064 void WriteHeader(const mol::EntityView& ent);
00065
00066 private:
00067 std::ofstream outfile_;
00068 std::ostream& outstream_;
00069 int atom_count_;
00070 };
00071
00072 class DLLEXPORT_OST_IO EntityIOCRDHandler: public EntityIOHandler {
00073 public:
00074 virtual void Import(mol::EntityHandle& ent, const boost::filesystem::path& loc);
00075
00076 virtual void Export(const mol::EntityView& ent,
00077 const boost::filesystem::path& loc) const;
00078
00079 virtual void Import(mol::EntityHandle& ent, std::istream& stream);
00080
00081 virtual void Export(const mol::EntityView& ent, std::ostream& stream) const;
00082
00083 static bool ProvidesImport(const boost::filesystem::path& loc,
00084 const String& format="auto");
00085 static bool ProvidesExport(const boost::filesystem::path& loc,
00086 const String& format="auto");
00087 virtual bool RequiresBuilder() const;
00088
00089 static String GetFormatName() { return String("Crd"); }
00090 static String GetFormatDescription() { return String("CARD format file used by the Charmm software package"); }
00091 };
00092
00093
00094 typedef EntityIOHandlerFactory<EntityIOCRDHandler> EntityIOCRDHandlerFactory;
00095
00096 mol::EntityHandle DLLEXPORT_OST_IO LoadCRD(const String& file_name);
00097
00098 }}
00099
00100 #endif