MASA-Core
SpecialRowReader.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 _SPECIALLINE_HPP
00023 #define _SPECIALLINE_HPP
00024 
00025 #include <stdio.h>
00026 #include <string>
00027 #include <vector>
00028 using namespace std;
00029 
00030 #include "../libmasa/libmasa.hpp"
00031 
00032 struct coordinate_t {
00033         int col;
00034         int row;
00035 
00036         static int sortf(coordinate_t a, coordinate_t b);
00037 };
00038 
00039 class SpecialRowReader {
00040 public:
00041     SpecialRowReader(string directory, const score_params_t* score_params, bool firstRowGapped = false);
00042     virtual ~SpecialRowReader();
00043 
00044     int getCol() const;
00045     int getRow() const;
00046 
00047     void open(int start);
00048     void close();
00049     int read(cell_t* buf, int offset, int len); //TODO desvincular cell_t
00050     int getCurrentPosition();
00051     string getFilename(int row=-1, int col=-1);
00052 
00053     bool nextSpecialRow(int row, int col, int min_dist);
00054     int getLargestInterval(int* max_i, int* max_j);
00055 
00056 private:
00057     void loadSpecialRows();
00058     int j0;
00059     int j1;
00060     string directory;
00061     const score_params_t* score_params;
00062     FILE* file;
00063     vector<coordinate_t> specialRowCoordinates;
00064     int id;
00065 
00066     int start;
00067     int min_step;
00068     int current;
00069     int firstRowGapped;
00070 };
00071 
00072 #endif  /* _SPECIALLINE_HPP */
00073