MASA-Core
AlignmentBinaryFile.hpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2010-2015   Edans Sandes
00004  *
00005  * This file is part of MASA-Core.
00006  * 
00007  * MASA-Core is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation, either version 3 of the License, or
00010  * (at your option) any later version.
00011  * 
00012  * MASA-Core is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with MASA-Core.  If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  ******************************************************************************/
00021 
00022 #ifndef ALIGNMENTBINARYFILE_HPP_
00023 #define ALIGNMENTBINARYFILE_HPP_
00024 
00025 #include <stdio.h>
00026 #include <string>
00027 using namespace std;
00028 
00029 #include "Alignment.hpp"
00030 #include "AlignmentParams.hpp"
00031 #include "SequenceModifiers.hpp"
00032 
00033 
00034 
00035 class AlignmentBinaryFile {
00036 public:
00037         static Alignment* read(string filename);
00038         static void write(string filename, Alignment* alignment);
00039 
00040 private:
00041         static void fwrite_header(FILE* file);
00042         static void fread_header(FILE* file);
00043 
00044         static void fwrite_sequences(vector<SequenceInfo*> sequences, FILE* file);
00045         static vector<SequenceInfo*> fread_sequences(FILE* file);
00046 
00047         static void fwrite_alignment_params(AlignmentParams* params, FILE* file);
00048         static AlignmentParams* fread_alignment_params(vector<SequenceInfo*> sequences, FILE* file);
00049 
00050         static void fwrite_alignment_result(Alignment* alignment, FILE* file);
00051         static Alignment* fread_alignment_result(AlignmentParams* params, FILE* file);
00052 
00053         static void fwrite_flags(SequenceModifiers* modifiers, FILE* file);
00054         static SequenceModifiers* fread_flags(FILE* file);
00055 
00056         static void fwrite_array(const char* array, const int len, FILE* file);
00057         static void fread_array(char* array, const int len, FILE* file);
00058 
00059         static void fwrite_uint4_compressed(const unsigned int i, FILE* file);
00060         static unsigned int fread_uint4_compressed(FILE* file);
00061 
00062         static void fwrite_int4(const int i, FILE* file);
00063         static int fread_int4(FILE* file);
00064 
00065         static void fwrite_int2(const short i, FILE* file);
00066         static short fread_int2(FILE* file);
00067 
00068         static void fwrite_int1(const unsigned char i, FILE* file);
00069         static unsigned char fread_int1(FILE* file);
00070 
00071         static void fwrite_str(const char* str, FILE* file);
00072         static string fread_str(FILE* file);
00073 
00074         static void fwrite_gaps(vector<gap_t>* gaps, FILE* file);
00075         static void fread_gaps(vector<gap_t>* gaps, FILE* file);
00076 
00077         static void fread_dummy(const int len, FILE* file);
00078 
00079 };
00080 
00081 #endif /* ALIGNMENTBINARYFILE_HPP_ */