MASA-Core
Job.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 class Job;
00023 
00024 #ifndef _JOB_HPP
00025 #define _JOB_HPP
00026 
00027 #include <string>
00028 #include <vector>
00029 using namespace std;
00030 
00031 #include "../libmasa/libmasa.hpp"
00032 #include "SpecialRowReader.hpp"
00033 #include "SpecialRowWriter.hpp"
00034 #include "CrosspointsFile.hpp"
00035 #include "biology/biology.hpp"
00036 #include "sra/SpecialRowsArea.hpp"
00037 #include "configs/Configs.hpp"
00038 #include "AlignerPool.hpp"
00039 
00040 #define STAGE_1   (1)
00041 #define STAGE_2   (2)
00042 #define STAGE_3   (3)
00043 #define STAGE_4   (4)
00044 #define STAGE_5   (5)
00045 #define STAGE_6   (6)
00046 #define STAGE_TOOL   (7)
00047 #define STAGE_GLOBAL (0)
00048 #define ALIGNER_STATISTICS (-1)
00049 
00050 #define AT_NOWHERE                      (-1)
00051 #define AT_ANYWHERE                     (0)
00052 #define AT_SEQUENCE_1           (1)
00053 #define AT_SEQUENCE_2           (2)
00054 #define AT_SEQUENCE_1_OR_2      (3)
00055 #define AT_SEQUENCE_1_AND_2     (4)
00056 
00057 
00058 class Job {
00059 public:
00060         /* Parameters */
00061 
00062         /*int blocks;
00063         int gpu;*/
00064         int alignment_start;
00065         int alignment_end;
00066         int max_alignments;
00067         long long ram_limit;
00068         long long disk_limit;
00069         bool block_pruning;
00070         bool dump_blocks;
00071         string flush_column_url;
00072         string load_column_url;
00073         int predicted_traceback;
00074         int stage4_maximum_partition_size;
00075         bool stage4_orthogonal_execution;
00076         string dump_pruning_text_filename;
00077         int stage6_output_format;
00078         string outputBufferLogFile;
00079         string inputBufferLogFile;
00080 
00081         IAligner* aligner;
00082         Configs* configs;
00083 
00084         int peer_listen_port;
00085         string peer_connect;
00086 
00087         /* Statistics */
00088 
00089         //long long cells_updates;
00090 
00091 
00092 
00093 
00094         Job(int sequencesCount);
00095         virtual ~Job();
00096 
00097         void setWorkPath(string workPath);
00098         void setSpecialRowsPath(string specialRowsPath);
00099         void setSharedPath(string sharedPath);
00100         string getWorkPath();
00101         int initialize();
00102 
00103         FILE* fopenStatistics(int stage, int id);
00104 
00105         int getSequenceCount() const;
00106         void addSequence(Sequence* sequence);
00107         Sequence* getSequence(int index);
00108         AlignmentParams* getAlignmentParams() const;
00109         Alignment* getAlignment() const;
00110         void setAlignment(Alignment* alignment);
00111 
00112         void loadSequenceData(Sequence* sequence);
00113         string getCrosspointFile(int stage, int id, int deep = -1);
00114         string getAlignmentBinaryFile(int id);
00115         string getAlignmentTextFile(int id);
00116 
00117         SpecialRowsArea* getSpecialRowsArea(int stage, int id, int deep = -1);
00118         void clearSpecialRowsArea(SpecialRowsArea** area);
00119 
00120         long long getSRALimit();
00121         long long getFlushInterval(int step);
00122         AlignerPool* getAlignerPool();
00123         int getPoolWaitId() const;
00124         void setPoolWaitId(int id);
00125         int getBufferLimit() const;
00126         void setBufferLimit(int bufferLimit);
00127 
00128 private:
00129         vector<Sequence*> sequences;
00130         AlignmentParams* alignment_params;
00131         Alignment* alignment;
00132         string statistics_filename;
00133         string status_filename;
00134         string info_filename;
00135         int last_crosspoint_id;
00136         string work_path;
00137         string crosspoints_path;
00138         string special_rows_path;
00139         int* flushIntervals;
00140         int maxFlushDeep;
00141         AlignerPool* alignerPool;
00142         string pool_shared_path;
00143         int pool_wait_id;
00144         int bufferLimit;
00145 
00146         map<string, SpecialRowsArea*> specialRowsAreas;
00147 
00148         string getSpecialRowsPath(int stage, int id, int deep = -1);
00149         void createPath(string path);
00150         void initializeWorkPath();
00151         string resolve_env(string in);
00152         void clearSpecialRowsAreas();
00153         void calculateFlushIntervals(int max_deep, long long limit, int seq0_len, int seq1_len);
00154 };
00155 
00156 #endif  /* _JOB_HPP */
00157