main.cpp
Go to the documentation of this file.
1 /* ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
2  ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
3 
4  trimAl v1.4: a tool for automated alignment trimming in large-scale
5  phylogenetics analyses.
6 
7  2009-2015 Capella-Gutierrez S. and Gabaldon, T.
8  [scapella, tgabaldon]@crg.es
9 
10  This file is part of trimAl.
11 
12  trimAl is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, the last available version.
15 
16  trimAl is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with trimAl. If not, see <http://www.gnu.org/licenses/>.
23 
24 ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
25 ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** */
26 
27 #include <fstream>
28 #include <iostream>
29 #include <iomanip>
30 
31 #include <stdlib.h>
32 #include <string.h>
33 
34 #include "compareFiles.h"
35 #include "compareFiles.h"
36 #include "alignment.h"
37 #include "defines.h"
38 #include "utils.h"
39 
40 void menu(void);
41 void examples(void);
42 
43 int main(int argc, char *argv[]){
44 
45  /* Parameters Control */
46  bool appearErrors = false, complementary = false, colnumbering = false, nogaps = false, noallgaps = false, gappyout = false,
47  strict = false, strictplus = false, automated1 = false, sgc = false, sgt = false, scc = false, sct = false, sfc = false,
48  sft = false, sident = false, soverlap = false, selectSeqs = false, selectCols = false, shortNames = false, splitbystop = false,
49  terminal = false, keepSeqs = false, keepHeader = false, ignorestop = false;
50 
51  float conserve = -1, gapThreshold = -1, simThreshold = -1, comThreshold = -1, resOverlap = -1, seqOverlap = -1, maxIdentity = -1;
52 
53  int outformat = -1, compareset = -1, stats = 0, windowSize = -1, gapWindow = -1, simWindow = -1, conWindow = -1,
54  blockSize = -1, clusters = -1, alternative_matrix = -1, alignDataType = -1;
55 
56  /* Others varibles */
57  ifstream compare;
58  float *compareVect = NULL;
59  alignment **compAlig = NULL;
60  string nline, *seqNames = NULL;
61  sequencesMatrix *seqMatrix = NULL;
62  similarityMatrix *similMatrix = NULL;
63  alignment *origAlig = NULL, *intermediateAlig = NULL, *singleAlig = NULL, *backtranslation = NULL;
64 
65  int i = 1, lng, num = 0, maxAminos = 0, numfiles = 0, referFile = 0, *delColumns = NULL, *delSequences = NULL, *seqLengths = NULL, *boundaries = NULL;
66  char c, *forceFile = NULL, *infile = NULL, *backtransFile = NULL, *outfile = NULL, *outhtml = NULL, *matrix = NULL,
67  **filesToCompare = NULL, line[256];
68 
69  /* ------------------------------------------------------------------------------------------------------ */
70 
71  /* Exec: TrimAl - Shows the menu. */
72 
73  /* ------------------------------------------------------------------------------------------------------ */
74  if(argc == 1) {
75  menu();
76  return 0;
77  }
78 
79  /* ------------------------------------------------------------------------------------------------------ */
80 
81  /* Help and Version Menu */
82 
83  /* ------------------------------------------------------------------------------------------------------ */
84  if(!strcmp(argv[i], "-h") && (i+1 == argc)) {
86  return 0;
87  }
88 
89  if(!strcmp(argv[i], "--version") && (i+1 == argc)) {
90  cout << endl << "trimAl v" << VERSION << ".rev" << REVISION
91  << " build[" << BUILD << "]" << endl << endl;
92  return 0;
93  }
94 
95  /***** ***** ***** ***** ***** ***** ***** Parameters Processing ***** ***** ***** ***** ***** ***** *****/
96  origAlig = new alignment;
97 
98  while(i < argc) {
99 
100  /* ------------------------------------------------------------------------------------------------------ */
101 
102  /* Input and Output files and format output */
103 
104  /* Option -in ------------------------------------------------------------------------------------------- */
105  if(!strcmp(argv[i], "-in") && (i+1 != argc) && (infile == NULL)) {
106 
107  if((sfc) || (sft) || (comThreshold != -1)) {
108  cerr << endl << "ERROR: Not allowed in combination of file comparision." << endl << endl;
109  appearErrors = true;
110  i++;
111  }
112 
113  else if((compareset == -1) || (forceFile != NULL)) {
114  lng = strlen(argv[++i]);
115  infile = new char[lng + 1];
116  strcpy(infile, argv[i]);
117 
118  if(!origAlig -> loadAlignment(infile)) {
119  cerr << endl << "ERROR: Alignment not loaded: \"" << infile << "\" Check the file's content." << endl << endl;
120  appearErrors = true;
121  }
122  }
123 
124  else {
125  if(compareset != -1)
126  cerr << endl << "ERROR: Option \"" << argv[i] << "\" not valid. A reference file exists with alignments to compare." << endl << endl;
127  if(forceFile != NULL)
128  cerr << endl << "ERROR: Option \"" << argv[i] << "\" not valid. A alignment file has been setting up to be compare with a set of alignmets." << endl << endl;
129  appearErrors = true;
130  i++;
131  }
132  }
133  /* ------------------------------------------------------------------------------------------------------ */
134 
135  /* Option -out ------------------------------------------------------------------------------------------ */
136  else if((!strcmp(argv[i], "-out")) && (i+1 != argc) && (outfile == NULL)) {
137  lng = strlen(argv[++i]);
138  outfile = new char[lng + 1];
139  strcpy(outfile, argv[i]);
140  }
141 
142  /* Option -htmlout -------------------------------------------------------------------------------- */
143  else if((!strcmp(argv[i], "-htmlout")) && (i+1 != argc) && (outhtml == NULL)) {
144  lng = strlen(argv[++i]);
145  outhtml = new char[lng + 1];
146  strcpy(outhtml, argv[i]);
147  }
148 
149  /* ------------------------------------------------------------------------------------------------------ */
150 
151  /* Output File format */
152 
153  /* Option -clustal -------------------------------------------------------------------------------------- */
154  else if(!strcmp(argv[i], "-clustal") && (outformat == -1))
155  outformat = 1;
156 
157  /* Option -fasta -------------------------------------------------------------------------------------- */
158  else if(!strcmp(argv[i], "-fasta") && (outformat == -1))
159  outformat = 8;
160 
161  /* Option -fasta-m10 -------------------------------------------------------------------------------------- */
162  else if(!strcmp(argv[i], "-fasta_m10") && (outformat == -1)) {
163  outformat = 8; shortNames = true;
164  }
165 
166  /* Option -nbrf ------------------------------------------------------------------------------------ */
167  else if(!strcmp(argv[i], "-nbrf") && (outformat == -1))
168  outformat = 3;
169 
170  /* Option -nexus ------------------------------------------------------------------------------------ */
171  else if(!strcmp(argv[i], "-nexus") && (outformat == -1))
172  outformat = 17;
173 
174  /* Option -mega ------------------------------------------------------------------------------------ */
175  else if(!strcmp(argv[i], "-mega") && (outformat == -1))
176  outformat = 21;
177 
178  /* Option -phylip3.2 --------------------------------------------------------------------------------- */
179  else if(!strcmp(argv[i], "-phylip3.2") && (outformat == -1))
180  outformat = 11;
181 
182  /* Option -phylip3.2-m10 ----------------------------------------------------------------------------- */
183  else if(!strcmp(argv[i], "-phylip3.2_m10") && (outformat == -1)) {
184  outformat = 11; shortNames = true;
185  }
186 
187  /* Option -phylip --------------------------------------------------------------------------- */
188  else if(!strcmp(argv[i], "-phylip") && (outformat == -1))
189  outformat = 12;
190 
191  /* Option -phylip-m10 ----------------------------------------------------------------------- */
192  else if(!strcmp(argv[i], "-phylip_m10") && (outformat == -1)) {
193  outformat = 12; shortNames = true;
194  }
195 
196  /* Option -phylip_paml ---------------------------------------------------------------------- */
197  else if(!strcmp(argv[i], "-phylip_paml") && (outformat == -1))
198  outformat = 13;
199 
200  /* Option -phylip_paml-m10 ------------------------------------------------------------------ */
201  else if(!strcmp(argv[i], "-phylip_paml_m10") && (outformat == -1)) {
202  outformat = 13; shortNames = true;
203  }
204 
205  /* ------------------------------------------------------------------------------------------------------ */
206 
207  /* Similarity Matrix File */
208 
209  /* Option -matrix --------------------------------------------------------------------------------------- */
210  else if(!strcmp(argv[i], "-matrix") && (i+1 != argc) && (matrix == NULL)) {
211  lng = strlen(argv[++i]);
212  matrix = new char[lng + 1];
213  strcpy(matrix, argv[i]);
214  }
215 
216  else if(!strcmp(argv[i], "--alternative_matrix") && (i+1 != argc) && (alternative_matrix == -1)) {
217  i++;
218  if (!strcmp(argv[i], "degenerated_nt_identity"))
219  alternative_matrix = 1;
220  else {
221  cerr << endl << "ERROR: Alternative not recognized \"" << argv[i] << "\"" << endl << endl;
222  appearErrors = true;
223  }
224  }
225  /* ------------------------------------------------------------------------------------------------------ */
226 
227  /* File with a alignments' set to compare */
228 
229  /* Option -compareset ----------------------------------------------------------------------------------- */
230  else if(!strcmp(argv[i], "-compareset") && (i+1 != argc) && (compareset == -1)) {
231 
232  if(infile == NULL) {
233  compare.open(argv[++i], ifstream::in);
234  if(!compare) {
235  cerr << endl << "ERROR: Check the reference file with the alignments to compare." << endl << endl;
236  appearErrors = true;
237  }
238 
239  while(compare.getline(line, 256)) numfiles++;
240  compare.close();
241 
242  compareset = i;
243  }
244 
245  else {
246  cerr << endl << "ERROR: Option \"" << argv[i] << "\" not valid. A single alignment file has been set by the user." << endl << endl;
247  appearErrors = true;
248  i++;
249  }
250  }
251 
252  /* Option -forceselect ----------------------------------------------------------------------------------- */
253  else if(!strcmp(argv[i], "-forceselect") && (i+1 != argc) && (forceFile == NULL)) {
254 
255  if(infile == NULL) {
256  lng = strlen(argv[++i]);
257  forceFile = new char[lng + 1];
258  strcpy(forceFile, argv[i]);
259  if(!origAlig -> loadAlignment(forceFile)) {
260  cerr << endl << "ERROR: Alignment not loaded: \"" << forceFile << "\" Check the file's content." << endl << endl;
261  appearErrors = true;
262  }
263  }
264 
265  else {
266  cerr << endl << "ERROR: Option \"" << argv[i] << "\" not valid. A single alignment file has been setting it up" << endl << endl;
267  appearErrors = true;
268  i++;
269  }
270  }
271 
272  /* Option -backtrans -------------------------------------------------------------------------------------- */
273  else if(!strcmp(argv[i], "-backtrans") && (i+1 != argc) && (backtransFile == NULL)) {
274 
275  lng = strlen(argv[++i]);
276  backtransFile = new char[lng + 1];
277  strcpy(backtransFile, argv[i]);
278 
279  backtranslation = new alignment;
280  if(!backtranslation -> loadAlignment(backtransFile)) {
281  cerr << endl << "ERROR: Alignment not loaded: \"" << backtransFile << "\" Check the file's content." << endl << endl;
282  appearErrors = true;
283  }
284  }
285 
286  /* ------------------------------------------------------------------------------------------------------ */
287 
288  /* Manual Method Values. Deleting columns */
289 
290  /* Option -gt, gapthreshold ----------------------------------------------------------------------------- */
291  else if((!strcmp(argv[i], "-gapthreshold") || !strcmp(argv[i], "-gt")) && (i+1 != argc) && (gapThreshold == -1)) {
292 
293  if((selectCols) || (selectSeqs)) {
294  cerr << endl << "ERROR: Not allowed in combination of other manual methods such as manual selection of sequences/columns." << endl << endl;
295  appearErrors = true;
296  }
297 
298  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
299  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
300  appearErrors = true;
301  }
302 
303  else {
304  if(utils::isNumber(argv[++i])) {
305  gapThreshold = 1 - atof(argv[i]);
306  if((gapThreshold < 0) || (gapThreshold > 1)) {
307  cerr << endl << "ERROR: The gap threshold value should be between 0 and 1." << endl << endl;
308  appearErrors = true;
309  }
310  }
311  else {
312  cerr << endl << "ERROR: The gap threshold value should be a positive real number." << endl << endl;
313  appearErrors = true;
314  }
315  }
316  }
317  /* ------------------------------------------------------------------------------------------------------ */
318 
319  /* Option -st -simthreshold ----------------------------------------------------------------------------- */
320  else if((!strcmp(argv[i], "-simthreshold") || !strcmp(argv[i], "-st")) && (i+1 != argc) && (simThreshold == -1)) {
321 
322  if((selectCols) || (selectSeqs)) {
323  cerr << endl << "ERROR: Not allowed in combination of other manual methods such as manual selection of sequences/columns." << endl << endl;
324  appearErrors = true;
325  }
326 
327  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
328  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
329  appearErrors = true;
330  }
331 
332  else {
333  if(utils::isNumber(argv[++i])) {
334  simThreshold = atof(argv[i]);
335  if((simThreshold < 0) || (simThreshold > 1)) {
336  cerr << endl << "ERROR: The similarity threshold value should be between 0 and 1." << endl << endl;
337  appearErrors = true;
338  }
339  }
340  else {
341  cerr << endl << "ERROR: The similarity threshold value should be a positive real number." << endl << endl;
342  appearErrors = true;
343  }
344  }
345  }
346  /* ------------------------------------------------------------------------------------------------------ */
347 
348 
349  /* Option -ct -conthreshold ----------------------------------------------------------------------------- */
350  else if((!strcmp(argv[i], "-conthreshold") || !strcmp(argv[i], "-ct")) && (i+1 != argc) && (comThreshold == -1)) {
351 
352  if((selectCols) || (selectSeqs)) {
353  cerr << endl << "ERROR: Not allowed in combination of other manual methods such as manual selection of sequences/columns." << endl << endl;
354  appearErrors = true;
355  }
356 
357  //~ else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
358  //~ cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
359  //~ appearErrors = true;
360  //~ }
361 
362  else if(infile != NULL) {
363  cerr << endl << "ERROR: Not allowed in combination with -in option." << endl << endl;
364  appearErrors = true;
365 
366  }
367 
368  else {
369  if(utils::isNumber(argv[++i])) {
370  comThreshold = atof(argv[i]);
371  if((comThreshold < 0) || (comThreshold > 1)) {
372  cerr << endl << "ERROR: The consistency threshold value should be between 0 and 1." << endl << endl;
373  appearErrors = true;
374  }
375  }
376  else {
377  cerr << endl << "ERROR: The consistency threshold value should be a positive real number." << endl << endl;
378  appearErrors = true;
379  }
380  }
381  }
382 
383  /* ------------------------------------------------------------------------------------------------------ */
384 
385  /* Option -cons ----------------------------------------------------------------------------------------- */
386  else if((!strcmp(argv[i], "-cons")) && (i+1 != argc) && (conserve == -1)) {
387 
388  if((selectCols) || (selectSeqs)) {
389  cerr << endl << "ERROR: Not allowed in combination of other manual methods such as manual selection of sequences/columns." << endl << endl;
390  appearErrors = true;
391  }
392 
393  else if(blockSize != -1) {
394  cerr << endl << "ERROR: Not allowed in combination of column block size value." << endl << endl;
395  appearErrors = true;
396  }
397 
398  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
399  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
400  appearErrors = true;
401  }
402 
403  else {
404  if(utils::isNumber(argv[++i])) {
405  conserve = atof(argv[i]);
406  if((conserve < 0) || (conserve > 100)) {
407  cerr << endl << "ERROR: The minimal positions value should be between 0 and 100." << endl << endl;
408  appearErrors = true;
409  }
410  }
411  else {
412  cerr << endl << "ERROR: The minimal positions value should be a positive real number." << endl << endl;
413  appearErrors = true;
414  }
415  }
416  }
417  /* ------------------------------------------------------------------------------------------------------ */
418 
419  /* Option -selectcols -------------------------------------------------------------------------------- */
420  else if((!strcmp(argv[i], "-selectcols")) && (selectCols == false) && ((i+3) < argc) && (!strcmp(argv[++i], "{")) && (!strcmp(argv[i+2], "}"))) {
421 
422  if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
423  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed." << endl << endl;
424  appearErrors = true;
425  }
426 
427  else if(blockSize != -1) {
428  cerr << endl << "ERROR: Not allowed in combination of column block size value." << endl << endl;
429  appearErrors = true;
430  }
431 
432  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) || (comThreshold != -1)) {
433  cerr << endl << "ERROR: Not allowed in combination of other manual methods." << endl << endl;
434  appearErrors = true;
435  }
436 
437  else if((windowSize != -1) || (gapWindow != -1)|| (simWindow != -1)) {
438  cerr << endl << "ERROR: It's imposible to use this windows size in combination of selection method." << endl << endl;
439  appearErrors = true;
440  }
441 
442  else if((delColumns = utils::readNumbers(argv[++i])) == NULL) {
443  cerr << endl << "ERROR: Impossible to parser the sequences number" << endl << endl;
444  appearErrors = true;
445  }
446 
447  else selectCols = true;
448  i++;
449  }
450 
451  /* ------------------------------------------------------------------------------------------------------ */
452 
453  /* Automated Methods. Deleting Columns */
454 
455  /* Option -nogaps --------------------------------------------------------------------------------------- */
456  else if(!strcmp(argv[i], "-nogaps") && (!nogaps)) {
457 
458  if((windowSize != -1) || (gapWindow != -1) || (simWindow != -1)) {
459  cerr << endl << "ERROR: Not allowed in combination of window values." << endl << endl;
460  appearErrors = true;
461  }
462 
463  else if(blockSize != -1) {
464  cerr << endl << "ERROR: Not allowed in combination of column block size value." << endl << endl;
465  appearErrors = true;
466  }
467 
468  else if((noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
469  cerr << endl << "ERROR: Combinations between automatic methods are not allowed." << endl << endl;
470  appearErrors = true;
471  }
472 
473  //~ else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
474  //~ (comThreshold != -1) || (selectCols) || (selectSeqs)) {
475  //~ cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
476  //~ appearErrors = true;
477  //~ }
478  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
479  (selectCols) || (selectSeqs)) {
480  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
481  appearErrors = true;
482  }
483 
484  else
485  nogaps = true;
486  }
487  /* ------------------------------------------------------------------------------------------------------ */
488 
489  /* Option -noallgaps --------------------------------------------------------------------------------------- */
490  else if(!strcmp(argv[i], "-noallgaps") && (!noallgaps)) {
491 
492  if((windowSize != -1) || (gapWindow != -1) || (simWindow != -1)) {
493  cerr << endl << "ERROR: Not allowed in combination of window values." << endl << endl;
494  appearErrors = true;
495  }
496 
497  else if(blockSize != -1) {
498  cerr << endl << "ERROR: Not allowed in combination of column block size value." << endl << endl;
499  appearErrors = true;
500  }
501 
502  else if((nogaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
503  cerr << endl << "ERROR: Combinations between automatic methods are not allowed." << endl << endl;
504  appearErrors = true;
505  }
506 
507  //~ else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
508  //~ (comThreshold != -1) || (selectCols) || (selectSeqs)) {
509  //~ cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
510  //~ appearErrors = true;
511  //~ }
512  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
513  (selectCols) || (selectSeqs)) {
514  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
515  appearErrors = true;
516  }
517 
518  else
519  noallgaps = true;
520  }
521 
522  /* Option -keepseqs --------------------------------------------------------------------------------------- */
523  else if(!strcmp(argv[i], "-keepseqs") && (!keepSeqs)) {
524  keepSeqs = true;
525  }
526 
527  /* Option -keepseqs --------------------------------------------------------------------------------------- */
528  else if(!strcmp(argv[i], "-keepheader") && (!keepHeader)) {
529  keepHeader = true;
530  }
531 
532  /* ------------------------------------------------------------------------------------------------------ */
533 
534  /* Option -gappyout ------------------------------------------------------------------------------------- */
535  else if(!strcmp(argv[i], "-gappyout") && (!strict)) {
536 
537  if((windowSize != -1) || (gapWindow != -1) || (simWindow != -1)) {
538  cerr << endl << "ERROR: Not allowed in combination of window values." << endl << endl;
539  appearErrors = true;
540  }
541 
542  else if((nogaps) || (noallgaps) || (strict) || (strictplus) || (automated1)) {
543  cerr << endl << "ERROR: Combinations between automatic methods are not allowed." << endl << endl;
544  appearErrors = true;
545  }
546 
547  //~ else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
548  //~ (comThreshold != -1) || (selectCols) || (selectSeqs)) {
549  //~ cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
550  //~ appearErrors = true;
551  //~ }
552  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
553  (selectCols) || (selectSeqs)) {
554  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
555  appearErrors = true;
556  }
557 
558  else
559  gappyout = true;
560  }
561  /* ------------------------------------------------------------------------------------------------------ */
562 
563  /* Option -strict --------------------------------------------------------------------------------------- */
564  else if(!strcmp(argv[i], "-strict") && (!strict)) {
565 
566  if((windowSize != -1) || (gapWindow != -1) || (simWindow != -1)) {
567  cerr << endl << "ERROR: Not allowed in combination of window values." << endl << endl;
568  appearErrors = true;
569  }
570 
571  //~ else if(blockSize != -1) {
572  //~ cerr << endl << "ERROR: Not allowed in combination of column block size value." << endl << endl;
573  //~ appearErrors = true;
574  //~ }
575 
576  else if((nogaps) || (noallgaps) || (gappyout) || (strictplus) || (automated1)) {
577  cerr << endl << "ERROR: Combinations between automatic methods are not allowed." << endl << endl;
578  appearErrors = true;
579  }
580 
581  //~ else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
582  //~ (comThreshold != -1) || (selectCols) || (selectSeqs)) {
583  //~ cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
584  //~ appearErrors = true;
585  //~ }
586  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
587  (selectCols) || (selectSeqs)) {
588  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
589  appearErrors = true;
590  }
591 
592  else
593  strict = true;
594  }
595  /* ------------------------------------------------------------------------------------------------------ */
596 
597  /* Option -strictplus ----------------------------------------------------------------------------------- */
598  else if((!strcmp(argv[i], "-strictplus")) && (!strictplus)) {
599 
600  if((windowSize != -1) || (gapWindow != -1) || (simWindow != -1)) {
601  cerr << endl << "ERROR: Not allowed in combination with this window value." << endl << endl;
602  appearErrors = true;
603  }
604 
605  //~ else if(blockSize != -1) {
606  //~ cerr << endl << "ERROR: Not allowed in combination of column block size value." << endl << endl;
607  //~ appearErrors = true;
608  //~ }
609 
610  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (automated1)) {
611  cerr << endl << "ERROR: Combinations between automatic methods are not allowed." << endl << endl;
612  appearErrors = true;
613  }
614 
615  //~ else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
616  //~ (comThreshold != -1) || (selectCols) || (selectSeqs)) {
617  //~ cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
618  //~ appearErrors = true;
619  //~ }
620  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
621  (selectCols) || (selectSeqs)) {
622  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
623  appearErrors = true;
624  }
625 
626  else
627  strictplus = true;
628  }
629  /* ------------------------------------------------------------------------------------------------------ */
630 
631  /* Option -automated1 ----------------------------------------------------------------------------------- */
632  else if((!strcmp(argv[i], "-automated1")) && (!automated1)) {
633 
634  if((windowSize != -1) || (gapWindow != -1) || (simWindow != -1)) {
635  cerr << endl << "ERROR: Not allowed in combination with this window value." << endl << endl;
636  appearErrors = true;
637  }
638 
639  else if(blockSize != -1) {
640  cerr << endl << "ERROR: Not allowed in combination of column block size value." << endl << endl;
641  appearErrors = true;
642  }
643 
644  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
645  (comThreshold != -1) || (selectCols) || (selectSeqs)) {
646  cerr << endl << "ERROR: Combinations between automatic methods are not allowed." << endl << endl;
647  appearErrors = true;
648  }
649 
650  //~ else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
651  //~ (comThreshold != -1) || (selectCols) || (selectSeqs)) {
652  //~ cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
653  //~ appearErrors = true;
654  //~ }
655  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
656  (selectCols) || (selectSeqs)) {
657  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
658  appearErrors = true;
659  }
660 //~
661  //~ else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) || (comThreshold != -1) || (delColumns != NULL)) {
662  //~ cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
663  //~ appearErrors = true;
664  //~ }
665 
666  else
667  automated1 = true;
668  }
669  /* ------------------------------------------------------------------------------------------------------ */
670 
671  /* ------------------------------------------------------------------------------------------------------ */
672 
673  /* Manual Method Values. Deleting sequences */
674 
675  /* Option -coloverlap ------------------------------------------------------------------------------------ */
676  else if((!strcmp(argv[i], "-resoverlap")) && (i+1 != argc) && (resOverlap == -1)) {
677 
678  if((selectCols) || (selectSeqs)) {
679  cerr << endl << "ERROR: Not allowed in combination of methods such as manual selection of sequences/columns." << endl << endl;
680  appearErrors = true;
681  }
682 
683  else {
684  if(utils::isNumber(argv[++i])) {
685  resOverlap = atof(argv[i]);
686  if((resOverlap < 0) || (resOverlap > 1)) {
687  cerr << endl << "ERROR: The residue overlap value should be between 0 and 1." << endl << endl;
688  appearErrors = true;
689  }
690  }
691  else {
692  cerr << endl << "ERROR: The residue overlap value should be a positive real number." << endl << endl;
693  appearErrors = true;
694  }
695  }
696  }
697  /* ------------------------------------------------------------------------------------------------------ */
698 
699  /* Option -seqoverlap ----------------------------------------------------------------------------------------------------- */
700  else if((!strcmp(argv[i], "-seqoverlap")) && (i+1 != argc) && (seqOverlap == -1)) {
701 
702  if((selectCols) || (selectSeqs)) {
703  cerr << endl << "ERROR: Not allowed in combination of methods such as manual selection of sequences/columns." << endl << endl;
704  appearErrors = true;
705  }
706 
707  else {
708  if(utils::isNumber(argv[++i])) {
709  seqOverlap = atof(argv[i]);
710  if((seqOverlap < 0) || (seqOverlap > 100)) {
711  cerr << endl << "ERROR: The sequences overlap value should be between 0 and 100." << endl << endl;
712  appearErrors = true;
713  }
714  }
715  else {
716  cerr << endl << "ERROR: The minimal positions value should be a positive real number." << endl << endl;
717  appearErrors = true;
718  }
719  }
720  }
721 
722  /* Option -selectseqs -------------------------------------------------------------------------------- */
723  else if((!strcmp(argv[i], "-selectseqs")) && (selectSeqs == false) && ((i+3) < argc) && (!strcmp(argv[++i], "{")) && (!strcmp(argv[i+2], "}"))) {
724 
725  if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
726  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed." << endl << endl;
727  appearErrors = true;
728  }
729 
730  else if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) || (comThreshold != -1)) {
731  cerr << endl << "ERROR: Not allowed in combination of other manual methods." << endl << endl;
732  appearErrors = true;
733  }
734 
735  else if((windowSize != -1) || (gapWindow != -1)|| (simWindow != -1)) {
736  cerr << endl << "ERROR: It's imposible to use this windows size in combination of selection method." << endl << endl;
737  appearErrors = true;
738  }
739 
740  else if((clusters != -1) || (maxIdentity != -1)) {
741  cerr << endl << "ERROR: Only one method to chose sequences can be applied." << endl << endl;
742  appearErrors = true;
743  }
744 
745  else if((delSequences = utils::readNumbers(argv[++i])) == NULL) {
746  cerr << endl << "ERROR: Impossible to parser the sequences number" << endl << endl;
747  appearErrors = true;
748  }
749 
750  else selectSeqs = true;
751  i++;
752  }
753 
754  /* Option -maxidentity ----------------------------------------------------------------------------------- */
755  else if((!strcmp(argv[i], "-maxidentity")) && (i+1 != argc) && (maxIdentity == -1)) {
756 
757  if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
758  (comThreshold != -1) || (selectCols) || (selectSeqs)) {
759  cerr << endl << "ERROR: Not allowed in combination of other manual methods such as manual "
760  << "selection of sequences/columns." << endl << endl;
761  appearErrors = true;
762  }
763 
764  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
765  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
766  appearErrors = true;
767  }
768 
769  else if((windowSize != -1) || (gapWindow != -1) || (simWindow != -1)) {
770  cerr << endl << "ERROR: Not allowed in combination with window values." << endl << endl;
771  appearErrors = true;
772  }
773 
774  else if(clusters != -1) {
775  cerr << endl << "ERROR: Only one method to chose representative sequences can be applied." << endl << endl;
776  appearErrors = true;
777  }
778 
779  else {
780  if(utils::isNumber(argv[++i])) {
781  maxIdentity = atof(argv[i]);
782  if((maxIdentity < 0) || (maxIdentity > 1)) {
783  cerr << endl << "ERROR: The maximum identity threshold should be between 0 and 1." << endl << endl;
784  appearErrors = true;
785  }
786  }
787  else {
788  cerr << endl << "ERROR: The minimal positions value should be a positive real number." << endl << endl;
789  appearErrors = true;
790  }
791  }
792  }
793  /* ------------------------------------------------------------------------------------------------------ */
794 
795  /* Option -clusters ----------------------------------------------------------------------------------- */
796  else if((!strcmp(argv[i], "-clusters")) && (i+1 != argc) && (clusters == -1)) {
797 
798  if((gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) ||
799  (comThreshold != -1) || (selectCols) || (selectSeqs)) {
800  cerr << endl << "ERROR: Not allowed in combination of other manual methods such as manual "
801  << "selection of sequences/columns." << endl << endl;
802  appearErrors = true;
803  }
804 
805  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
806  cerr << endl << "ERROR: Combinations between automatic and manual methods are not allowed" << endl << endl;
807  appearErrors = true;
808  }
809 
810  else if((windowSize != -1) || (gapWindow != -1) || (simWindow != -1)) {
811  cerr << endl << "ERROR: Not allowed in combination with window values." << endl << endl;
812  appearErrors = true;
813  }
814 
815  else if(maxIdentity != -1) {
816  cerr << endl << "ERROR: Only one method to chose representative sequences can be applied." << endl << endl;
817  appearErrors = true;
818  }
819 
820  else {
821  if(utils::isNumber(argv[++i])) {
822  clusters = atoi(argv[i]);
823  if(clusters < 1) {
824  cerr << endl << "ERROR: There is a problem with the given clusters number." << endl << endl;
825  appearErrors = true;
826  }
827  }
828  else {
829  cerr << endl << "ERROR: The clusters number should be a positive integer number." << endl << endl;
830  appearErrors = true;
831  }
832  }
833  }
834  /* ------------------------------------------------------------------------------------------------------ */
835 
836  /* ------------------------------------------------------------------------------------------------------ */
837 
838  /* Other methods: Just remove the terminal gaps from an alignment keeping the columns that are in the middle
839  * of the sequences independently of the trimming method used */
840 
841  /* ------------------------------------------------------------------------------------------------------ */
842  /* Option -terminalonly --------------------------------------------------------------------------------- */
843  else if((!strcmp(argv[i], "-terminalonly")) && (!terminal)) {
844  terminal = true;
845  }
846 
847  /* Option --set_boundaries -------------------------------------------------------------------------------- */
848  else if((!strcmp(argv[i], "--set_boundaries")) && (!terminal) && ((i+3) < argc) && (!strcmp(argv[++i], "{")) && (!strcmp(argv[i+2], "}"))) {
849 
850  if((boundaries = utils::readNumbers_StartEnd(argv[++i])) == NULL) {
851 
852  cerr << endl << "ERROR: Impossible to parser the sequences number" << endl << endl;
853  appearErrors = true;
854  }
855 
856  terminal = true;
857  i++;
858  }
859  /* ------------------------------------------------------------------------------------------------------ */
860 
861  /* ------------------------------------------------------------------------------------------------------ */
862 
863  /* Windows Size Values */
864 
865  /* Option -w -------------------------------------------------------------------------------------------- */
866  else if(!strcmp(argv[i], "-w") && (i+1 != argc) && (windowSize == -1)){
867 
868  if((gapWindow != -1) || (simWindow != -1) || (conWindow != -1)) {
869  cerr << endl << "ERROR: Not allowed in combination with this specific window value." << endl << endl;
870  appearErrors = true;
871  }
872 
873  if((selectCols) || (selectSeqs)) {
874  cerr << endl << "ERROR: It's imposible to use this windows size in combination of manual selection method." << endl << endl;
875  appearErrors = true;
876  }
877 
878  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
879  cerr << endl << "ERROR: Not allowed in combination of automatic methods." << endl << endl;
880  appearErrors = true;
881  }
882 
883  else {
884  if(utils::isNumber(argv[i+1])) {
885  windowSize = atoi(argv[++i]);
886  if(windowSize <= 0){
887  cerr << endl << "ERROR: The window value should be a positive integer number." << endl << endl;
888  appearErrors = true;
889  }
890  }
891  else {
892  cerr << endl << "ERROR: The window value should be a number." << endl << endl;
893  appearErrors = true;
894  }
895  }
896  //~ i++;
897  }
898  /* ------------------------------------------------------------------------------------------------------ */
899 
900  /* Option -gw -------------------------------------------------------------------------------------------- */
901  else if(!strcmp(argv[i], "-gw") && (i+1 != argc) && (gapWindow == -1)){
902 
903  if(windowSize != -1) {
904  cerr << endl << "ERROR: Not allowed in combination of general window value." << endl << endl;
905  appearErrors = true;
906  }
907 
908  if((selectCols) || (selectSeqs)) {
909  cerr << endl << "ERROR: It's imposible to use this windows size in combination of manual selection method." << endl << endl;
910  appearErrors = true;
911  }
912 
913  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
914  cerr << endl << "ERROR: Not allowed in combination of automatic methods." << endl << endl;
915  appearErrors = true;
916  }
917 
918  else {
919  if(utils::isNumber(argv[i+1])) {
920  gapWindow = atoi(argv[++i]);
921  if(gapWindow <= 0){
922  cerr << endl << "ERROR: The window value should be a positive integer number." << endl << endl;
923  appearErrors = true;
924  }
925  }
926  else {
927  cerr << endl << "ERROR: The window value should be a number." << endl << endl;
928  appearErrors = true;
929  }
930  }
931  //~ i++;
932  }
933  /* ------------------------------------------------------------------------------------------------------ */
934 
935  /* Option -sw -------------------------------------------------------------------------------------------- */
936  else if(!strcmp(argv[i], "-sw") && (i+1 != argc) && (simWindow == -1)){
937 
938  if(windowSize != -1) {
939  cerr << endl << "ERROR: Not allowed in combination of general window value." << endl << endl;
940  appearErrors = true;
941  }
942 
943  if((selectCols) || (selectSeqs)) {
944  cerr << endl << "ERROR: It's imposible to use this windows size in combination of manual selection method." << endl << endl;
945  appearErrors = true;
946  }
947 
948  else if((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)) {
949  cerr << endl << "ERROR: Not allowed in combination of automatic methods." << endl << endl;
950  appearErrors = true;
951  }
952 
953  else {
954  if(utils::isNumber(argv[i+1])) {
955  simWindow = atoi(argv[++i]);
956  if(simWindow <= 0){
957  cerr << endl << "ERROR: The window value should be a positive integer number." << endl << endl;
958  appearErrors = true;
959  }
960  }
961  else {
962  cerr << endl << "ERROR: The window value should be a number." << endl << endl;
963  appearErrors = true;
964  }
965  }
966  //~ i++;
967  }
968  /* ------------------------------------------------------------------------------------------------------ */
969 
970  /* Option -cw -------------------------------------------------------------------------------------------- */
971  else if(!strcmp(argv[i], "-cw") && (i+1 != argc) && (conWindow == -1)){
972 
973  if(windowSize != -1) {
974  cerr << endl << "ERROR: Not allowed in combination of general window value." << endl << endl;
975  appearErrors = true;
976  }
977 
978  if((selectCols) || (selectSeqs)) {
979  cerr << endl << "ERROR: It's imposible to use this windows size in combination of manual selection method." << endl << endl;
980  appearErrors = true;
981  }
982 
983  else {
984  if(utils::isNumber(argv[i+1])) {
985  conWindow = atoi(argv[++i]);
986  if(conWindow <= 0){
987  cerr << endl << "ERROR: The window value should be a positive integer number." << endl << endl;
988  appearErrors = true;
989  }
990  }
991  else {
992  cerr << endl << "ERROR: The window value should be a number." << endl << endl;
993  appearErrors = true;
994  }
995  }
996  //~ i++;
997  }
998  /* ------------------------------------------------------------------------------------------------------ */
999 
1000  /* ------------------------------------------------------------------------------------------------------ */
1001 
1002  /* Block Size Value */
1003 
1004  /* Option -block -------------------------------------------------------------------------------------------- */
1005  else if(!strcmp(argv[i], "-block") && (i+1 != argc) && (blockSize == -1)){
1006 
1007  if(selectCols) {
1008  cerr << endl << "ERROR: It's imposible to set a block size value in combination with a column manual selection" << endl << endl;
1009  appearErrors = true;
1010  }
1011 
1012  else if(conserve != -1) {
1013  cerr << endl << "ERROR: It's imposible to ask for a minimum percentage of the input alignment in combination with column block size" << endl << endl;
1014  appearErrors = true;
1015  }
1016 
1017  //~ else if((nogaps) || (noallgaps) || (strict) || (strictplus) || (automated1)) {
1018  else if((nogaps) || (noallgaps)) {
1019  cerr << endl << "ERROR: Not allowed in combination of automatic methods." << endl << endl;
1020  appearErrors = true;
1021  }
1022 
1023  else {
1024  if(utils::isNumber(argv[i+1])) {
1025  blockSize = atoi(argv[++i]);
1026  if(blockSize <= 0){
1027  cerr << endl << "ERROR: The block size value should be a positive integer number." << endl << endl;
1028  appearErrors = true;
1029  }
1030  }
1031  else {
1032  cerr << endl << "ERROR: The block size value should be a number." << endl << endl;
1033  appearErrors = true;
1034  }
1035  }
1036  }
1037  /* ------------------------------------------------------------------------------------------------------ */
1038 
1039  /* Statistics */
1040 
1041  /* Option -sgc ------------------------------------------------------------------------------------------ */
1042  else if((!strcmp(argv[i], "-sgc")) && (!sgc)) {
1043  sgc = true;
1044  stats--;
1045  }
1046  /* ------------------------------------------------------------------------------------------------------ */
1047 
1048  /* Option -sgt ------------------------------------------------------------------------------------------ */
1049  else if((!strcmp(argv[i], "-sgt")) && (!sgt)) {
1050  sgt = true;
1051  stats--;
1052  }
1053  /* ------------------------------------------------------------------------------------------------------ */
1054 
1055  /* Option -scc ------------------------------------------------------------------------------------------ */
1056  else if((!strcmp(argv[i], "-ssc")) && (!scc)) {
1057  scc = true;
1058  stats--;
1059  }
1060  /* ------------------------------------------------------------------------------------------------------ */
1061 
1062  /* Option -sct ------------------------------------------------------------------------------------------ */
1063  else if((!strcmp(argv[i], "-sst")) && (!sct)) {
1064  sct = true;
1065  stats--;
1066  }
1067  /* ------------------------------------------------------------------------------------------------------ */
1068 
1069  /* Option -sident --------------------------------------------------------------------------------------- */
1070  else if((!strcmp(argv[i], "-sident")) && (!sident)) {
1071  sident = true;
1072  stats--;
1073  }
1074 
1075  /* Option -soverlap --------------------------------------------------------------------------------------- */
1076  else if((!strcmp(argv[i], "-soverlap")) && (!soverlap)) {
1077  soverlap = true;
1078  stats--;
1079  }
1080  /* ------------------------------------------------------------------------------------------------------ */
1081 
1082  /* Option -sfc ------------------------------------------------------------------------------------------ */
1083  else if((!strcmp(argv[i], "-sfc")) && (!sfc)) {
1084 
1085  if(infile != NULL) {
1086  cerr << endl << "ERROR: Not allowed in combination with -in option." << endl << endl;
1087  appearErrors = true;
1088  i++;
1089  }
1090 
1091  else {
1092  sfc = true;
1093  stats--;
1094  }
1095  }
1096  /* ------------------------------------------------------------------------------------------------------ */
1097 
1098  /* Option -sft ------------------------------------------------------------------------------------------ */
1099  else if((!strcmp(argv[i], "-sft")) && (!sft)) {
1100 
1101  if(infile != NULL) {
1102  cerr << endl << "ERROR: Not allowed in combination with -in option." << endl << endl;
1103  appearErrors = true;
1104  i++;
1105  }
1106 
1107  else {
1108  sft = true;
1109  stats--;
1110  }
1111  }
1112  /* ------------------------------------------------------------------------------------------------------ */
1113 
1114  /* Others parameters */
1115 
1116  /* ------------------------------------------------------------------------------------------------------ */
1117 
1118  /* Option -complementary -------------------------------------------------------------------------------- */
1119  else if((!strcmp(argv[i], "-complementary")) && (complementary == false)) {
1120  complementary = true;
1121  }
1122 
1123  /* Option -colnumbering ------------------------------------------------------------------------------- */
1124  else if((!strcmp(argv[i], "-colnumbering")) && (colnumbering == false)) {
1125  colnumbering = true;
1126  }
1127 
1128  /* Option -splitbystopcodon ------------------------------------------------------------------------------- */
1129  else if((!strcmp(argv[i], "-splitbystopcodon")) && (splitbystop == false)) {
1130  splitbystop = true;
1131  }
1132 
1133  /* Option -ignorestopcodon ------------------------------------------------------------------------------- */
1134  else if((!strcmp(argv[i], "-ignorestopcodon")) && (ignorestop == false)) {
1135  ignorestop = true;
1136  }
1137 
1138  /* ------------------------------------------------------------------------------------------------------ */
1139 
1140  /* Not Valids Parameters */
1141 
1142  /* ------------------------------------------------------------------------------------------------------ */
1143  else {
1144  cerr << endl << "ERROR: Parameter \"" << argv[i] << "\" not valid." << endl << endl;
1145  appearErrors = true;
1146  }
1147  /* ------------------------------------------------------------------------------------------------------ */
1148  i++;
1149 
1150  if(appearErrors)
1151  break;
1152 
1153  }
1154  /* ------------------------------------------------------------------------------------------------------ */
1155 
1156  /* Postprocessing Parameters */
1157 
1158 
1159  /* ------------------------------------------------------------------------------------------------------ */
1160  if((!appearErrors) && (infile != NULL) && (forceFile != NULL)) {
1161  cerr << endl << "ERROR: You can not use a single alignmet at the same "
1162  << "time that you force the alignment selection." << endl << endl;
1163  appearErrors = true;
1164  }
1165  /* ------------------------------------------------------------------------------------------------------ */
1166  if((!appearErrors) && (compareset == -1) && (forceFile != NULL)) {
1167  cerr << endl << "ERROR: You can not force the alignment selection without set"
1168  << " an alignment dataset against to compare it." << endl << endl;
1169  appearErrors = true;
1170  }
1171  /* ------------------------------------------------------------------------------------------------------ */
1172  if((!appearErrors) && (infile == NULL) && (compareset == -1) && (forceFile == NULL) && (backtransFile != NULL)) {
1173  cerr << endl << "ERROR: It is impossible to use a Coding Sequences file to apply the back translation method"
1174  << " without define an input alignment." << endl << endl;
1175  appearErrors = true;
1176  }
1177  /* ------------------------------------------------------------------------------------------------------ */
1178  if((!appearErrors) && (infile != NULL)) {
1179 
1180  if(((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1) ||
1181  (gapThreshold != -1) || (conserve != -1) || (simThreshold != -1) || (selectCols) || (selectSeqs) ||
1182  (resOverlap != -1) || (seqOverlap != -1) || (stats < 0)) &&
1183  (!origAlig -> isFileAligned())) {
1184  cerr << endl << "ERROR: The sequences in the input alignment should be aligned in order to use trimming method." << endl << endl;
1185  appearErrors = true;
1186  }
1187  }
1188  /* ------------------------------------------------------------------------------------------------------ */
1189  if((!appearErrors) && (windowSize != -1) && (compareset != -1))
1190  cerr << "INFO: Try with specific comparison file window value. parameter -cw." << endl << endl;
1191  /* ------------------------------------------------------------------------------------------------------ */
1192 
1193  /* ------------------------------------------------------------------------------------------------------ */
1194  if((matrix != NULL) && (!appearErrors)) {
1195  if((!strict) && (!strictplus) && (!automated1) && (simThreshold == -1.0) && (!scc) && (!sct)) {
1196  cerr << endl << "ERROR: The Similarity Matrix can only be used with methods that use this matrix." << endl << endl;
1197  appearErrors = true;
1198  }
1199 
1200  if((gapWindow != -1) ||((compareset == -1) && (conWindow != -1))) {
1201  cerr << endl << "ERROR: The Similarity Matrix can only be used with general/similarity windows size." << endl << endl;
1202  appearErrors = true;
1203  }
1204  }
1205  /* ------------------------------------------------------------------------------------------------------ */
1206 
1207  /* ------------------------------------------------------------------------------------------------------ */
1208  if((complementary) && (!appearErrors))
1209  if((!nogaps) && (!noallgaps) && (!gappyout) && (!strict) && (!strictplus) && (!automated1)
1210  && (gapThreshold == -1) && (conserve == -1) && (simThreshold == -1) && (!selectCols) && (!selectSeqs)
1211  && (resOverlap == -1) && (seqOverlap == -1) && (maxIdentity == -1) && (clusters == -1)) {
1212  cerr << endl << "ERROR: This parameter can only be used with either an automatic or a manual method." << endl << endl;
1213  appearErrors = true;
1214  }
1215  /* ------------------------------------------------------------------------------------------------------ */
1216 
1217  /* ------------------------------------------------------------------------------------------------------ */
1218  if((terminal) && (boundaries != NULL) && (!appearErrors)) {
1219  num = origAlig -> getNumAminos();
1220 
1221  if((!nogaps) && (!noallgaps) && (!gappyout) && (!strict) && (!strictplus) && (!automated1)
1222  && (gapThreshold == -1) && (conserve == -1) && (simThreshold == -1) && (!selectCols) && (!selectSeqs)
1223  && (resOverlap == -1) && (seqOverlap == -1) && (maxIdentity == -1) && (clusters == -1)) {
1224  cerr << endl << "ERROR: This parameter '--set_boundaries' can only be used with either an automatic or a manual method." << endl << endl;
1225  appearErrors = true;
1226  }
1227 
1228  else if(boundaries[1] >= num) {
1229  cerr << endl << "ERROR: \"--set_boundaries\" parameter only accepts "
1230  << "integer numbers between 0 and the number of positions (" << num
1231  << ") - 1." << endl << endl;
1232  appearErrors = true;
1233  }
1234  }
1235 
1236  if((terminal) && (boundaries == NULL) && (!appearErrors))
1237  if((!nogaps) && (!noallgaps) && (!gappyout) && (!strict) && (!strictplus) && (!automated1)
1238  && (gapThreshold == -1) && (conserve == -1) && (simThreshold == -1) && (!selectCols) && (!selectSeqs)
1239  && (resOverlap == -1) && (seqOverlap == -1) && (maxIdentity == -1) && (clusters == -1)) {
1240  cerr << endl << "ERROR: This parameter '-terminalonly' can only be used with either an automatic or a manual method." << endl << endl;
1241  appearErrors = true;
1242  }
1243  /* ------------------------------------------------------------------------------------------------------ */
1244 
1245  /* ------------------------------------------------------------------------------------------------------ */
1246  if((colnumbering) && (!appearErrors)) {
1247  if((!nogaps) && (!noallgaps) && (!gappyout) && (!strict) && (!strictplus) && (!automated1)
1248  && (gapThreshold == -1) && (conserve == -1) && (simThreshold == -1) && (comThreshold == -1) && (!selectCols) && (!selectSeqs)) {
1249  cerr << endl << "ERROR: This parameter can only be used with any trimming method." << endl << endl;
1250  appearErrors = true;
1251  }
1252  else if(stats < 0) {
1253  cerr << endl << "ERROR: This parameter is not valid when statistics' parameters are defined." << endl << endl;
1254  appearErrors = true;
1255  }
1256  }
1257  /* ------------------------------------------------------------------------------------------------------ */
1258 
1259  /* ------------------------------------------------------------------------------------------------------ */
1260  if((outhtml != NULL) && (outfile != NULL) && (!appearErrors)) {
1261  if(!strcmp(outhtml, outfile)) {
1262  cerr << endl << "ERROR: The output and html files should not be the same." << endl << endl;
1263  appearErrors = true;
1264  }
1265  }
1266 
1267  /* ------------------------------------------------------------------------------------------------------ */
1268 
1269  if((outhtml != NULL) && (!appearErrors)) {
1270  if((!nogaps) && (!noallgaps) && (!gappyout) && (!strict) && (!strictplus) && (!automated1) &&
1271  (gapThreshold == -1) && (conserve == -1) && (simThreshold == -1) && (comThreshold == -1) &&
1272  (!selectCols) && (!selectSeqs) && (resOverlap == -1) && (seqOverlap == -1) && (maxIdentity == -1) &&
1273  (clusters == -1)) {
1274  cerr << endl << "ERROR: This parameter can only be used with any trimming method." << endl << endl;
1275  appearErrors = true;
1276  }
1277  }
1278  /* ------------------------------------------------------------------------------------------------------ */
1279 
1280  /* ------------------------------------------------------------------------------------------------------ */
1281 
1282  //~ if((outhtml != NULL) && (!appearErrors)) {
1283  //~ if(((gapThreshold != -1) || (simThreshold != -1)) && (comThreshold != -1)) {
1284  //~ cerr << endl << "ERROR: Impossible to generate the HTML file using two consecutive trimming methods." << endl << endl;
1285  //~ appearErrors = true;
1286  //~ }
1287  //~ }
1288  /* ------------------------------------------------------------------------------------------------------ */
1289 
1290 
1291  /* ------------------------------------------------------------------------------------------------------ */
1292  if(((resOverlap != -1) || (seqOverlap != -1)) && (!appearErrors)) {
1293 
1294  if((resOverlap != -1) && (seqOverlap == -1)) {
1295  cerr << endl << "ERROR: The sequence overlap value should be defined." << endl << endl;
1296  appearErrors = true;
1297  }
1298 
1299  else if((resOverlap == -1) && (seqOverlap != -1)) {
1300  cerr << endl << "ERROR: The residue overlap value should be defined." << endl << endl;
1301  appearErrors = true;
1302  }
1303  }
1304  /* ------------------------------------------------------------------------------------------------------ */
1305 
1306  /* ------------------------------------------------------------------------------------------------------ */
1307  if((stats < 0) && (!appearErrors)) {
1308  stats--;
1309 
1310  if(((nogaps) || (noallgaps) || (gappyout) || (strict) || (strictplus) || (automated1)
1311  || (gapThreshold != -1) || (conserve != -1) || (simThreshold != -1)) && (outfile == NULL)) {
1312  cerr << endl << "ERROR: An output file should be defined in order to get the alignment's statistics." << endl << endl;
1313  appearErrors = true;
1314  }
1315  }
1316  /* ------------------------------------------------------------------------------------------------------ */
1317 
1318  /* ------------------------------------------------------------------------------------------------------ */
1319  if((comThreshold != -1) && (conserve != -1) && (!appearErrors)) {
1320 
1321  if((gapThreshold != -1) || (simThreshold != -1)) {
1322  cerr << endl << "ERROR: Combinations among thresholds are not allowed." << endl << endl;
1323  appearErrors = true;
1324  }
1325  }
1326  /* **** ***** ***** ***** ***** ***** **** **************************** **** ***** ***** ***** ***** ***** **** */
1327 
1328  /* **** ***** ***** ***** ***** ***** ***** Files Comparison Methods ***** ***** ***** ***** ***** ***** **** */
1329  if((compareset != -1) && (!appearErrors)) {
1330 
1331  compAlig = new alignment*[numfiles];
1332  filesToCompare = new char*[numfiles];
1333 
1334  /* -------------------------------------------------------------------- */
1335  compare.open(argv[compareset], ifstream::in);
1336 
1337  for(i = 0; (i < numfiles) && (!appearErrors); i++) {
1338 
1339  /* -------------------------------------------------------------------- */
1340  for(nline.clear(), compare.read(&c, 1); (c != '\n') && ((!compare.eof())); compare.read(&c, 1))
1341  nline += c;
1342 
1343  filesToCompare[i] = new char [nline.size() + 1];
1344  strcpy(filesToCompare[i], nline.c_str());
1345  /* -------------------------------------------------------------------- */
1346 
1347  /* -------------------------------------------------------------------- */
1348  compAlig[i] = new alignment;
1349  if(!compAlig[i] -> loadAlignment(filesToCompare[i])) {
1350  cerr << endl << "Alignment not loaded: \"" << filesToCompare[i] << "\" Check the file's content." << endl << endl;
1351  appearErrors = true;
1352  }
1353 
1354  else {
1355  if(!compAlig[i] -> isFileAligned()) {
1356  cerr << endl << "ERROR: The sequences in the input alignment should be aligned in order to use this method." << endl << endl;
1357  appearErrors = true;
1358  } else {
1359  compAlig[i] -> sequenMatrix();
1360 
1361  if(compAlig[i] -> getNumAminos() > maxAminos)
1362  maxAminos = compAlig[i] -> getNumAminos();
1363 
1364  if((compAlig[i] -> getTypeAlignment() != alignDataType) && (alignDataType != -1)) {
1365  cerr << endl << "ERROR: The alignments' datatypes are different. Check your dataset." << endl << endl;
1366  appearErrors = true;
1367  } else
1368  alignDataType = compAlig[i] -> getTypeAlignment();
1369  }
1370  }
1371  }
1372  /* -------------------------------------------------------------------- */
1373 
1374  /* -------------------------------------------------------------------- */
1375  if((!appearErrors) && (forceFile == NULL)) {
1376 
1377  compareVect = new float[maxAminos];
1378  if((stats >= 0) && (outfile != NULL))
1379  referFile = compareFiles::algorithm(compAlig, filesToCompare, compareVect, numfiles, true);
1380  else
1381  referFile = compareFiles::algorithm(compAlig, filesToCompare, compareVect, numfiles, false);
1382 
1383  if(windowSize != -1)
1384  compareFiles::applyWindow(compAlig[referFile] -> getNumAminos(), windowSize, compareVect);
1385  else if(conWindow != -1)
1386  compareFiles::applyWindow(compAlig[referFile] -> getNumAminos(), conWindow, compareVect);
1387 
1388  origAlig -> loadAlignment(filesToCompare[referFile]);
1389 
1390  } else if((!appearErrors) && (forceFile != NULL)) {
1391 
1392  compareVect = new float[origAlig -> getNumAminos()];
1393  appearErrors = !(compareFiles::forceComparison(compAlig, numfiles, origAlig, compareVect));
1394 
1395  if((windowSize != -1) && (!appearErrors))
1396  compareFiles::applyWindow(origAlig -> getNumAminos(), windowSize, compareVect);
1397  else if((conWindow != -1) && (!appearErrors))
1398  compareFiles::applyWindow(origAlig -> getNumAminos(), conWindow, compareVect);
1399  }
1400  /* -------------------------------------------------------------------- */
1401 
1402  /* -------------------------------------------------------------------- */
1403  for(i = 0; i < numfiles; i++) {
1404  delete compAlig[i];
1405  delete filesToCompare[i];
1406  }
1407  /* -------------------------------------------------------------------- */
1408  }
1409 
1410  /* **** ***** ***** ***** ***** ***** **** **************************** **** ***** ***** ***** ***** ***** **** */
1411 
1412  /* ------------------------------------------------------------------------------------------------------ */
1413  if((!appearErrors) && (origAlig -> getNumAminos() < (blockSize/4))) {
1414  cerr << endl << "ERROR: The block size value is too big. Please, choose another one smaller than residues number / 4." << endl << endl;
1415  appearErrors = true;
1416  }
1417 
1418  if((!appearErrors) && (backtransFile != NULL) && (backtranslation -> getTypeAlignment() != DNAType && backtranslation -> getTypeAlignment() != DNADeg)) {
1419  cerr << endl << "ERROR: Check your Coding sequences file. It has been detected other kind of biological sequences." << endl << endl;
1420  appearErrors = true;
1421  }
1422  /* ------------------------------------------------------------------------------------------------------ */
1423  if((!appearErrors) && (origAlig -> isFileAligned() != true) && (backtransFile != NULL)) {
1424  cerr << endl << "ERROR: The input protein file has to be aligned to carry out the backtranslation process" << endl << endl;
1425  appearErrors = true;
1426  }
1427  /* ------------------------------------------------------------------------------------------------------ */
1428  if((!appearErrors) && (backtransFile == NULL) && (splitbystop)) {
1429  cerr << endl << "ERROR: The -splitbystopcodon parameter can be only set up with backtranslation functionality." << endl << endl;
1430  appearErrors = true;
1431  }
1432  /* ------------------------------------------------------------------------------------------------------ */
1433  if((!appearErrors) && (backtransFile == NULL) && (ignorestop)) {
1434  cerr << endl << "ERROR: The -ignorestopcodon parameter can be only set up with backtranslation functionality." << endl << endl;
1435  appearErrors = true;
1436  }
1437  /* ------------------------------------------------------------------------------------------------------ */
1438  if((!appearErrors) && (ignorestop) && (splitbystop)) {
1439  cerr << endl << "ERROR: Incompatibility of -ignorestopcodon & -splitbystopcodon parameters. Choose one." << endl << endl;
1440  appearErrors = true;
1441  }
1442  /* ------------------------------------------------------------------------------------------------------ */
1443  if((!appearErrors) && (backtransFile != NULL) && (backtranslation -> prepareCodingSequence(splitbystop, ignorestop, origAlig) != true))
1444  appearErrors = true;
1445 
1446  /* ------------------------------------------------------------------------------------------------------ */
1447  if((!appearErrors) && (backtransFile != NULL)) {
1448 
1449  seqNames = new string[backtranslation -> getNumSpecies()];
1450  seqLengths = new int[backtranslation -> getNumSpecies()];
1451  backtranslation -> getSequences(seqNames, seqLengths);
1452 
1453  if(origAlig -> checkCorrespondence(seqNames, seqLengths, backtranslation -> getNumSpecies(), 3) != true)
1454  appearErrors = true;
1455  }
1456  /* ------------------------------------------------------------------------------------------------------ */
1457 
1458  /* **** ***** ***** ***** ***** ***** **** End of Parameters Processing **** ***** ***** ***** ***** ***** **** */
1459 
1460 
1461  /* **** ***** ***** ***** ***** ***** **** Errors Control **** ***** ***** ***** ***** ***** **** */
1462  if(appearErrors) {
1463 
1464  delete singleAlig;
1465  delete origAlig;
1466  delete[] compAlig;
1467 
1468  delete similMatrix;
1469  delete []delColumns;
1470 
1471  delete[] filesToCompare;
1472  delete[] compareVect;
1473 
1474  delete[] outfile;
1475  delete[] outhtml;
1476 
1477  delete[] infile;
1478  delete[] matrix;
1479 
1480  if(forceFile != NULL) delete forceFile;
1481  if(backtransFile != NULL) delete backtransFile;
1482  if(backtranslation != NULL) delete backtranslation;
1483 
1484  return -1;
1485  }
1486  /* **** ***** ***** ***** ***** ***** ** End Errors Control ** ***** ***** ***** ***** ***** **** */
1487 
1488  /* -------------------------------------------------------------------- */
1489  if(conserve == -1)
1490  conserve = 0;
1491  /* -------------------------------------------------------------------- */
1492 
1493  origAlig -> trimTerminalGaps(terminal, boundaries);
1494  origAlig -> setKeepSequencesFlag(keepSeqs);
1495  origAlig -> setKeepSeqsHeaderFlag(keepHeader);
1496 
1497  /* -------------------------------------------------------------------- */
1498  if(windowSize != -1) {
1499  gapWindow = windowSize;
1500  simWindow = windowSize;
1501  }
1502  else {
1503  if(gapWindow == -1)
1504  gapWindow = 0;
1505  if(simWindow == -1)
1506  simWindow = 0;
1507  }
1508  origAlig -> setWindowsSize(gapWindow, simWindow);
1509 
1510  /* -------------------------------------------------------------------- */
1511 
1512  /* -------------------------------------------------------------------- */
1513  if(blockSize != -1)
1514  origAlig -> setBlockSize(blockSize);
1515 
1516  /* -------------------------------------------------------------------- */
1517 
1518  /* -------------------------------------------------------------------- */
1519  if(outformat != -1)
1520  origAlig -> setOutputFormat(outformat, shortNames);
1521  /* -------------------------------------------------------------------- */
1522 
1523  /* -------------------------------------------------------------------- */
1524  if((strict) || (strictplus) || (automated1) || (simThreshold != -1.0) || (scc == 1) || (sct == 1)) {
1525  similMatrix = new similarityMatrix();
1526 
1527  if(matrix != NULL)
1528  similMatrix -> loadSimMatrix(matrix);
1529 
1530  /* User can choose alternative matrices such as other BLOSUMs, PAMs, Identity Matrices, etc */
1531  else if(alternative_matrix != -1) {
1532  alignDataType = origAlig -> getTypeAlignment();
1533  similMatrix -> alternativeSimilarityMatrices(alternative_matrix, alignDataType);
1534  }
1535 
1536  else {
1537  alignDataType = origAlig -> getTypeAlignment();
1538  if(alignDataType == AAType)
1539  similMatrix -> defaultAASimMatrix();
1540  else if((alignDataType == DNAType) || (alignDataType == RNAType))
1541  similMatrix -> defaultNTSimMatrix();
1542  else if((alignDataType == DNADeg) || (alignDataType == RNADeg))
1543  similMatrix -> defaultNTDegeneratedSimMatrix();
1544  }
1545 
1546  if(!origAlig -> setSimilarityMatrix(similMatrix)) {
1547  cerr << endl << "ERROR: It's imposible to proccess the Similarity Matrix." << endl << endl;
1548  return -1;
1549  }
1550  }
1551  /* -------------------------------------------------------------------- */
1552 
1553  /* -------------------------------------------------------------------- */
1554  if(sgc) {
1555  origAlig -> printStatisticsGapsColumns();
1556  stats++;
1557  if(stats < -1)
1558  cout << endl;
1559  }
1560 
1561  if(sgt) {
1562  origAlig -> printStatisticsGapsTotal();
1563  stats++;
1564  if(stats < -1)
1565  cout << endl;
1566  }
1567 
1568  if(scc) {
1569  origAlig -> printStatisticsConservationColumns();
1570  stats++;
1571  if(stats < -1)
1572  cout << endl;
1573  }
1574 
1575  if(sct) {
1576  origAlig -> printStatisticsConservationTotal();
1577  stats++;
1578  if(stats < -1)
1579  cout << endl;
1580  }
1581 
1582  if(sident) {
1583  origAlig -> printSeqIdentity();
1584  stats++;
1585  if(stats < -1)
1586  cout << endl;
1587  }
1588 
1589  if(soverlap) {
1590  origAlig -> printSeqOverlap();
1591  stats++;
1592  if(stats < -1)
1593  cout << endl;
1594  }
1595  /* -------------------------------------------------------------------- */
1596 
1597  /* -------------------------------------------------------------------- */
1598  if(compareset != -1) {
1599  if(sfc)
1600  compareFiles::printStatisticsFileColumns(origAlig -> getNumAminos(), compareVect);
1601  if(sft)
1602  compareFiles::printStatisticsFileAcl(origAlig -> getNumAminos(), compareVect);
1603  }
1604  /* -------------------------------------------------------------------- */
1605 
1606  /* -------------------------------------------------------------------- */
1607  if(backtransFile != NULL)
1608  seqMatrix = origAlig -> getSeqMatrix();
1609  /* -------------------------------------------------------------------- */
1610 
1611  /* -------------------------------------------------------------------- */
1612  if(nogaps)
1613  singleAlig = origAlig -> cleanGaps(0, 0, complementary);
1614 
1615  else if(noallgaps)
1616  singleAlig = origAlig -> cleanNoAllGaps(complementary);
1617 
1618  else if(gappyout)
1619  singleAlig = origAlig -> clean2ndSlope(complementary);
1620 
1621  else if(strict)
1622  singleAlig = origAlig -> cleanCombMethods(complementary, false);
1623 
1624  else if(strictplus)
1625  singleAlig = origAlig -> cleanCombMethods(complementary, true);
1626 
1627  else if(automated1) {
1628  if(origAlig -> selectMethod() == GAPPYOUT)
1629  singleAlig = origAlig -> clean2ndSlope(complementary);
1630  else
1631  singleAlig = origAlig -> cleanCombMethods(complementary, false);
1632  }
1633  /* -------------------------------------------------------------------- */
1634 
1635  /* -------------------------------------------------------------------- */
1636  if(comThreshold != -1)
1637  singleAlig = origAlig -> cleanCompareFile(comThreshold, conserve, compareVect, complementary);
1638  /* -------------------------------------------------------------------- */
1639 
1640  /* -------------------------------------------------------------------- */
1641  if((resOverlap != -1) && (seqOverlap != -1)) {
1642  intermediateAlig = origAlig -> cleanSpuriousSeq(resOverlap, (seqOverlap/100), complementary);
1643  singleAlig = intermediateAlig -> cleanNoAllGaps(false);
1644 
1645  delete intermediateAlig;
1646  }
1647  /* -------------------------------------------------------------------- */
1648 
1649  /* -------------------------------------------------------------------- */
1650  if(simThreshold != -1.0) {
1651  if(gapThreshold != -1.0)
1652  singleAlig = origAlig -> clean(conserve, gapThreshold, simThreshold, complementary);
1653  else
1654  singleAlig = origAlig -> cleanConservation(conserve, simThreshold, complementary);
1655  }
1656  /* -------------------------------------------------------------------- */
1657 
1658  /* -------------------------------------------------------------------- */
1659  else if(gapThreshold != -1.0)
1660  singleAlig = origAlig -> cleanGaps(conserve, gapThreshold, complementary);
1661  /* -------------------------------------------------------------------- */
1662 
1663  /* -------------------------------------------------------------------- */
1664  if((selectCols) || (selectSeqs)) {
1665 
1666  /* Columns and/or sequences to be removed might be disordered. Therefore,
1667  * we cannot assume the last element of the vectors are the highest ones.
1668  * We check every single element to make sure they are inbetween the
1669  * established boundaries e.g. max number of sequences and/or columns.
1670  */
1671 
1672  if(delColumns != NULL) {
1673  num = origAlig -> getNumAminos();
1674 
1675  for(i = 1; i < delColumns[0] + 1; i++)
1676  if(delColumns[i] >= num) {
1677  cerr << endl << "ERROR: This option only accepts integer numbers "
1678  "between 0 and the number of columns - 1." << endl << endl;
1679  appearErrors = true;
1680  break;
1681  }
1682 
1683  if (!appearErrors)
1684  singleAlig = origAlig -> removeColumns(delColumns, 1, delColumns[0],
1685  complementary);
1686 
1687  }
1688 
1689  if(delSequences != NULL) {
1690  num = origAlig -> getNumSpecies();
1691 
1692  for(i = 1; i < delSequences[0] + 1; i++)
1693  if(delSequences[i] >= num) {
1694  cerr << endl << "ERROR: This option only accepts integer numbers "
1695  "between 0 and the number of sequences - 1." << endl << endl;
1696  appearErrors = true;
1697  break;
1698  }
1699 
1700  if (!appearErrors) {
1701  intermediateAlig = origAlig -> removeSequences(delSequences, 1,
1702  delSequences[0], complementary);
1703  singleAlig = intermediateAlig -> cleanNoAllGaps(false);
1704 
1705  delete intermediateAlig;
1706  }
1707  }
1708  }
1709  /* -------------------------------------------------------------------- */
1710 
1711  /* -------------------------------------------------------------------- */
1712  if(maxIdentity != -1) {
1713  intermediateAlig = origAlig -> getClustering(maxIdentity);
1714  singleAlig = intermediateAlig -> cleanNoAllGaps(false);
1715 
1716  delete intermediateAlig;
1717  }
1718  else if(clusters != -1) {
1719  if(clusters > origAlig -> getNumSpecies()) {
1720  cerr << endl << "ERROR:The number of clusters from the alignment can not be larger than the number of sequences from that alignment." << endl << endl;
1721  appearErrors = true;
1722  } else {
1723  intermediateAlig = origAlig -> getClustering(origAlig -> getCutPointClusters(clusters));
1724  singleAlig = intermediateAlig -> cleanNoAllGaps(false);
1725 
1726  delete intermediateAlig;
1727  }
1728  }
1729  /* -------------------------------------------------------------------- */
1730 
1731  /* -------------------------------------------------------------------- */
1732  if(singleAlig == NULL) {
1733  singleAlig = origAlig;
1734  origAlig = NULL;
1735  }
1736  /* -------------------------------------------------------------------- */
1737 
1738  /* -------------------------------------------------------------------- */
1739  if((outhtml != NULL) && (!appearErrors))
1740  if(!origAlig -> alignmentSummaryHTML(outhtml, singleAlig -> getNumAminos(), singleAlig -> getNumSpecies(),
1741  singleAlig -> getCorrespResidues(), singleAlig -> getCorrespSequences(), compareVect)) {
1742  cerr << endl << "ERROR: It's imposible to generate the HTML output file." << endl << endl;
1743  appearErrors = true;
1744  }
1745  /* -------------------------------------------------------------------- */
1746 
1747  /* -------------------------------------------------------------------- */
1748  if(backtransFile != NULL) {
1749 
1750  if(seqNames != NULL) delete [] seqNames;
1751  seqNames = new string[singleAlig -> getNumSpecies()];
1752 
1753  singleAlig -> getSequences(seqNames);
1754 
1755  singleAlig = backtranslation -> getTranslationCDS(singleAlig -> getNumAminos(), singleAlig -> getNumSpecies(),
1756  singleAlig -> getCorrespResidues(), seqNames, seqMatrix, singleAlig);
1757  }
1758  /* -------------------------------------------------------------------- */
1759 
1760  /* -------------------------------------------------------------------- */
1761  if((outfile != NULL) && (!appearErrors)) {
1762  if(!singleAlig -> saveAlignment(outfile)) {
1763  cerr << endl << "ERROR: It's imposible to generate the output file." << endl << endl;
1764  appearErrors = true;
1765  }
1766  }
1767  else if((stats >= 0) && (!appearErrors))
1768  singleAlig -> printAlignment();
1769  /* -------------------------------------------------------------------- */
1770 
1771  /* -------------------------------------------------------------------- */
1772  if((colnumbering) && (!appearErrors))
1773  singleAlig -> printCorrespondence();
1774  /* -------------------------------------------------------------------- */
1775 
1776  /* -------------------------------------------------------------------- */
1777  delete singleAlig;
1778  delete origAlig;
1779 
1780  delete[] compAlig;
1781 
1782  delete similMatrix;
1783  delete []delColumns;
1784 
1785  delete[] filesToCompare;
1786  delete[] compareVect;
1787 
1788  delete[] outfile;
1789  delete[] outhtml;
1790 
1791  delete[] infile;
1792  delete[] matrix;
1793  /* -------------------------------------------------------------------- */
1794 
1795  return 0;
1796 }
1797 
1798 void menu(void) {
1799 
1800  cout << endl;
1801  cout << "trimAl v" << VERSION << ".rev" << REVISION << " build[" << BUILD
1802  << "]. " << AUTHORS << endl << endl;
1803 
1804  cout << "trimAl webpage: http://trimal.cgenomics.org" << endl << endl;
1805 
1806  cout << "This program is free software: you can redistribute it and/or modify " << endl
1807  << "it under the terms of the GNU General Public License as published by " << endl
1808  << "the Free Software Foundation, the last available version." << endl << endl;
1809 
1810  cout << "Please cite:" << endl
1811  << "\t\ttrimAl: a tool for automated alignment trimming in large-scale phylogenetic analyses."
1812  << "\n\t\tSalvador Capella-Gutierrez; Jose M. Silla-Martinez; Toni Gabaldon."
1813  << "\n\t\tBioinformatics 2009, 25:1972-1973." << endl << endl;
1814 
1815  cout << "Basic usage" << endl
1816  << "\ttrimal -in <inputfile> -out <outputfile> -(other options)." << endl << endl;
1817 
1818  cout << "Common options (for a complete list please see the User Guide or visit http://trimal.cgenomics.org):" << endl << endl;
1819  cout << " -h " << "Print this information and show some examples." << endl;
1820  cout << " --version " << "Print the trimAl version." << endl << endl;
1821 
1822  cout << " -in <inputfile> " << "Input file in several formats (clustal, fasta, NBRF/PIR, nexus, phylip3.2, phylip)." << endl << endl;
1823 
1824  cout << " -compareset <inputfile> " << "Input list of paths for the files containing the alignments to compare." << endl;
1825  cout << " -forceselect <inputfile> " << "Force selection of the given input file in the files comparison method." << endl << endl;
1826 
1827  cout << " -backtrans <inputfile> " << "Use a Coding Sequences file to get a backtranslation for a given AA alignment" << endl;
1828  cout << " -ignorestopcodon " << "Ignore stop codons in the input coding sequences" << endl;
1829  cout << " -splitbystopcodon " << "Split input coding sequences up to first stop codon appearance" << endl << endl;
1830 
1831 
1832  cout << " -matrix <inpufile> " << "Input file for user-defined similarity matrix (default is Blosum62)." << endl;
1833  cout << " --alternative_matrix <name> " << "Select an alternative similarity matrix already loaded. " << endl
1834  << " Only available 'degenerated_nt_identity'" << endl << endl;
1835 
1836  cout << " -out <outputfile> " << "Output alignment in the same input format (default stdout). (default input format)" << endl;
1837  cout << " -htmlout <outputfile> " << "Get a summary of trimal's work in an HTML file." << endl << endl;
1838 
1839  cout << " -keepheader " << "Keep original sequence header including non-alphanumeric characters." << endl;
1840  cout << " " << "Only available for input FASTA format files. (future versions will extend this feature)" << endl << endl;
1841 
1842  cout << " -nbrf " << "Output file in NBRF/PIR format" << endl;
1843  cout << " -mega " << "Output file in MEGA format" << endl;
1844  cout << " -nexus " << "Output file in NEXUS format" << endl;
1845  cout << " -clustal " << "Output file in CLUSTAL format" << endl << endl;
1846 
1847  cout << " -fasta " << "Output file in FASTA format" << endl;
1848  cout << " -fasta_m10 " << "Output file in FASTA format. Sequences name length up to 10 characters." << endl << endl;
1849 
1850  cout << " -phylip " << "Output file in PHYLIP/PHYLIP4 format" << endl;
1851  cout << " -phylip_m10 " << "Output file in PHYLIP/PHYLIP4 format. Sequences name length up to 10 characters." << endl;
1852  cout << " -phylip_paml " << "Output file in PHYLIP format compatible with PAML" << endl;
1853  cout << " -phylip_paml_m10 " << "Output file in PHYLIP format compatible with PAML. Sequences name length up to 10 characters." << endl;
1854  cout << " -phylip3.2 " << "Output file in PHYLIP3.2 format" << endl;
1855  cout << " -phylip3.2_m10 " << "Output file in PHYLIP3.2 format. Sequences name length up to 10 characters." << endl << endl;
1856 
1857  cout << " -complementary " << "Get the complementary alignment." << endl;
1858  cout << " -colnumbering " << "Get the relationship between the columns in the old and new alignment." << endl << endl;
1859 
1860  cout << " -selectcols { n,l,m-k } " << "Selection of columns to be removed from the alignment. Range: [0 - (Number of Columns - 1)]. (see User Guide)." << endl;
1861  cout << " -selectseqs { n,l,m-k } " << "Selection of sequences to be removed from the alignment. Range: [0 - (Number of Sequences - 1)]. (see User Guide)." << endl << endl;
1862 
1863  cout << " -gt -gapthreshold <n> " << "1 - (fraction of sequences with a gap allowed). Range: [0 - 1]" << endl;
1864  cout << " -st -simthreshold <n> " << "Minimum average similarity allowed. Range: [0 - 1]" << endl;
1865  cout << " -ct -conthreshold <n> " << "Minimum consistency value allowed.Range: [0 - 1]" << endl;
1866  cout << " -cons <n> " << "Minimum percentage of the positions in the original alignment to conserve. Range: [0 - 100]" << endl << endl;
1867 
1868  cout << " -nogaps " << "Remove all positions with gaps in the alignment." << endl;
1869  cout << " -noallgaps " << "Remove columns composed only by gaps." << endl;
1870  cout << " -keepseqs " << "Keep sequences even if they are composed only by gaps." << endl << endl;
1871 
1872  cout << " -gappyout " << "Use automated selection on \"gappyout\" mode. This method only uses "
1873  << "information based on gaps' distribution. (see User Guide)." << endl;
1874  cout << " -strict " << "Use automated selection on \"strict\" mode. (see User Guide)." << endl;
1875  cout << " -strictplus " << "Use automated selection on \"strictplus\" mode. (see User Guide)." << endl;
1876  cout << " " << "(Optimized for Neighbour Joining phylogenetic tree reconstruction)."<< endl << endl;
1877 
1878  cout << " -automated1 " << "Use a heuristic selection of the automatic method based on similarity statistics. "
1879  << "(see User Guide). (Optimized for Maximum Likelihood phylogenetic tree reconstruction)."
1880  << endl << endl;
1881 
1882  cout << " -terminalonly " << "Only columns out of internal boundaries (first and last column without gaps) are " << endl;
1883  cout << " " << "candidates to be trimmed depending on the selected method" << endl;
1884 
1885  cout << " --set_boundaries { l,r } " << "Set manually left (l) and right (r) boundaries - only columns out of these boundaries are " << endl;
1886  cout << " " << "candidates to be trimmed depending on the selected method. Range: [0 - (Number of Columns - 1)]" << endl;
1887 
1888 
1889  cout << " -block <n> " << "Minimum column block size to be kept in the trimmed alignment. Available with manual"
1890  << " and automatic (gappyout) methods" << endl << endl;
1891 
1892 
1893  cout << " -resoverlap " << "Minimum overlap of a positions with other positions in the column to be considered a "
1894  << "\"good position\". Range: [0 - 1]. (see User Guide)." << endl;
1895  cout << " -seqoverlap " << "Minimum percentage of \"good positions\" that a sequence must have in order to be conserved. Range: [0 - 100]"
1896  << "(see User Guide)." << endl << endl;
1897 
1898  cout << " -clusters <n> " << "Get the most Nth representatives sequences from a given alignment. Range: [1 - (Number of sequences)]" << endl;
1899  cout << " -maxidentity <n> " << "Get the representatives sequences for a given identity threshold. Range: [0 - 1]." << endl << endl;
1900 
1901  cout << " -w <n> " << "(half) Window size, score of position i is the average of the window (i - n) to (i + n)."
1902  << endl;
1903  cout << " -gw <n> " << "(half) Window size only applies to statistics/methods based on Gaps." << endl;
1904  cout << " -sw <n> " << "(half) Window size only applies to statistics/methods based on Similarity." << endl;
1905  cout << " -cw <n> " << "(half) Window size only applies to statistics/methods based on Consistency." << endl << endl;
1906 
1907  cout << " -sgc " << "Print gap scores for each column in the input alignment." << endl;
1908  cout << " -sgt " << "Print accumulated gap scores for the input alignment." << endl;
1909  cout << " -ssc " << "Print similarity scores for each column in the input alignment." << endl;
1910  cout << " -sst " << "Print accumulated similarity scores for the input alignment." << endl;
1911  cout << " -sfc " << "Print sum-of-pairs scores for each column from the selected alignment"
1912  << endl;
1913  cout << " -sft " << "Print accumulated sum-of-pairs scores for the selected alignment"
1914  << endl;
1915  cout << " -sident " << "Print identity scores matrix for all sequences in the input alignment. (see User Guide)."
1916  << endl;
1917  cout << " -soverlap " << "Print overlap scores matrix for all sequences in the input alignment. (see User Guide)."
1918  << endl << endl;
1919 }
1920 
1921 void examples(void) {
1922 
1923  cout << "Some Examples:" << endl << endl;
1924 
1925  cout << "1) Removes all positions in the alignment with gaps in 10% or more of" << endl
1926  << " the sequences, unless this leaves less than 60% of original alignment. " << endl
1927  << " In such case, print the 60% best (with less gaps) positions." << endl << endl;
1928 
1929  cout << " trimal -in <inputfile> -out <outputfile> -gt 0.9 -cons 60" << endl << endl;
1930 
1931  cout << "2) As above but, the gap score is averaged over a window starting" << endl
1932  << " 3 positions before and ending 3 positions after each column." << endl << endl;
1933 
1934  cout << " trimal -in <inputfile> -out <outputfile> -gt 0.9 -cons 60 -w 3" << endl << endl;
1935 
1936  cout << "3) Use an automatic method to decide optimal thresholds, based in the gap scores" << endl
1937  << " from input alignment. (see User Guide for details)." << endl << endl;
1938 
1939  cout << " trimal -in <inputfile> -out <outputfile> -gappyout" << endl << endl;
1940 
1941  cout << "4) Use automatic methods to decide optimal thresholds, based on the combination " << endl
1942  << " of gap and similarity scores. (see User Guide for details)." << endl << endl;
1943 
1944  cout << " trimal -in <inputfile> -out <outputfile> -strictplus" << endl << endl;
1945 
1946  cout << "5) Use an heuristic to decide the optimal method for trimming the alignment. " << endl
1947  << " (see User Guide for details)." << endl << endl;
1948 
1949  cout << " trimal -in <inputfile> -out <outputfile> -automated1" << endl << endl;
1950 
1951  cout << "6) Use residues and sequences overlap thresholds to delete some sequences from the " << endl
1952  << " alignemnt. (see User Guide for details)." << endl << endl;
1953 
1954  cout << " trimal -in <inputfile> -out <outputfile> -resoverlap 0.8 -seqoverlap 75" << endl << endl;
1955 
1956  cout << "7) Selection of columns to be deleted from the alignment. The selection can " << endl
1957  << " be a column number or a column number interval. Start from 0" << endl << endl;
1958 
1959  cout << " trimal -in <inputfile> -out <outputfile> -selectcols { 0,2,3,10,45-60,68,70-78 }" << endl << endl;
1960 
1961  cout << "8) Get the complementary alignment from the alignment previously trimmed." << endl << endl;
1962 
1963  cout << " trimal -in <inputfile> -out <outputfile> -selectcols { 0,2,3,10,45-60,68,70-78 } -complementary" << endl << endl;
1964 
1965  cout << "9) Selection of sequences to be deleted from the alignment. Start in 0" << endl << endl;
1966 
1967  cout << " trimal -in <inputfile> -out <outputfile> -selectseqs { 2,4,8-12 } " << endl << endl;
1968 
1969  cout << "10) Select the 5 most representative sequences from the alignment" << endl << endl;
1970 
1971  cout << " trimal -in <inputfile> -out <outputfile> -clusters 5 " << endl << endl;
1972 }
#define GAPPYOUT
Definition: defines.h:38
#define AUTHORS
Definition: defines.h:36
#define REVISION
Definition: defines.h:35
int main(int argc, char *argv[])
Definition: trimAlMain.cpp:34
void examples(void)
Definition: main.cpp:1921
Utilities class. This class contains shared methods to be used in multiple parts of the code...
Definition: utils.h:50
#define VERSION
Definition: defines.h:34
void menu(void)
Definition: main.cpp:1798
bool isNumber(char *num)
String-is-number checking.
Definition: utils.cpp:116
#define BUILD
Definition: defines.h:33