Debian Codegraph @

src/progs/mira.C

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 * Written by Bastien Chevreux (BaCh)
3 *
4 * Copyright (C) 1997-2000 by the German Cancer Research Center (Deutsches
5 * Krebsforschungszentrum, DKFZ Heidelberg) and Bastien Chevreux
6 * Copyright (C) 2000 and later by Bastien Chevreux
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the
22 * Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 *
25 */
26
27
28 #ifdef HAVE_OPENMP
29 #include <omp.h>
30 #endif
31
32 #include <sys/resource.h> // defines rlimit for getMoreStack()
33
34 #include <boost/algorithm/string.hpp>
35
36 #include "errorhandling/errorhandling.H"
37 #include "util/machineinfo.H"
38 #include "util/fileanddisk.H"
39 #include "progs/quirks.H"
40
41 #include "modules/mod_mira.H"
42 #include "modules/mod_bait.H"
43 #include "modules/mod_convert.H"
44 #include "modules/mod_diff.H"
45 #include "modules/mod_memestim.H"
46 #include "modules/mod_mer.H"
47 #include "modules/mod_scaffold.H"
48 #include "modules/mod_sigconex.H"
49 #include "modules/mod_tagsnp.H"
50
51 #include "version.H"
52
53 #ifdef MIRAMEMORC
54 #include "memorc/memorc.H"
55 #endif
56
57 using std::cout;
58 using std::cerr;
59 using std::endl;
60
61
62 extern const char * compileinfo;
63
64 void doAbort()
65 {
66 #ifndef PUBLICQUIET
67 Read::dumpStringContainerStats(cout);
68 #endif
69
70 cout << "\n\nVCODE: " << miraversion << endl;
71
72 cout << "\n\nFor general help, you will probably get a quicker response on the\n"
73 " MIRA talk mailing list\n"
74 "than if you mailed the author directly.\n"
75 "\nTo report bugs or ask for features, please use the SourceForge ticketing\nsystem at:\n"
76 "\thttp://sourceforge.net/p/mira-assembler/tickets/\n"
77 "This ensures that requests do not get lost.\n";
78 exit(100);
79 }
80
81
82
83 // usual linux stack size of 8Mb will lead to segfaults in very long
84 // alignments (>15-18k) in align.C
85 // therefore, get some more stack, atm 64 Mb
86
87 void getMoreStack()
88 {
89 struct rlimit rl;
90 const rlim_t wantstacksize=64L*1024L*1024L;
91
92 auto result = getrlimit(RLIMIT_STACK, &rl);
93 if (result == 0){
94 //cout << "Have cur " << rl.rlim_cur << endl;
95 //cout << "Have max " << rl.rlim_max << endl;
96 if(rl.rlim_cur<wantstacksize){
97 rl.rlim_cur=wantstacksize;
98 result = setrlimit(RLIMIT_STACK, &rl);
99 }
100 }else{
101 cout << "could not query stack size?\n";
102 }
103 }
104
105 int main(int argc, char ** argv)
106 {
107 #ifdef MIRAMEMORC
108 MemORC::setChecking(true);
109 #endif
110
111 fixQuirks();
112 getMoreStack();
113
114 #ifdef TIMERESTRICTED
115
116 cout << "Compiled on " << __DATE__ << ". Will run until "<< TR_OUT_MAXDAY << "." << TR_OUT_MAXMONTH << "." << TR_OUT_MAXYEAR << " (dd.mm.yyyy)\n";
117
118 {
119 struct stat st;
120 int rc=stat(dir_params.dir_log.c_str(),&st);
121 struct tm *mytm;
122 mytm=localtime(&st.st_mtime);
123
124 if(mytm->tm_year > TR_MAXYEAR
125 || (mytm->tm_year == TR_MAXYEAR
126 && mytm->tm_mon >= TR_OUT_MAXMONTH)){
127 cerr << "\n\nThis version of MIRA is definitively old, please get a newer version of the assembler.\n";
128 exit(0);
129 }
130 }
131 #endif
132
133 //cpu_set_t mask;
134 //cout << "####" << sizeof(cpu_set_t) << endl;
135 //sched_getaffinity(0,sizeof(cpu_set_t),&mask);
136 //
137 //cout << "Affinity: " << (uint8 *) &mask[0] << endl;
138
139 #ifdef HAVE_OPENMP
140 omp_set_num_threads(MachineInfo::getCoresTotal());
141 #endif
142
143
144 std::string path;
145 std::string miraprog;
146
147 splitFullPathAndFileName(argv[0],path,miraprog);
148 boost::to_lower(miraprog);
149
150 int retvalue=0;
151 try{
152 if(miraprog=="mira"
153 || miraprog=="mira4"
154 || miraprog=="mira5"){
155 miraMain(argc,argv);
156 // } else if(miraprog=="mirasearchestsnps"){
157 // //miraEST(argc,argv);
158 // } else if(miraprog=="miraclip"){
159 // //miraClip(argc,argv);
160 // } else if(miraprog=="mirapre"){
161 // //miraPre(argc,argv);
162 // } else if(miraprog=="tagsnp"){
163 // tagsnp t;
164 // t.mainTagSNP(argc, argv);
165 } else if(miraprog=="mirapbcorrect"){
166 mainPBCorrect(argc,argv);
167 } else if(miraprog=="miramem"
168 ||miraprog=="mira4mem"){
169 miraMemEstimate(argc, argv);
170 } else if(miraprog=="dbgreplay"){
171 dbgReplayMain(argc, argv);
172 }else if(miraprog=="mirascaff"
173 || miraprog=="mira4scaff"){
174 MiraScaffold m;
175 m.mainMiraScaffold(argc, argv);
176 }else if(miraprog=="mirabait"
177 || miraprog=="mira4bait"){
178 MiraBait m;
179 retvalue=m.mainMiraBait(argc, argv);
180 }else if(miraprog=="miradiff"
181 || miraprog=="mira4diff"){
182 MiraDiff m;
183 m.mainMiraDiff(argc, argv);
184 }else if(miraprog=="mirasce"
185 || miraprog=="mira4dsce"){
186 MiraSCE m;
187 m.mainSignificantContigExtraction(argc, argv);
188 }else if(miraprog=="miramer"
189 || miraprog=="mira4mer"){
190 MiraMer m;
191 m.mainMiraMer(argc, argv);
192 }else if(miraprog=="miraconvert"
193 || miraprog=="mira4convert"
194 || miraprog=="convert_project"
195 || miraprog=="convert_projectd"){
196 if(miraprog.front()=='c'){
197 cout << "convert_project is a deprecated name for miraconvert, please switch to new name.\n";
198 }
199 ConvPro cp;
200 cp.mainConvPro(argc, argv);
201 } else {
202 cout << miraprog << " is a non-recognised program name of MIRA.\n"
203 "The programs SHOULD be named either\n"
204 "\"mira\", \"miraconvert\", \"miramem\", \"mirabait\""
205 "\nAssuming 'mira'\n" << endl;
206
207 miraMain(argc,argv);
208 }
209 }
210 catch(Notify n){
211 cout.flush(); cerr.flush();
212 n.handleError("main");
213 }
214 catch(Flow f){
215 cout.flush(); cerr.flush();
216 cout << "INTERNAL ERROR: Unexpected exception: Flow()\n";
217 doAbort();
218 }
219 catch(const std::bad_alloc & e){
220 cout.flush(); cerr.flush();
221 cout << "Out of memory detected, exception message is: ";
222 cout << e.what() << endl;
223
224 if(sizeof(size_t) == sizeof(int32)){
225 cout << "\nYou are running a 32 bit executable. Please note that the maximum"
226 "\ntheoretical memory a 32 bit programm can use (be it in Linux, Windows or"
227 "\nother) is 4 GiB, in practice less: between 2.7 and 3.3 GiB. This is valid"
228 "\neven if your machine has hundreds of GiB."
229 "\nShould your machine have more that 4 GiB, use a 64 bit OS and a 64 bit"
230 "\nversion of MIRA.";
231 }
232
233 cout << "\n\nIf you have questions on why this happened, please send the last 1000"
234 "\nlines of the output log (or better: the complete file) to the author"
235 "\ntogether with a short summary of your assembly project.\n\n";
236
237 doAbort();
238 }
239 catch(const std::ios_base::failure & e){
240 cout.flush(); cerr.flush();
241 cout << "Failure in IO stream detected, exception message is: "
242 << e.what() << endl
243 << "\nWe perhaps ran out of disk space or hit a disk quota?\n";
244 doAbort();
245 }
246 catch (std::exception& e) {
247 cout.flush(); cerr.flush();
248 cout << "A 'standard' exception occurred (that's NOT normal):\n" << e.what() << "\n\nIf the cause is not immediatly obvious, please contact: [email protected]\n\n";
249 doAbort();
250 }
251 catch(...){
252 cout.flush(); cerr.flush();
253 cout << "Unknown exception caught, aborting the process.\n\nPlease contact: [email protected]\n\n";
254 doAbort();
255 }
256
257 #ifndef PUBLICQUIET
258 Read::dumpStringContainerStats(cout);
259 #endif
260
261 return retvalue;
262 }