00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef MTZ_IO_HEAD
00010 #define MTZ_IO_HEAD
00011
00012 #include <string>
00013 #include <map>
00014
00015
00016 #include "clipper/clipper.h"
00017 #include "clipper/clipper-ccp4.h"
00018 using clipper::Message;
00019 using clipper::Message_fatal;
00020
00021
00022
00023 #include "csymlib.h"
00024 #include "ccp4_parser.h"
00025 #include "ccp4_general.h"
00026 #include "cmtzlib.h"
00027
00028 #include "hkl_datatypes.hh"
00029 #include "controls.hh"
00030 #include "columnlabels.hh"
00031 #include "hkl_unmerge.hh"
00032 #include "range.hh"
00033 #include "hash.hh"
00034
00035
00036 using namespace scala;
00037
00038 namespace scala{class FileRead;}
00039
00040 namespace MtzIO {
00041
00042 class MtzUnmrgFile
00044 {
00045 public:
00047 MtzUnmrgFile();
00049 ~MtzUnmrgFile();
00050
00052 bool open_read( const std::string filename_in );
00054 void close_read();
00055
00056
00057
00059 FileRead FillHklList(const std::string& mtzname,
00060 std::string& output,
00061 const int& verbose,
00062 hkl_unmerge_list& hkl_list);
00063
00065
00074 FileRead AddHklList(const int& fileSeries,
00075 const std::string& mtzname,
00076 file_select& file_sel,
00077 col_controls& column_selection,
00078 MtzIO::column_labels& column_list,
00079 const all_controls& controls,
00080 const scala::PxdName& InputPxdName,
00081 const scala::Scell& cell,
00082 const double& cellTolerance,
00083 std::string& output,
00084 const int& verbose,
00085 hkl_unmerge_list& hkl_list);
00110
00112 int Nrec() const {return Nrecl_file;}
00114 int Ncols() const {return Ncolumns;}
00116 bool Sorted() const {return sorted;}
00118 bool Merged() const {return merged;}
00120 scala::SpaceGroup Spacegroup() const {return spacegroup_;}
00122 std::vector<Batch> BatchList();
00124 scala::Scell Cell() const {return averagecell;}
00125
00127 CMtz::MTZ* mtz_file() const {return mtzin;}
00129 ResoRange ResRangeFile() const
00130 {return ResoRange(Range(minres, maxres));}
00132 ResoRange ResRange() const {return resrange;}
00133
00135 void Rewind();
00137 bool Rrefl(std::vector<float>& cols, std::vector<bool>& col_mnf);
00138
00141 bool get_dataset(const int& kdataset, Xdataset& this_dataset) const;
00144 bool get_batch(const int& kbatch, CMtz::MTZBAT& this_batch) const;
00146 std::string get_title() const {return title;}
00148 std::string FilenameIn() const {return filename_in_;}
00150 column_select ColumnSelect() const {return col_select;}
00151
00152 column_labels ColumnLabels()const {return column_list;}
00153
00154 private:
00155 enum MTZmode { NONE, READ, WRITE, APPEND };
00157 CMtz::MTZ* mtzin;
00158 MTZmode mode;
00159 std::string filename_in_, filename_out_;
00160 scala::SpaceGroup spacegroup_;
00161 CMtz::SYMGRP mtzsym;
00162 std::string title;
00163
00164 std::vector<Xdataset> xdatasets;
00165 std::vector<CMtz::MTZBAT*> mtzbatches;
00166
00167 std::vector<Xdataset> datasets;
00168 std::vector<Batch> batches;
00169 std::vector<Run> runs;
00170 std::vector<int> offsets;
00171
00172 Scell averagecell;
00173 bool sorted;
00174 bool merged;
00175
00176 int IrefCnt;
00177 int Ncolumns;
00178
00179 int Nrecl_file;
00180 float minres, maxres;
00181 ResoRange resrange;
00182 int Nrej_batch;
00183
00184 column_select col_select;
00185 MtzIO::column_labels column_list;
00186
00187
00188 int read_datasets(const CMtz::MTZ* mtzin,
00189 std::vector<Xdataset>& Xdatasets);
00190 bool read_batches(const CMtz::MTZ* mtzin,
00191 std::vector<CMtz::MTZBAT*>& mtzbatches);
00192
00193 Scell get_dset_batch_info(const int& fileSeries,
00194 const file_select& file_sel,
00195 const scala::PxdName& InputPxdName,
00196 const scala::Scell& cell,
00197 const column_select& col_sel,
00198 bool& DifferentCell);
00199
00200 int get_refs(hkl_unmerge_list& hkl_list,
00201 file_select& file_sel,
00202 const column_select& col_sel,
00203 const Scell& averagecell,
00204 bool& ChangeIndex);
00205
00206 bool IsCompatible(const hkl_unmerge_list& hkl_list,
00207 const double& cellTolerance) const;
00208
00209
00210 void MakeRuns();
00211
00212
00213 bool FileSorted() const;
00214
00215 void OffsetBatches();
00216
00217
00218
00219
00220
00221 void get_col_lookup(column_labels& ColumnLabels);
00222
00223
00224 };
00225
00226
00227
00228 }
00229
00230 #endif