trimalManager.cpp
Go to the documentation of this file.
1 /* *****************************************************************************
2 
3  trimAl v2.0: a tool for automated alignment trimming in large-scale
4  phylogenetics analyses.
5 
6  readAl v2.0: a tool for automated alignment conversion among different
7  formats.
8 
9  2009-2019
10  Fernandez-Rodriguez V. (victor.fernandez@bsc.es)
11  Capella-Gutierrez S. (salvador.capella@bsc.es)
12  Gabaldon, T. (tgabaldon@crg.es)
13 
14  This file is part of trimAl/readAl.
15 
16  trimAl/readAl are free software: you can redistribute it and/or modify
17  it under the terms of the GNU General Public License as published by
18  the Free Software Foundation, the last available version.
19 
20  trimAl/readAl are distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with trimAl/readAl. If not, see <http://www.gnu.org/licenses/>.
27 
28 ***************************************************************************** */
29 
30 
31 #include <trimalManager.h>
32 
33 #include "FormatHandling/BaseFormatHandler.h"
34 #include "Statistics/similarityMatrix.h"
35 #include "Statistics/Consistency.h"
36 #include "Statistics/Similarity.h"
38 #include "Alignment/Alignment.h"
39 #include "Statistics/Manager.h"
40 #include "trimalManager.h"
41 #include "reportsystem.h"
42 #include "VCFHandler.h"
43 #include "Cleaner.h"
44 #include "defines.h"
45 #include "values.h"
46 #include "utils.h"
47 
48 // Macros defined on this file will be defined
49 // before the method that uses them.
50 // This is due to macros that are only used on
51 // one method.
52 
54  // Create a timer that will report times upon its destruction
55  // which means the end of the current scope.
56  StartTiming("trimAlManager::trimAlManager() ");
57 }
58 
60  // Create a timer that will report times upon its destruction
61  // which means the end of the current scope.
62  StartTiming("trimAlManager::~trimAlManager() ");
63 
65 }
66 
67 #define checkArgument(argument) {
68  auto x = argument(&argc, argv, &i);
69  if (x == Recognized) continue;
70  if (x == Errored) return x;
71  if (x == Final) return x;\
72 }
73 
74 int trimAlManager::parseArguments(int argc, char **argv) {
75  // Create a timer that will report times upon its destruction
76  // which means the end of the current scope.
77  StartTiming("void trimAlManager::parseArguments(int argc, char *argv[]) ");
78 
79  // Call to verbosity argument has to be done
80  // before any other argument.
81  verbosity_argument(&argc, argv);
82 
83  // Check if there is only an argument passed to trimAl,
84  // if so, show the menu and the examples
85  if (argc == 1) {
86  menu();
87  examples();
88  return Final;
89  }
90 
91  // Check every provided argument
92  // with each argument method
93  for (int i = 1; i < argc; i++) {
94  if (appearErrors) break;
95 
97 
98  // Check arguments. Makes use of the
99  // macro checkArgument (defined before the method)
100  // to make code more understandable.
101  //
102  // Argument passed to checkArgument is,
103  // indeed, a method with signature:
104  // x_argument(&argc, argv, &i)
105 
106  // In-Out
107  {
108  // Alignment in-out
112 
113  // Trimming Reports
116 
117  // Compare set
120 
121  // Back translation
123 
124  // Stats report
127 
128  // Time Tracker out
130 
131  // Custom Matrix argument
133 
134  // Column Numbering
136  }
137 
138  // Stats
139  {
140  // Thresholds
145 
146  // Windows
151  }
152 
153  // Trimming methods
154  {
155  // Gaps based
158  // Automated
163  // Overlap
166  // Manual
169  // Duplicates
171  // Identity
174  }
175 
176  // Modifiers
177  {
180 
181  // Back translation Modifiers
184 
186 
188 
190  }
191 
192  // VCF
193  {
198  }
199 
200  // Skip the verbosity option, as it was checked before the loop
201  if (!strcmp(argv[i], "--verbosity") || !strcmp(argv[i], "-v")) {
202  i++;
203  continue;
204  }
205 
207  appearErrors = true;
208  break;
209  }
210 
212  appearErrors = true;
213 
214  // Check if we've provided multiple correct arguments
215  // but no input file is provided.
216  if (infile == nullptr && compareset == nullptr) {
217  this->appearErrors = true;
219  return Errored;
220  }
221  return this->appearErrors ? Errored : Recognized;
222 }
223 
224 #undef checkArgument
225 
227  StartTiming("bool trimAlManager::check_arguments_incompatibilities()");
228  // The incompatibilities are checked only once,
229  // so there are arguments with no function to check it's incompatibilities although they have.
230  // These are checked within other functions.
231  // So if argument A is incompatible with B,
232  // A may have this checked in it's incompatibilities function,
233  // but B may have no function to check them.
234 
245 
247 
248  return appearErrors;
249 }
250 
251 /**inline**/ void trimAlManager::verbosity_argument(const int *argc, char *argv[]) {
252  for (int i = 1; i < *argc; i++) {
253  if (!strcmp(argv[i], "--verbosity") || !strcmp(argv[i], "-v")) {
254  if ((i + 1) != *argc) {
255  if (!strcmp(argv[i + 1], "error") || !strcmp(argv[i + 1], "3")) {
257  return;
258  }
259  if (!strcmp(argv[i + 1], "warning") || !strcmp(argv[i + 1], "2")) {
261  return;
262  }
263  if (!strcmp(argv[i + 1], "info") || !strcmp(argv[i + 1], "1")) {
265  return;
266  }
267  if (!strcmp(argv[i + 1], "none") || !strcmp(argv[i + 1], "0")) {
269  return;
270  }
271 
272  debug.report(ErrorCode::VerboseLevelNotRecognized, new std::string[2]{argv[i + 1], std::to_string(debug.Level)});
273  } else
274  debug.report(ErrorCode::NeedToSpecifyVerboseLevel, new std::string[2]{argv[i], std::to_string(debug.Level)});
275  }
276  }
277 }
278 
279 /**inline**/ trimAlManager::argumentReport trimAlManager::help_arguments(const int *argc, char **argv, int *currentArg) {
280  if (!strcmp(argv[*currentArg], "-h") || !strcmp(argv[*currentArg], "-help")) {
281  menu();
282  examples();
283  return Final; // We don't want to continue if we show the help.
284  }
285 
286  if (!strcmp(argv[*currentArg], "--version")) {
287  std::cout << VERSION << std::endl;
288  return Final; // We don't want to continue if we show the version.
289  }
290 
291  if (!strcmp(argv[*currentArg], "-lf") || !strcmp(argv[*currentArg], "--listformats")) {
292  std::cout << "Input Formats: \t" << formatManager.getInputFormatsAvailable() << "\n\n";
293  std::cout << "Output Formats: \t" << formatManager.getOutputFormatsAvailable() << "\n";
294  return Final;
295  }
296 
297  return NotRecognized;
298 }
299 
300 /**inline**/ trimAlManager::argumentReport trimAlManager::in_argument(const int *argc, char *argv[], int *i) {
301  if (!strcmp(argv[*i], "-in") && ((*i) + 1 != *argc) && infile == nullptr)
302  {
303  // Need to check this here, as later origAlig is set and checked
304  // the same happens on force_select_argument, and thus,
305  // one alignment would be leaked.
306  if (forceFile != nullptr)
307  {
309  return Errored;
310  }
311  argumentLength = strlen(argv[++*i]);
312  infile = new char[argumentLength + 1];
313  strcpy(infile, argv[*i]);
314  if ((origAlig = formatManager.loadAlignment(infile)) == nullptr) {
315  appearErrors = true;
316  }
317  return Recognized;
318  }
319  return NotRecognized;
320 }
321 
322 /**inline**/ trimAlManager::argumentReport trimAlManager::vcf_argument(const int *argc, char *argv[], int *i) {
323  if (!strcmp(argv[*i], "-vcf") && ((*i) + 1 != *argc)) {
324  vcfs = new std::vector<std::string>();
325  while (((*i) + 1 != *argc)) {
326  ++*i;
327  if (argv[*i][0] == '-') {
328  --*i;
329  break;
330  }
331  vcfs->emplace_back(argv[*i]);
332  }
333  return Recognized;
334 
335  }
336  return NotRecognized;
337 }
338 
339 /**inline**/ trimAlManager::argumentReport trimAlManager::out_argument(const int *argc, char *argv[], int *i) {
340  if ((!strcmp(argv[*i], "-out")) && ((*i) + 1 != *argc) && (outfile == nullptr)) {
341  argumentLength = strlen(argv[++*i]);
342  outfile = new char[argumentLength + 1];
343  strcpy(outfile, argv[*i]);
344  return Recognized;
345  }
346  return NotRecognized;
347 }
348 
349 /**inline**/ trimAlManager::argumentReport trimAlManager::html_out_argument(const int *argc, char *argv[], int *i) {
350  if ((!strcmp(argv[*i], "-htmlout")) && ((*i) + 1 != *argc) && (htmlOutFile == nullptr)) {
351  argumentLength = strlen(argv[++*i]);
352  htmlOutFile = new char[argumentLength + 1];
353  strcpy(htmlOutFile, argv[*i]);
354  return Recognized;
355  }
356  return NotRecognized;
357 }
358 
359 /**inline**/ trimAlManager::argumentReport trimAlManager::timetracker_out_argument(const int *argc, char *argv[], int *i) {
360  if ((!strcmp(argv[*i], "-timetrackerout")) && ((*i) + 1 != *argc)) {
361  (*i) += 1;
362  return Recognized;
363  }
364  return NotRecognized;
365 }
366 
367 /**inline**/ trimAlManager::argumentReport trimAlManager::svg_out_argument(const int *argc, char *argv[], int *i) {
368  if ((!strcmp(argv[*i], "-svgout")) && ((*i) + 1 != *argc) && (svgOutFile == nullptr)) {
369  argumentLength = strlen(argv[++*i]);
370  svgOutFile = new char[argumentLength + 1];
371  strcpy(svgOutFile, argv[*i]);
372  return Recognized;
373  }
374  return NotRecognized;
375 }
376 
377 /**inline**/ trimAlManager::argumentReport trimAlManager::svg_stats_argument(const int *argc, char *argv[], int *i) {
378  if ((!strcmp(argv[*i], "-svgstats")) && ((*i) + 1 != *argc) && (svgStatsOutFile == nullptr)) {
379  argumentLength = strlen(argv[++*i]);
380  svgStatsOutFile = new char[argumentLength + 1];
381  strcpy(svgStatsOutFile, argv[*i]);
382  return Recognized;
383  }
384  return NotRecognized;
385 }
386 
387 // Macro to allow using legacy format arguments
388 // with the new system.
389 #define LegacyFormatArgumentWrapper(arg, format)
390  if (!strcmp(argv[*i], arg)) {
391  oformats.emplace_back(format);
392  return Recognized;
393  }
394 
395 /**inline**/ trimAlManager::argumentReport trimAlManager::out_format_arguments(const int *argc, char *argv[], int *i) {
396  // Detect formats using the ReadWriteMachineState (RWMS) method
397  // Store the formats desired on 'oformats' list, which
398  // will be passed to the RWMS
399  if (!strcmp(argv[*i], "-formats")) {
400  if ((*i + 1) == *argc) {
402  appearErrors = true;
403  return Errored;
404  }
405  while (++(*i) != *argc && argv[*i][0] != '-')
406  {
407  if (formatManager.getFormatFromToken(argv[*i]) == nullptr)
408  {
410  appearErrors = true;
411  return Errored;
412  } else oformats.emplace_back(argv[*i]);
413  }
414  (*i)--;
415  return Recognized;
416  }
417 
418  // Legacy formats handling code.
419  // Makes use of the macro LegacyFormatArgumentWrapper
420  // for the sake of understandability.
421  // This transforms the old arguments to the RWMS format,
422  // emplacing the IDS for each format on oformats list.
423  LegacyFormatArgumentWrapper("-clustal", "clustal")
424  LegacyFormatArgumentWrapper("-fasta", "fasta")
425  LegacyFormatArgumentWrapper("-fasta_m10", "fasta_m10")
426  LegacyFormatArgumentWrapper("-nbrf", "pir")
427  LegacyFormatArgumentWrapper("-nexus", "nexus")
428  LegacyFormatArgumentWrapper("-mega", "mega")
429  LegacyFormatArgumentWrapper("-phylip3.2", "phylip32")
430  LegacyFormatArgumentWrapper("-phylip3.2_m10", "phylip32_m10")
431  LegacyFormatArgumentWrapper("-phylip", "phylip40")
432  LegacyFormatArgumentWrapper("-phylip_m10", "phylip40_m10")
433  LegacyFormatArgumentWrapper("-phylip_paml", "phylip_paml")
434  LegacyFormatArgumentWrapper("-phylip_paml_m10", "phylip_paml_m10")
435 
436  return NotRecognized;
437 }
438 
439 #undef LegacyFormatArgumentWrapper
440 
441 /**inline**/ trimAlManager::argumentReport trimAlManager::matrix_argument(const int *argc, char *argv[], int *i) {
442  if (!strcmp(argv[*i], "-matrix") && ((*i) + 1 != *argc) && (matrixFile == nullptr)) {
443  argumentLength = strlen(argv[++*i]);
444  matrixFile = new char[argumentLength + 1];
445  strcpy(matrixFile, argv[*i]);
446  return Recognized;
447  } else if (!strcmp(argv[*i], "--alternative_matrix") && ((*i) + 1 != *argc) && (alternative_matrix == -1)) {
448  (*i)++;
449  if (!strcmp(argv[*i], "degenerated_nt_identity"))
450  {
451  alternative_matrix = 1;
452  return Recognized;
453  }
454  else {
456  appearErrors = true;
457  }
458  }
459  return NotRecognized;
460 }
461 
462 /**inline**/ trimAlManager::argumentReport trimAlManager::compareset_argument(const int *argc, char *argv[], int *i) {
463  if (!strcmp(argv[*i], "-compareset") && ((*i) + 1 != *argc) && (compareset == nullptr)) {
464  // Check if file can be opened
465  compare.open(argv[++*i], std::ifstream::in);
466  if (!compare) {
468  appearErrors = true;
469  }
470  compare.close();
471  compareset = argv[*i];
472  return Recognized;
473  }
474  return NotRecognized;
475 }
476 
477 /**inline**/ trimAlManager::argumentReport trimAlManager::force_select_argument(const int *argc, char *argv[], int *i) {
478  if (!strcmp(argv[*i], "-forceselect") && ((*i) + 1 != *argc) && forceFile == nullptr)
479  {
480  // Need to check this here, as later origAlig is set and checked
481  // the same happens on in_argument, and thus,
482  // one alignment would be leaked.
483  if (infile != nullptr)
484  {
486  return Errored;
487  }
488  argumentLength = strlen(argv[++*i]);
489  forceFile = new char[argumentLength + 1];
490  strcpy(forceFile, argv[*i]);
491 
494  appearErrors = true;
495  }
496  return Recognized;
497  }
498  return NotRecognized;
499 }
500 
501 /**inline**/ trimAlManager::argumentReport trimAlManager::back_trans_argument(const int *argc, char *argv[], int *i) {
502  if (!strcmp(argv[*i], "-backtrans") && ((*i) + 1 != *argc) && (backtransFile == nullptr)) {
503  argumentLength = strlen(argv[++*i]);
504  backtransFile = new char[argumentLength + 1];
505  strcpy(backtransFile, argv[*i]);
506 
509  appearErrors = true;
510  }
511  return Recognized;
512  }
513  return NotRecognized;
514 }
515 
516 /**inline**/ trimAlManager::argumentReport trimAlManager::gap_threshold_argument(const int *argc, char *argv[], int *i) {
517 
518  if ((!strcmp(argv[*i], "-gapthreshold") || !strcmp(argv[*i], "-gt"))
519  && ((*i) + 1 != *argc) && (gapThreshold == -1)) {
520 
521  if (gapAbsoluteThreshold != -1) {
523  appearErrors = true;
524  }
525 
526  if (utils::isNumber(argv[++*i])) {
527  gapThreshold = 1.0F - (float)atof(argv[*i]);
528  if ((gapThreshold < 0) || (gapThreshold > 1)) {
530  appearErrors = true;
531  }
532  } else {
534  appearErrors = true;
535  }
536  return Recognized;
537  }
538 
539  if ((!strcmp(argv[*i], "-gapabsolutethreshold") || !strcmp(argv[*i], "-gat"))
540  && ((*i) + 1 != *argc) && (gapAbsoluteThreshold == -1)) {
541 
542  if (gapThreshold != -1) {
544  appearErrors = true;
545  }
546 
547  if (utils::isNumber(argv[++*i])) {
548  gapAbsoluteThreshold = atoi(argv[*i]);
549  if (gapAbsoluteThreshold < 0) {
551  appearErrors = true;
552  }
553  } else {
555  appearErrors = true;
556  }
557  return Recognized;
558  }
559  return NotRecognized;
560 
561 }
562 
563 /**inline**/ trimAlManager::argumentReport trimAlManager::similarity_threshold_argument(const int *argc, char *argv[], int *i) {
564  if ((!strcmp(argv[*i], "-simthreshold") || !strcmp(argv[*i], "-st")) && ((*i) + 1 != *argc) && (similarityThreshold == -1)) {
565  if (utils::isNumber(argv[++*i])) {
566  similarityThreshold = atof(argv[*i]);
567  if ((similarityThreshold < 0) || (similarityThreshold > 1)) {
569  appearErrors = true;
570  }
571  } else {
573  appearErrors = true;
574  }
575  return Recognized;
576  }
577  return NotRecognized;
578 }
579 
580 /**inline**/ trimAlManager::argumentReport trimAlManager::consistency_threshold_argument(const int *argc, char *argv[], int *i) {
581  if ((!strcmp(argv[*i], "-conthreshold") || !strcmp(argv[*i], "-ct")) && ((*i) + 1 != *argc) && (consistencyThreshold == -1)) {
582  if (utils::isNumber(argv[++*i])) {
583  consistencyThreshold = atof(argv[*i]);
584  if ((consistencyThreshold < 0) || (consistencyThreshold > 1)) {
586  appearErrors = true;
587  }
588  } else {
590  appearErrors = true;
591  }
592  return Recognized;
593  }
594  return NotRecognized;
595 }
596 
597 /**inline**/ trimAlManager::argumentReport trimAlManager::conservation_threshold_argument(const int *argc, char *argv[], int *i) {
598  if ((!strcmp(argv[*i], "-cons")) && ((*i) + 1 != *argc) && (conservationThreshold == -1)) {
599  if (utils::isNumber(argv[++*i])) {
600  conservationThreshold = atof(argv[*i]);
601  if ((conservationThreshold < 0) || (conservationThreshold > 100)) {
603  appearErrors = true;
604  }
605  } else {
607  appearErrors = true;
608  }
609 
610  return Recognized;
611  }
612  return NotRecognized;
613 }
614 
615 /**inline**/ trimAlManager::argumentReport trimAlManager::select_cols_argument(const int *argc, char *argv[], int *i) {
616  StartTiming("trimAlManager::select_cols_argument");
617  if ((!strcmp(argv[*i], "-selectcols")) &&
618  !selectCols &&
619  (*i + 3) < *argc &&
620  !strcmp(argv[++(*i)], "{") &&
621  !strcmp(argv[(*i) + 2], "}")) {
622  if ((delColumns = utils::readNumbers(argv[++(*i)])) == nullptr) {
624  appearErrors = true;
625  } else selectCols = true;
626  (*i)++;
627 
628  return Recognized;
629  }
630  return NotRecognized;
631 }
632 
633 /**inline**/ trimAlManager::argumentReport trimAlManager::no_gaps_argument(const int *argc, char *argv[], int *i) {
634  if (!strcmp(argv[*i], "-nogaps") && (!nogaps)) {
635  nogaps = true;
636  return Recognized;
637  }
638  return NotRecognized;
639 }
640 
641 /**inline**/ trimAlManager::argumentReport trimAlManager::remove_duplicates_argument(const int *argc, char *argv[], int *i) {
642  if (!strcmp(argv[*i], "-noduplicateseqs") && (!removeDuplicates)) {
643  removeDuplicates = true;
644  return Recognized;
645  }
646  return NotRecognized;
647 }
648 
649 /**inline**/ trimAlManager::argumentReport trimAlManager::no_all_gaps_argument(const int *argc, char *argv[], int *i) {
650  if (!strcmp(argv[*i], "-noallgaps") && (!noallgaps)) {
651  noallgaps = true;
652  return Recognized;
653  }
654  return NotRecognized;
655 }
656 
657 /**inline**/ trimAlManager::argumentReport trimAlManager::keep_seqs_argument(const int *argc, char *argv[], int *i) {
658  if (!strcmp(argv[*i], "-keepseqs") && (!keepSeqs)) {
659  keepSeqs = true;
660  return Recognized;
661  }
662  return NotRecognized;
663 }
664 
665 /**inline**/ trimAlManager::argumentReport trimAlManager::keep_header_argument(const int *argc, char *argv[], int *i) {
666  if (!strcmp(argv[*i], "-keepheader") && (!formatManager.keepHeader)) {
668  return Recognized;
669  }
670  return NotRecognized;
671 }
672 
673 /**inline**/ trimAlManager::argumentReport trimAlManager::gappy_out_argument(const int *argc, char *argv[], int *i) {
674  if (!strcmp(argv[*i], "-gappyout") && (!gappyout)) {
675  gappyout = true;
676  return Recognized;
677  }
678  return NotRecognized;
679 }
680 
681 /**inline**/ trimAlManager::argumentReport trimAlManager::strict_argument(const int *argc, char *argv[], int *i) {
682  if (!strcmp(argv[*i], "-strict") && (!strict)) {
683  strict = true;
684  return Recognized;
685  }
686  return NotRecognized;
687 }
688 
689 /**inline**/ trimAlManager::argumentReport trimAlManager::strict_plus_argument(const int *argc, char *argv[], int *i) {
690  if ((!strcmp(argv[*i], "-strictplus")) && (!strictplus)) {
691  strictplus = true;
692  return Recognized;
693  }
694  return NotRecognized;
695 }
696 
697 /**inline**/ trimAlManager::argumentReport trimAlManager::automated1_argument(const int *argc, char *argv[], int *i) {
698  if ((!strcmp(argv[*i], "-automated1")) && (!automated1)) {
699  automated1 = true;
700  return Recognized;
701  }
702  return NotRecognized;
703 }
704 
705 /**inline**/ trimAlManager::argumentReport trimAlManager::residue_overlap_argument(const int *argc, char *argv[], int *i) {
706  if ((!strcmp(argv[*i], "-resoverlap")) && ((*i) + 1 != *argc) && (residuesOverlap == -1)) {
707  if (utils::isNumber(argv[++*i])) {
708  residuesOverlap = atof(argv[*i]);
709  if ((residuesOverlap < 0) || (residuesOverlap > 1)) {
711  appearErrors = true;
712  }
713  } else {
715  appearErrors = true;
716  }
717  return Recognized;
718  }
719  return NotRecognized;
720 }
721 
722 /**inline**/ trimAlManager::argumentReport trimAlManager::sequence_overlap_argument(const int *argc, char *argv[], int *i) {
723  if ((!strcmp(argv[*i], "-seqoverlap")) && ((*i) + 1 != *argc) && (sequenceOverlap == -1)) {
724  if (utils::isNumber(argv[++*i])) {
725  sequenceOverlap = atof(argv[*i]);
726  if ((sequenceOverlap < 0) || (sequenceOverlap > 100)) {
728  appearErrors = true;
729  }
730  } else {
732  appearErrors = true;
733  }
734  return Recognized;
735  }
736  return NotRecognized;
737 }
738 
739 /**inline**/ trimAlManager::argumentReport trimAlManager::seqs_select_argument(const int *argc, char *argv[], int *i) {
740  StartTiming("trimAlManager::select_seqs_argument");
741  if ((!strcmp(argv[*i], "-selectseqs")) &&
742  !selectSeqs &&
743  ((*i + 3) < *argc) &&
744  (!strcmp(argv[++*i], "{")) &&
745  (!strcmp(argv[*i + 2], "}"))) {
746  if ((delSequences = utils::readNumbers(argv[++*i])) == nullptr) {
748  appearErrors = true;
749  } else selectSeqs = true;
750  (*i)++;
751  return Recognized;
752  }
753  return NotRecognized;
754 }
755 
756 /**inline**/ trimAlManager::argumentReport trimAlManager::max_identity_argument(const int *argc, char *argv[], int *i) {
757  if ((!strcmp(argv[*i], "-maxidentity")) && ((*i) + 1 != *argc) && (maxIdentity == -1)) {
758 
759  if (utils::isNumber(argv[++*i])) {
760  maxIdentity = atof(argv[*i]);
761  if ((maxIdentity < 0) || (maxIdentity > 1)) {
763  appearErrors = true;
764  }
765  } else {
767  appearErrors = true;
768  }
769 
770  return Recognized;
771  }
772  return NotRecognized;
773 }
774 
775 /**inline**/ trimAlManager::argumentReport trimAlManager::clusters_argument(const int *argc, char *argv[], int *i) {
776  if ((!strcmp(argv[*i], "-clusters")) && ((*i) + 1 != *argc) && (clusters == -1)) {
777  if (utils::isNumber(argv[++*i])) {
778  clusters = atoi(argv[*i]);
779  if (clusters < 1) {
781  appearErrors = true;
782  }
783  } else {
785  appearErrors = true;
786  }
787 
788  return Recognized;
789  }
790  return NotRecognized;
791 }
792 
793 /**inline**/ trimAlManager::argumentReport trimAlManager::terminal_only_argument(const int *argc, char *argv[], int *i) {
794  if ((!strcmp(argv[*i], "-terminalonly")) && (!terminalOnly)) {
795  terminalOnly = true;
796  return Recognized;
797  }
798  return NotRecognized;
799 }
800 
801 /**inline**/ trimAlManager::argumentReport trimAlManager::window_argument(const int *argc, char *argv[], int *i) {
802  if (!strcmp(argv[*i], "-w") && ((*i) + 1 != *argc) && (windowSize == -1)) {
803  if (utils::isNumber(argv[*i + 1])) {
804  windowSize = atoi(argv[++*i]);
805  if (windowSize <= 0) {
807  appearErrors = true;
808  }
809  } else {
811  appearErrors = true;
812  }
813  return Recognized;
814  }
815  return NotRecognized;
816 }
817 
818 /**inline**/ trimAlManager::argumentReport trimAlManager::gap_window_argument(const int *argc, char *argv[], int *i) {
819  if (!strcmp(argv[*i], "-gw") && ((*i) + 1 != *argc) && (gapWindow == -1)) {
820  if (utils::isNumber(argv[*i + 1])) {
821  gapWindow = atoi(argv[++*i]);
822  if (gapWindow <= 0) {
824  appearErrors = true;
825  }
826  } else {
828  appearErrors = true;
829  }
830  return Recognized;
831  }
832  return NotRecognized;
833 }
834 
835 /**inline**/ trimAlManager::argumentReport trimAlManager::similarity_window_argument(const int *argc, char *argv[], int *i) {
836  if (!strcmp(argv[*i], "-sw") && ((*i) + 1 != *argc) && (similarityWindow == -1)) {
837  if (utils::isNumber(argv[*i + 1])) {
838  similarityWindow = atoi(argv[++*i]);
839  if (similarityWindow <= 0) {
841  appearErrors = true;
842  }
843  } else {
845  appearErrors = true;
846  }
847 
848  return Recognized;
849  }
850  return NotRecognized;
851 }
852 
853 /**inline**/ trimAlManager::argumentReport trimAlManager::consistency_window_argument(const int *argc, char *argv[], int *i) {
854  if (!strcmp(argv[*i], "-cw") && ((*i) + 1 != *argc) && (consistencyWindow == -1)) {
855  if (utils::isNumber(argv[*i + 1])) {
856  consistencyWindow = atoi(argv[++*i]);
857  if (consistencyWindow <= 0) {
859  appearErrors = true;
860  }
861  } else {
863  appearErrors = true;
864  }
865  return Recognized;
866  }
867  return NotRecognized;
868 }
869 
870 /**inline**/ trimAlManager::argumentReport trimAlManager::block_argument(const int *argc, char *argv[], int *i) {
871  if (!strcmp(argv[*i], "-block") && ((*i) + 1 != *argc) && (blockSize == -1)) {
872  if (utils::isNumber(argv[*i + 1])) {
873  blockSize = atoi(argv[++*i]);
874  if (blockSize <= 0) {
876  appearErrors = true;
877  }
878  } else {
880  appearErrors = true;
881  }
882  return Recognized;
883  }
884  return NotRecognized;
885 }
886 
887 // Macros to make the code on stats_arguments easier to understand.
888 // The macro needs the stat variable name to be the same as the argument used.
889 
890 // This macro also tightens the relation between a stats argument and
891 // the variable name where that information is stored.
892 
893 // This is an intentional coupling that would help when the number of variables
894 // arises, as their names may be not fully informative.
895 
896 #define stat_check(stat)
897  if (!strcmp(argv[*i], "-" #stat )) {
898  if (!stat) {
899  stat = true;
900  stats--;
901  return Recognized;
902  } else return NotRecognized;
903  }
904 
905 /**inline**/ trimAlManager::argumentReport trimAlManager::stats_arguments(const int *argc, char *argv[], int *i) {
906  stat_check(sgc)
907  stat_check(sgt)
908  stat_check(ssc)
909  stat_check(sst)
910 
913 
914  stat_check(sfc)
915  stat_check(sft)
916 
917  // As macro stat_check is able to make the method to return values
918  // under certain circumstances, althought the method (stats_arguments)
919  // seem to always return false, this is incorrect and the method can
920  // return True or False, depeding if a stat argument has been recognized.
921  return NotRecognized;
922 }
923 
924 #undef stat_check
925 
926 /**inline**/ trimAlManager::argumentReport trimAlManager::complementary_argument(const int *argc, char *argv[], int *i) {
927  if ((!strcmp(argv[*i], "-complementary")) && !getComplementary) {
928  getComplementary = true;
929  return Recognized;
930  }
931  if ((!strcmp(argv[*i], "-complementaryseq")) && !getComplementarySeq) {
932  getComplementarySeq = true;
933  return Recognized;
934  }
935  return NotRecognized;
936 }
937 
938 /**inline**/ trimAlManager::argumentReport trimAlManager::col_numbering_argument(const int *argc, char *argv[], int *i) {
939  if ((!strcmp(argv[*i], "-colnumbering")) && !columnNumbering) {
940  columnNumbering = true;
941  return Recognized;
942  }
943  return NotRecognized;
944 }
945 
946 /**inline**/ trimAlManager::argumentReport trimAlManager::split_by_stop_codon_argument(const int *argc, char *argv[], int *i) {
947  if ((!strcmp(argv[*i], "-splitbystopcodon")) && !splitByStopCodon) {
948  splitByStopCodon = true;
949  return Recognized;
950  }
951  return NotRecognized;
952 }
953 
954 /**inline**/ trimAlManager::argumentReport trimAlManager::ignore_stop_codon_argument(const int *argc, char *argv[], int *i) {
955  if ((!strcmp(argv[*i], "-ignorestopcodon")) && !ignoreStopCodon) {
956  ignoreStopCodon = true;
957  return Recognized;
958  }
959  return NotRecognized;
960 }
961 
962 /**inline**/ trimAlManager::argumentReport trimAlManager::ignore_filter_argument(const int *argc, char *argv[], int *i) {
963  if ((!strcmp(argv[*i], "-ignorefilter")) && !ignoreFilter) {
964  ignoreFilter = true;
965  return Recognized;
966  }
967  return NotRecognized;
968 }
969 
970 /**inline**/ trimAlManager::argumentReport trimAlManager::min_quality_argument(const int *argc, char *argv[], int *i) {
971  if (!strcmp(argv[*i], "-minquality") && ((*i) + 1 != *argc) && (minQuality == -1)) {
972  if (utils::isNumber(argv[*i + 1])) {
973  minQuality = atof(argv[++*i]);
974  if (minQuality < 0) {
976  appearErrors = true;
977  }
978  } else {
980  appearErrors = true;
981  }
982  return Recognized;
983  }
984  return NotRecognized;
985 }
986 
987 /**inline**/ trimAlManager::argumentReport trimAlManager::min_coverage_argument(const int *argc, char *argv[], int *i) {
988  if (!strcmp(argv[*i], "-mincoverage") && ((*i) + 1 != *argc) && (minCoverage == -1)) {
989  if (utils::isNumber(argv[*i + 1])) {
990  minCoverage = atof(argv[++*i]);
991  if (minCoverage < 0) {
993  appearErrors = true;
994  }
995  } else {
997  appearErrors = true;
998  }
999  return Recognized;
1000  }
1001  return NotRecognized;
1002 }
1003 
1004 bool trimAlManager::processArguments(char *argv[]) {
1005  // Create a timer that will report times upon its destruction
1006  // which means the end of the current scope.
1007  StartTiming("bool trimAlManager::processArguments(char *argv[]) ");
1008  if (!appearErrors) {
1009 
1010  // This allows us to have a count of all the automatic methods
1011  // that have been requested.
1012  // We can use this information to prevent performing more than one method,
1013  // and using as a bool, to check if any automatic method has been used.
1015  nogaps + noallgaps +
1016  gappyout + strict +
1018 
1021  }
1022  return appearErrors;
1023 }
1024 
1026  if (infile != nullptr) {
1027  if ((sfc) || (sft) || (consistencyThreshold != -1)) {
1029  appearErrors = true;
1030  i++;
1031  }
1032  if (compareset != nullptr) {
1033  debug.report(ErrorCode::IncompatibleArguments, new std::string[2]{"-in", "-compareset"});
1034  appearErrors = true;
1035  }
1036  if (forceFile != nullptr) {
1037  debug.report(ErrorCode::IncompatibleArguments, new std::string[2]{"-in", "-forceselect"});
1038  appearErrors = true;
1039  }
1040  }
1041  return appearErrors;
1042 }
1043 
1045  if (selectCols || selectSeqs) {
1046  if ((clusters != -1) || (maxIdentity != -1)) {
1048  appearErrors = true;
1049  }
1050 
1051  if (selectCols)
1052  {
1053  if (blockSize != -1) {
1055  new std::string[2]{"-selectcols", "-block"});
1056  appearErrors = true;
1057  }
1058 
1059  for (int i = 1; i <= delColumns[0]; i++)
1060  {
1063  new std::string[2]{"-selectcols", "columns"});
1064  appearErrors = true;
1065  break;
1066  }
1067  }
1068  }
1069 
1070  if (selectSeqs)
1071 
1072  for (int i = 1; i <= delSequences[0]; i++)
1073  {
1076  new std::string[2]{"-selectseqs", "sequences"});
1077  appearErrors = true;
1078  break;
1079  }
1080  }
1081  }
1082  return appearErrors;
1083 }
1084 
1086  if ((gapThreshold != -1) ||
1087  (similarityThreshold != -1) ||
1088  (consistencyThreshold != -1) ||
1089  (conservationThreshold != -1)
1090  )
1091  {
1092 
1093 
1094  if (automatedMethodCount) {
1095 
1096  const char *autom;
1097  if (strict) autom = "-strict";
1098  if (strictplus) autom = "-strictplus";
1099  if (gappyout) autom = "-gappyout";
1100  if (nogaps) autom = "-nogaps";
1101  if (noallgaps) autom = "-noallgaps";
1102  if (automated1) autom = "-automated1";
1103 
1104 
1105  if (gapThreshold != -1)
1106  debug.report(ErrorCode::CombinationAmongTrimmingMethods, new std::string[2]{autom,"-gt"});
1107  if (similarityThreshold != -1)
1108  debug.report(ErrorCode::CombinationAmongTrimmingMethods, new std::string[2]{autom,"-st"});
1109  if (consistencyThreshold != -1)
1110  debug.report(ErrorCode::CombinationAmongTrimmingMethods, new std::string[2]{autom,"-ct"});
1111  if (conservationThreshold != -1)
1112  debug.report(ErrorCode::CombinationAmongTrimmingMethods, new std::string[2]{autom,"-cons"});
1113 
1114  appearErrors = true;
1115  }
1116 
1117  if (conservationThreshold != -1) {
1118  if (blockSize != -1) {
1120  new std::string[2]{"-conthreshold", "-block"});
1121  appearErrors = true;
1122  }
1123  }
1124  }
1125  return appearErrors;
1126 }
1127 
1129  if (automatedMethodCount) {
1130 
1131  const char *autom;
1132  if (strict) autom = "-strict";
1133  if (strictplus) autom = "-strictplus";
1134  if (gappyout) autom = "-gappyout";
1135  if (nogaps) autom = "-nogaps";
1136  if (noallgaps) autom = "-noallgaps";
1137  if (automated1) autom = "-automated1";
1138 
1139 
1140  if ((windowSize != -1)) {
1141  debug.report(ErrorCode::CombinationAmongTrimmingMethods, new std::string[2]{autom, "-w"});
1142  appearErrors = true;
1143  }
1144  if ((gapWindow != -1)) {
1145  debug.report(ErrorCode::CombinationAmongTrimmingMethods, new std::string[2]{autom,"-gw"});
1146  appearErrors = true;
1147  }
1148  if ((similarityWindow != -1)) {
1149  debug.report(ErrorCode::CombinationAmongTrimmingMethods, new std::string[2]{autom,"-sw"});
1150  appearErrors = true;
1151  }
1152 
1153  if (automatedMethodCount > 1) {
1155  appearErrors = true;
1156  }
1157  }
1158  return appearErrors;
1159 }
1160 
1162  if (maxIdentity != -1) {
1163  if ((windowSize != -1) || (gapWindow != -1) || (similarityWindow != -1) || (consistencyWindow != -1)) {
1164  debug.report(ErrorCode::WindowAndArgumentIncompatibilities, new std::string[1]{"-maxIdentity"});
1165  appearErrors = true;
1166  }
1167  if (clusters != -1) {
1169  appearErrors = true;
1170  }
1171  }
1172  return appearErrors;
1173 }
1174 
1176  if (clusters != -1) {
1179  appearErrors = true;
1180  }
1181  }
1182  return appearErrors;
1183 }
1184 
1186  if (windowSize != -1) {
1187  if (consistencyWindow != -1 || gapWindow != -1 || similarityWindow != -1) {
1189  appearErrors = true;
1190  }
1191  }
1192  return appearErrors;
1193 }
1194 
1196  if (stats < 0) {
1197  if (columnNumbering) {
1198  debug.report(ErrorCode::StatisticsArgumentIncompatibilities, new std::string[1]{"-colnumbering"});
1199  appearErrors = true;
1200  }
1201  }
1202  return appearErrors;
1203 }
1204 
1205 /**inline**/ bool trimAlManager::check_arguments_needs(char *argv[]) {
1206  StartTiming("bool trimAlManager::check_arguments_needs(char *argv[])");
1207 
1209 
1227 
1229  return appearErrors;
1230 }
1231 
1233  if ((!appearErrors) && (ignoreStopCodon) && (splitByStopCodon)) {
1234  debug.report(ErrorCode::IncompatibleArguments, new std::string[2]{"-ignorestopcodon", "-splitbystopcodon"});
1235  appearErrors = true;
1236  return true;
1237  }
1238  return false;
1239 }
1240 
1242 {
1243  if ((consistencyThreshold != -1)
1244  && (conservationThreshold != -1)
1245  && (!appearErrors))
1246  {
1247  if ((gapThreshold != -1) || (similarityThreshold != -1)) {
1249  appearErrors = true;
1250  return true;
1251  }
1252  }
1253  return false;
1254 }
1255 
1257 {
1258  bool returnValue = false;
1259  if (vcfs == nullptr)
1260  {
1261  if (minQuality != -1)
1262  {
1263  appearErrors = true;
1265  }
1266 
1267  if (minCoverage != -1)
1268  {
1269  appearErrors = true;
1271  }
1272 
1273  if (ignoreFilter)
1274  {
1275  appearErrors = true;
1277  }
1278  }
1279  return returnValue;
1280 }
1281 
1282 
1284  if ((getComplementary) && (!appearErrors))
1285  if (!automatedMethodCount && // Are we not using an automated method?
1286  (gapThreshold == -1) && (consistencyThreshold == -1) && (similarityThreshold == -1) && // Neither a threshold method.
1287  (!selectCols) && (!selectSeqs) && (residuesOverlap == -1) && (sequenceOverlap == -1) && // Neither a sequence and residues semimanual selection methods
1288  (maxIdentity == -1) && (clusters == -1)) // Or complex selection of sequences.
1289  {
1290  debug.report(ErrorCode::TrimmingMethodNeeded, new std::string[1]{"-complementary"});
1291  appearErrors = true;
1292  return true;
1293  }
1294 
1295  if ((terminalOnly) && (!appearErrors))
1296  if (!automatedMethodCount && // Are we not using an automated method?
1297  (gapThreshold == -1) && (conservationThreshold == -1) && (similarityThreshold == -1) && // Neither a threshold method.
1298  (!selectCols) && (!selectSeqs) && (residuesOverlap == -1) && (sequenceOverlap == -1) && // Neither a sequence and residues semimanual selection methods
1299  (maxIdentity == -1) && (clusters == -1)) // Or complex selection of sequences.
1300  {
1301  debug.report(ErrorCode::TrimmingMethodNeeded, new std::string[1]{"-terminalonly"});
1302  appearErrors = true;
1303  return true;
1304  }
1305  return false;
1306 }
1307 
1309  if (!appearErrors) {
1310  if (gapAbsoluteThreshold != -1)
1311  {
1313  if (gapThreshold >= 1.0F) {
1314  appearErrors = true;
1317  new std::string[2] {
1318  std::to_string(origAlig->originalNumberOfSequences),
1319  std::to_string(gapAbsoluteThreshold)
1320  });
1321  gapThreshold = -1;
1322  return true;
1323  }
1324  }
1325  }
1326  return false;
1327 }
1328 
1329 /**inline**/ bool trimAlManager::check_force_selection() {
1330  if (!appearErrors) {
1331  if ((compareset == nullptr) && (forceFile != nullptr)) {
1333  appearErrors = true;
1334  return true;
1335  }
1336  }
1337  return false;
1338 }
1339 
1341  if ((!appearErrors) && (infile == nullptr) && (compareset == nullptr) && (forceFile == nullptr) && (backtransFile != nullptr)) {
1343  appearErrors = true;
1344  return true;
1345  }
1346  return false;
1347 }
1348 
1349 /**inline**/ bool trimAlManager::check_file_aligned() {
1350  if ((!appearErrors) && (infile != nullptr)) {
1351 
1352  if (// Are we requesting an automated method ? or...
1354  // Are we requesting any manual threshold method ? or...
1355  (gapThreshold != -1) || (consistencyThreshold != -1) || (similarityThreshold != -1) ||
1356  // Are we selecting columns or sequences ? or...
1357  (selectCols) || (selectSeqs) ||
1358  // Are we using max overlap between sequences ? or...
1359  (residuesOverlap != -1) || (sequenceOverlap != -1) ||
1360  // Are we asking for any stats?
1361  (stats < 0))
1362  &&
1363  // Then we need the alignment to be aligned;
1364  // If not, we should report the error
1366  &&
1367  // We are not doing VCF)
1368  (vcfs == nullptr))
1369  {
1370  debug.report(ErrorCode::NotAligned, new std::string[1]{infile});
1371  appearErrors = true;
1372  return true;
1373  }
1374  }
1375  return false;
1376 }
1377 
1379  if ((matrixFile != nullptr || alternative_matrix != -1) && (!appearErrors)) {
1380  if ((!strict) && (!strictplus) && (!automated1) && (similarityThreshold == -1) && (!ssc) && (!sst)) {
1382  appearErrors = true;
1383  return true;
1384  }
1385 
1386  // TODO this is an incompatibility.
1387  if ((gapWindow != -1) || ((compareset == nullptr) && (consistencyWindow != -1))) {
1389  appearErrors = true;
1390  return true;
1391  }
1392  }
1393  return false;
1394 }
1395 
1397  // Check dynamically that every output path is unique
1398  // We use two arrays:
1399  // outFiles, which contains the variables
1400  // outFilesNames, which is used to identify each method
1401 
1402  std::array<char *, 4> outFiles
1403  {{
1404  htmlOutFile,
1405  outfile,
1406  svgOutFile,
1408  }};
1409 
1410  std::array<std::string, 4> outFilesNames
1411  {{
1412  "html report (-htmlout)",
1413  "output alignment (-out)",
1414  "svg report (-svgout)",
1415  "svg stats (-svgstats)"
1416  }};
1417 
1418 
1419  for (int i = 0, x = 0; i < outFiles.size(); i++) {
1420  if (outFiles.at(i) != nullptr)
1421  for (x = i + 1; x < outFiles.size(); x++) {
1422  if (outFiles.at(x) != nullptr)
1423  if (!strcmp(outFiles.at(i), outFiles.at(x))) {
1424  debug.report(ErrorCode::SameNameOutput, new std::string[2]{outFilesNames.at(i), outFilesNames.at(x)});
1425  appearErrors = true;
1426  }
1427  }
1428  }
1429 
1430  return false;
1431 }
1432 
1433 /**inline**/ bool trimAlManager::check_col_numbering() {
1434 
1435  // As colnumbering doesn't make sense if we don't trim the alignment...
1436  if ((columnNumbering) && (!appearErrors)) {
1437  if (
1438  // Are we not using any automated method? and...
1439  (!automatedMethodCount) &&
1440  // Are we not using any threshold? and...
1441  (gapThreshold == -1) &&
1442  (conservationThreshold == -1) &&
1443  (similarityThreshold == -1) &&
1444  (consistencyThreshold == -1) &&
1445  // Neither selecting any column or sequence?
1446  (!selectCols) && (!selectSeqs))
1447  {
1448  // If all that happens, we are not trimming the alignment and should report it.
1449  debug.report(ErrorCode::TrimmingMethodNeeded, new std::string[1]{"-colnumbering"});
1450  appearErrors = true;
1451  return true;
1452  }
1453  }
1454  return false;
1455 }
1456 
1458  if (!appearErrors) {
1459  if ((residuesOverlap != -1) && (sequenceOverlap == -1)) {
1460  debug.report(ErrorCode::SequenceAndResiduesOverlapMutuallyNeeded, new std::string[1]{"residues overlap"});
1461  appearErrors = true;
1462  return true;
1463  } else if ((residuesOverlap == -1) && (sequenceOverlap != -1)) {
1464  debug.report(ErrorCode::SequenceAndResiduesOverlapMutuallyNeeded, new std::string[1]{"sequences overlap"});
1465  appearErrors = true;
1466  return true;
1467  }
1468  }
1469  return false;
1470 }
1471 
1473  if (((htmlOutFile != nullptr) ||
1474  (svgOutFile != nullptr) ||
1475  (svgStatsOutFile != nullptr))
1476  && (!appearErrors)) {
1477  if (
1478  // Are we not using any automated method? and...
1480  // Neither using thresholds? and...
1481  (gapThreshold == -1) && (conservationThreshold == -1) && (similarityThreshold == -1) && (consistencyThreshold == -1) &&
1482  // Neither selecting columns or sequences? and...
1483  (!selectCols) && (!selectSeqs) && (residuesOverlap == -1) && (sequenceOverlap == -1) &&
1484  // Neither using other selecting methods? and...
1485  (maxIdentity == -1) && (clusters == -1))
1486  {
1487  // Then, we are not trimming the alignment and should report it.
1488  if (htmlOutFile != nullptr)
1489  debug.report(ErrorCode::TrimmingMethodNeeded, new std::string[1]{"-htmlout"});
1490  if (svgOutFile != nullptr)
1491  debug.report(ErrorCode::TrimmingMethodNeeded, new std::string[1]{"-svgout"});
1492  if (svgStatsOutFile != nullptr)
1493  debug.report(ErrorCode::TrimmingMethodNeeded, new std::string[1]{"-svgstats"});
1494  appearErrors = true;
1495  return true;
1496  }
1497  }
1498  return false;
1499 }
1500 
1502  // TODO: Create a method to check if a trimming method has been requested.
1503  // TODO: This will help to maintain coherence when scaling up
1504  // TODO: With more trimming methods.
1505 
1506  if ((stats < 0) && (!appearErrors)) {
1507  stats--;
1508 
1509  if (
1510  // If we are using an automated method
1511  ((automatedMethodCount) ||
1512  // Or a manual threshold
1513  (gapThreshold != -1) || (conservationThreshold != -1) || (similarityThreshold != -1))
1514  // We need the outFile to be specified.
1515  && (outfile == nullptr))
1516  {
1517  // If so, report the error to the user.
1519  appearErrors = true;
1520  return true;
1521  }
1522  }
1523  return false;
1524 }
1525 
1526 /**inline**/ bool trimAlManager::check_block_size() {
1527  if ((!appearErrors) && (blockSize > origAlig->getNumAminos() / 4)) {
1528  debug.report(ErrorCode::BlocksizeTooBig, new std::string[1]{std::to_string(origAlig->getNumAminos() / 4)});
1529  appearErrors = true;
1530  return true;
1531  }
1532  return false;
1533 }
1534 
1536  if (!appearErrors) {
1537  if (backtransFile == nullptr) {
1538 
1539  // Crossed dependency between Backtranslation and SplitByCodon
1540 
1541  if (splitByStopCodon) {
1542  debug.report(ErrorCode::ParemeterOnlyOnBacktranslation, new std::string[1]{"-splitbystopcodon"});
1543  appearErrors = true;
1544  return true;
1545  }
1546 
1547  // Crossed dependency between Backtranslation and IgnoreStopCodon
1548  if (ignoreStopCodon) {
1549  debug.report(ErrorCode::ParemeterOnlyOnBacktranslation, new std::string[1]{"-ignorestopcodon"});
1550  appearErrors = true;
1551  return true;
1552  }
1553  }
1554  // If doing backtranslation, we need the input file to be aligned.
1555  else if (!origAlig->isFileAligned()) {
1557  appearErrors = true;
1558  return true;
1559  }
1560  }
1561  return false;
1562 }
1563 
1565  if (
1566  // Is there a backtranslation file?
1567  (!appearErrors) && (backtransFile != nullptr) &&
1568  // If so, is it from DNA? If not...
1570  {
1571  // When doing backtranslation,
1572  // a DNA alignment (without gaps) is needed.
1573  // Report the error to the user.
1575  appearErrors = true;
1576  return true;
1577  }
1578  return false;
1579 }
1580 
1582  if ((!appearErrors) &&
1583  // If we are going to do a back translation
1584  (backtransFile != nullptr) &&
1585  // Perform it and save if it has errored.
1589  origAlig)
1590  )
1591  )
1592  {
1593  // Error reporting is made by prepareCodingSequence function.
1594  appearErrors = true;
1595  return true;
1596  }
1597  return false;
1598 }
1599 
1601  //NOTE Maybe we don't need to copy the names and lengths to two new arrays
1602  // as we could pass the original names and lengths to the check checkCorrespondence function,
1603  // which doesn't modify the pointers passed to them
1604 
1605  if ((!appearErrors) && (backtransFile != nullptr)) {
1609 
1614  3
1615  )) {
1616  appearErrors = true;
1617  }
1618  }
1619  delete [] sequencesNames;
1620  delete [] sequencesLengths;
1621 
1622  return appearErrors;
1623 }
1624 
1626  if ((!appearErrors) && (windowSize != -1) && (compareset != nullptr))
1628 }
1629 
1630 /**inline**/ void trimAlManager::check_output_format() {
1631  if (oformats.empty() && infile) {
1633  }
1634 }
1635 
1637  bool generalMakesSense = false;
1638  for(auto& thresholdDependency : std::vector<std::tuple<const char *, float&, int&>>{
1639  {"gaps", gapThreshold, gapWindow},
1640  {"similarity", similarityThreshold, similarityWindow},
1641  {"consistency", consistencyThreshold, consistencyWindow},
1642  })
1643  {
1644  if (std::get<2>(thresholdDependency) != -1) // Window is defined
1645  {
1646  if (std::get<1>(thresholdDependency) == -1.0F) // Threshold is not defined
1647  {
1648  this->appearErrors = true;
1649  std::cout << std::get<0>(thresholdDependency) << " window provided, but stat not requested.";
1650  }
1651  } else if (windowSize != -1) { // Specific window is not defined, but general is
1652  if (std::get<1>(thresholdDependency) != -1.0F) // Threshold is defined
1653  {
1654  generalMakesSense = true;
1655  }
1656  }
1657  }
1658  if (windowSize != -1) // General window size specified
1659  {
1660  if (!generalMakesSense) // And there isn't a stat with no specific window
1661  {
1662  this->appearErrors = true;
1663  std::cout << "General window provided, but no stat requested without specific window";
1664  }
1665  }
1666 }
1667 
1669  // Create a timer that will report times upon its destruction
1670  // which means the end of the current scope.
1671  StartTiming("int trimAlManager::perform() ");
1672 
1673  // We don't perform any manipulation in previous steps an error has
1674  // been detected
1675  if (appearErrors)
1676  return 1;
1677 
1678  // If similarity threshold is -1, it hasn't been specified, and we
1679  // use 0 as default value, which makes no effect
1680  if (conservationThreshold == -1)
1682 
1683  // In case we are not doing VCF transformations, the perform
1684  // should be applied normally and once.
1685  if (vcfs == nullptr)
1686  return innerPerform();
1687 
1688  // In case we are doing VCF transformations, the perform should
1689  // be applied in all the collection.
1690  else
1691  {
1692  int returnValue = 0;
1694  char replacement = '-';
1696  /* Dataset */ XX,
1697  /* VCF Collection */ *vcfs,
1698  /* min Quality */ minQuality,
1699  /* min Coverage */ minCoverage,
1700  /* ignore Filters */ ignoreFilter,
1701  /* replacement char */ &replacement
1702  );
1703 
1704  // If no output filename has been provided,
1705  // or the filename does not contain the [contig] tag,
1706  // the sequence names should contain the name of the contig
1707  // to prevent repeated sequences names.
1708  if (outfile == nullptr || std::string(outfile).find("[contig]") == std::string::npos)
1709  {
1710  // On each alignment, add the prefix to each non-reference sequence -> [1:]
1711  for (Alignment* &i : XX)
1712  {
1713  for (int x = 1; x < i->originalNumberOfSequences; x++)
1714  i->seqsName[x] = i->seqsName[0] + "." + i->seqsName[x];
1715  }
1716 
1717  // We check if outfile is not null because checking
1718  // if it contains the contig tag
1719  // it needs to be converted to string
1720  // and it needs to check if outfile is not null previously
1721  // As this two conditions have previously checked,
1722  // if outfile is not null, it doesn't contain the tag either.
1723  if (outfile != nullptr)
1724  {
1725  // Set the mode of opening files of the manager to append.
1726  formatManager.openmode = std::ofstream::out | std::ofstream::app;
1727 
1728  // Store the output filename
1729  std::string fname = formatManager.replaceINtag(*origAlig, outfile);
1730 
1731  // Iterate over all formats requested
1732  for (const std::string & token : oformats) {
1733 
1734  // Get the handler for each format handler
1735  auto * handler = formatManager.getFormatFromToken(token);
1736  if (handler != nullptr)
1737  {
1738  // Open the destination file to empty it
1739  std::string newName =
1741  fname, "[format]", handler->name);
1743  newName, "[extension]", handler->extension);
1744  std::ofstream tmp(newName);
1745  }
1746  }
1747  }
1748  }
1749 
1750  // To allow users to use [in] and [contig] tags, we should recover the original filename.
1751  std::string originalName = origAlig->filename;
1752 
1753  // We can get rid of the original alignment.
1754  delete origAlig;
1755  origAlig = nullptr;
1756 
1757  // Save the original filename pattern containing the tags
1758  std::string originalOutFile = outfile == nullptr ? "" : outfile;
1759 
1760  // Free the outfile array. It will be replenished before it's use.
1761  delete [] outfile;
1762 
1763  for (Alignment* &i : XX) {
1764 
1765  // If original filename wasn't empty,
1766  // reset it and apply the [contig] tag
1767  std::string newOutFile =
1769  originalOutFile, "[contig]", i->filename);
1770 
1771  if (!originalOutFile.empty())
1772  {
1773  outfile = &newOutFile[0];
1774  i->filename = originalName;
1775  }
1776 
1777  // To use innerPerform, alignment must be stored on origAlig
1778  origAlig = i;
1779  returnValue = std::max(innerPerform(), returnValue);
1780 
1781  // Delete and nullify tempAlig
1782  if (tempAlig != origAlig &&
1783  tempAlig != singleAlig)
1784  delete tempAlig;
1785  tempAlig = nullptr;
1786 
1787  // Delete and nullify singleAlig
1788  if (singleAlig != origAlig)
1789  delete singleAlig;
1790  singleAlig = nullptr;
1791 
1792  // Delete and nullify origAlig
1793  delete origAlig;
1794  origAlig = nullptr;
1795 
1796  }
1797  outfile = nullptr;
1798  origAlig = nullptr;
1799  return returnValue;
1800  }
1801 }
1802 
1803 /**inline**/ int trimAlManager::innerPerform() {
1806 
1808 
1809  if (blockSize != -1)
1811 
1813  return 2;
1814 
1816 
1818 
1819  if (singleAlig == nullptr) {
1820  singleAlig = origAlig;
1821  origAlig = nullptr;
1822  }
1823 
1825 
1827 
1829 
1830  if (svgStatsOutFile != nullptr)
1832 
1833  if ((columnNumbering) && (!appearErrors))
1835 
1836  return 0;
1837 
1838 }
1839 
1840 /**inline**/ void trimAlManager::save_alignment()
1841 {
1842  if ((outfile != nullptr) && (!appearErrors)) {
1843  std::string outFileString = std::string(outfile);
1844  if (singleAlig != nullptr)
1845  {
1847  appearErrors = true;
1848  }
1849  } else debug.report(
1851  "Trying to save a nullptr alignment on save_alignment");
1852 
1853  } else if ((stats >= 0) && (!appearErrors))
1854  {
1855  std::string emptyString;
1856  if (singleAlig != nullptr)
1858  else debug.report(
1860  "Trying to save a nullptr alignment on save_alignment");
1861  }
1862 }
1863 
1864 /**inline**/ bool trimAlManager::performCompareset() {
1865 
1866  if (compareset != nullptr && !appearErrors) {
1867 
1868  // Need to check this here, as inside Consistency::perform
1869  // origAlig is set and checked
1870  // (if no forceselect applied),
1871  // and thus, one alignment would be leaked.
1872  if (infile != nullptr)
1873  {
1875  return appearErrors = true;
1876  }
1877  CS = new statistics::Consistency();
1879  appearErrors = true;
1880  }
1881  return appearErrors;
1882 }
1883 
1884 /**inline**/ void trimAlManager::output_reports()
1885 {
1886  if ((svgOutFile != nullptr) && (!appearErrors))
1887  {
1888  size_t start = origAlig->filename.find_last_of('/');
1889  if (start == std::string::npos) start = 0;
1890  size_t end = origAlig->filename.find_last_of('.');
1891  if (end == std::string::npos) end = origAlig->filename.size();
1892  std::string filename = utils::ReplaceString(svgOutFile, "[in]", origAlig->filename.substr(start, end-start));
1893  utils::ReplaceStringInPlace(filename, "[extension]", "svg");
1894  if (!origAlig->alignmentSummarySVG(*singleAlig, filename.c_str(), 0)) {
1895  debug.report(ErrorCode::ImpossibleToGenerate, new std::string[1]{"the SVG output file"});
1896  appearErrors = true;
1897  }
1898  }
1899 
1900  if ((htmlOutFile != nullptr) && (!appearErrors))
1901  {
1902  size_t start = origAlig->filename.find_last_of('/');
1903  if (start == std::string::npos) start = 0;
1904  size_t end = origAlig->filename.find_last_of('.');
1905  if (end == std::string::npos) end = 0;
1906  std::string filename = utils::ReplaceString(htmlOutFile, "[in]", origAlig->filename.substr(start, end-start));
1907  utils::ReplaceStringInPlace(filename, "[extension]", "svg");
1908  if (!origAlig->alignmentSummaryHTML(*singleAlig, filename.c_str())) {
1909  debug.report(ErrorCode::ImpossibleToGenerate, new std::string[1]{"the HTML output file"});
1910  appearErrors = true;
1911  }
1912  }
1913 }
1914 
1915 /**inline**/ void trimAlManager::print_statistics() {
1916  // Create a timer that will report times upon its destruction
1917  // which means the end of the current scope.
1918  StartTiming("/**inline**/ void trimAlManager::print_statistics() ");
1919 
1920  if (sgc) {
1922  stats++;
1923  }
1924 
1925  if (sgt) {
1927  stats++;
1928  }
1929 
1930  if (ssc) {
1932  stats++;
1933  }
1934 
1935  if (sst) {
1937  stats++;
1938  }
1939 
1940  if (sident) {
1942  stats++;
1943  }
1944 
1945  if (soverlap) {
1947  stats++;
1948  }
1949 
1950  if (compareset != nullptr) {
1951  if (sfc)
1953  if (sft)
1955  }
1956 }
1957 
1958 /**inline**/ void trimAlManager::svg_stats_out()
1959 {
1961 }
1962 
1964  // Create a timer that will report times upon its destruction
1965  // which means the end of the current scope.
1966  StartTiming("/**inline**/ bool trimAlManager::create_or_use_similarity_matrix() ");
1967  if ((strict) || (strictplus) || (automated1) || (similarityThreshold != -1.0) || (ssc == 1) || (sst == 1)) {
1969 
1970  // Load Matrix
1971  if (matrixFile != nullptr)
1973 
1974  // Alternative Default Matrix
1975  else if (alternative_matrix != -1) {
1977  }
1978 
1979  // Default Matrices
1980  else {
1981  int alignDataType = origAlig->getAlignmentType();
1982  if (alignDataType & SequenceTypes::AA)
1984  else if ((alignDataType == SequenceTypes::DNA) || (alignDataType == SequenceTypes::RNA))
1986  else if ((alignDataType == (SequenceTypes::DNA | SequenceTypes::DEG)) ||
1987  (alignDataType == (SequenceTypes::RNA | SequenceTypes::DEG)))
1989  }
1990 
1991  // Check if Matrix has been loaded
1994  return false;
1995  }
1996  }
1997  return true;
1998 }
1999 
2000 /**inline**/ void trimAlManager::clean_alignment() {
2001  // Create a timer that will report times upon its destruction
2002  // which means the end of the current scope.
2003  StartTiming("inline void trimAlManager::clean_alignment() ");
2004 
2005  // Check alignment is aligned
2008  exit(ErrorCode::NotAligned);
2009  }
2010 
2011  // We apply first the cleaning methods that remove sequences
2013 
2014  // We apply the cleaning methods that remove columns / residues
2015  // Combination between Automatic and Non Automatic are not allowed
2018  else
2020 
2021 }
2022 
2023 /**inline**/ void trimAlManager::postprocess_alignment() {
2024  // Create a timer that will report times upon its destruction
2025  // which means the end of the current scope.
2026  StartTiming("/**inline**/ void trimAlManager::postprocess_alignment()");
2027 
2028  // Only terminal
2029  if (terminalOnly)
2031 
2032  // Complementary
2033  if (getComplementary)
2035 
2036  // ComplementarySeq
2037  if (getComplementarySeq)
2039 
2040  // Backtranslate
2041  if (backtransFile != nullptr) {
2043  if (singleAlig != origAlig)
2044  delete singleAlig;
2045  singleAlig = tempAlig;
2046  tempAlig = nullptr;
2047  }
2048 
2049 }
2050 
2051 /**inline**/ void trimAlManager::CleanSequences() {
2052  // Create a timer that will report times upon its destruction
2053  // which means the end of the current scope.
2054  StartTiming("/**inline**/ void trimAlManager::CleanSequences() ");
2055 
2056  // Clustering by number of clusters
2057  if (clusters != -1) {
2060  );
2061 
2062  // Clustering by Max Identity
2063  } else if (maxIdentity != -1) {
2065 
2066  // Remove Sequences
2067  } else if (delSequences != nullptr) {
2069  delSequences, // Informative array
2070  1, // Position to start.
2071  // Position on number 0 indicates the number of elements.
2072  delSequences[0], // Num of sequences in array
2073  false // Complementary? Legacy
2074  );
2075 
2076  // Remove by Overlap
2077  } else if ((residuesOverlap != -1) && (sequenceOverlap != -1)) {
2080  sequenceOverlap / 100.0F,
2081  /* getComplementary*/ false
2082  );
2083  } else if (removeDuplicates) {
2085  }
2086 
2087 
2088  // We'll use singleAlig as input for the next cleaning step.
2089  // If tempAlig is not null it means that we've performed a sequence trim
2090  // If not, we move the origAlig to singleAlig
2091  if (tempAlig) {
2093 
2094  delete tempAlig;
2095  tempAlig = nullptr;
2096 
2098  singleAlig->Statistics->gaps = nullptr;
2099 
2102 
2103  } else {
2104  singleAlig = origAlig;
2105  }
2106 }
2107 
2108 /**inline**/ void trimAlManager::CleanResiduesAuto() {
2109  // Create a timer that will report times upon its destruction
2110  // which means the end of the current scope.
2111  StartTiming("/**inline**/ void trimAlManager::CleanResiduesAuto() ");
2112  // Here we use singleAlig as source alignment as the previous step,
2113  // CleanSequences initializes singleAlig.
2114  // singleAlig can be a derived alignment from origAlig or be origAlig itself
2115 
2116  if (automated1) {
2118  gappyout = true;
2119  else
2120  strict = true;
2121  }
2122  if (nogaps) {
2123  tempAlig = singleAlig->Cleaning->cleanGaps(0, 0, /* getComplementary*/ false);
2124  } else if (noallgaps) {
2125  tempAlig = singleAlig->Cleaning->cleanNoAllGaps(/* getComplementary*/ false);
2126  } else if (gappyout) {
2127  tempAlig = singleAlig->Cleaning->clean2ndSlope(/* getComplementary*/ false);
2128  } else if (strict) {
2129  tempAlig = singleAlig->Cleaning->cleanCombMethods(/* getComplementary*/ false, false);
2130  } else if (strictplus) {
2131  tempAlig = singleAlig->Cleaning->cleanCombMethods(/* getComplementary*/ false, true);
2132  }
2133 
2134  // Move the new formed alignment to the variable singleAlig
2135  if (tempAlig) {
2136  // If singleAlig was an created, we delete it from memory.
2137  if (singleAlig != origAlig)
2138  delete singleAlig;
2139 
2140  singleAlig = tempAlig;
2141  tempAlig = nullptr;
2142  }
2143 }
2144 
2145 /**inline**/ void trimAlManager::CleanResiduesNonAuto() {
2146  // Here we use singleAlig as source alignment as the previous step,
2147  // CleanSequences initializes singleAlig.
2148  // singleAlig can be a derived alignment from origAlig or origAlig itself
2149 
2150  // Create a timer that will report times upon its destruction
2151  // which means the end of the current scope.
2152  StartTiming("/**inline**/ void trimAlManager::CleanResiduesNonAuto() ");
2153 
2154  if (delColumns != nullptr) {
2155  for (int i = 0 ; i <= delColumns[0]; i++)
2156  {
2160  new std::string[2]{"-selectcols", "residues"}
2161  );
2162  appearErrors = true;
2163  }
2164  }
2165  if (!appearErrors)
2167  delColumns,
2168  1,
2169  delColumns[0],
2170  /* getComplementary*/ false
2171  );
2172 
2173  } else {
2174 
2175  // Consistency will be applied prior to gap or similarity
2176  if (consistencyThreshold != -1.0F) {
2181  /* getComplementary*/ false
2182  );
2183  if (singleAlig != origAlig) delete singleAlig;
2184  singleAlig = tempAlig;
2185  tempAlig = nullptr;
2186  }
2187 
2188  if (similarityThreshold != -1.0F) {
2189 
2190  // Clean by similarity AND gaps
2191  if (gapThreshold != -1.0F) {
2196  /* getComplementary*/ false
2197  );
2198  // Clean only by similarity
2199  } else {
2203  /* getComplementary*/ false
2204  );
2205  }
2206  // Clean only by gaps
2207  } else if (gapThreshold != -1.0F) {
2208 
2212  /* getComplementary*/ false
2213  );
2214 
2215  }
2216  }
2217 
2218  if (tempAlig) {
2219  if (singleAlig != origAlig)
2220  delete singleAlig;
2221  singleAlig = tempAlig;
2222  tempAlig = nullptr;
2223  }
2224 }
2225 
2226 /**inline**/ void trimAlManager::set_window_size() {
2227  // Create a timer that will report times upon its destruction
2228  // which means the end of the current scope.
2229  StartTiming("inline void trimAlManager::set_window_size() ");
2230  if (windowSize != -1) {
2233  } else {
2234  if (gapWindow == -1)
2235  gapWindow = 0;
2236  if (similarityWindow == -1)
2237  similarityWindow = 0;
2238  }
2240 }
2241 
2242 /**inline**/ void trimAlManager::delete_variables() {
2243  // Create a timer that will report times upon its destruction
2244  // which means the end of the current scope.
2245  StartTiming("inline void trimAlManager::delete_variables() ");
2246 
2247  if (tempAlig == origAlig || tempAlig == singleAlig)
2248  tempAlig = nullptr;
2249  if (singleAlig == origAlig)
2250  singleAlig = nullptr;
2251 
2252  delete tempAlig;
2253  tempAlig = nullptr;
2254 
2255  delete singleAlig;
2256  singleAlig = nullptr;
2257 
2258  delete origAlig;
2259  origAlig = nullptr;
2260 
2261  delete[] compareAlignmentsArray;
2262  compareAlignmentsArray = nullptr;
2263 
2264  delete similMatrix;
2265  similMatrix = nullptr;
2266 
2267  delete[] delColumns;
2268  delColumns = nullptr;
2269 
2270  delete[] delSequences;
2271  delSequences = nullptr;
2272 
2273  delete[] filesToCompare;
2274  filesToCompare = nullptr;
2275 
2276  delete[] outfile;
2277  outfile = nullptr;
2278  delete[] htmlOutFile;
2279  htmlOutFile = nullptr;
2280  delete[] svgOutFile;
2281  svgOutFile = nullptr;
2282  delete[] svgStatsOutFile;
2283  svgStatsOutFile = nullptr;
2284 
2285  delete[] infile;
2286  infile = nullptr;
2287  delete[] matrixFile;
2288  matrixFile = nullptr;
2289 
2290  delete [] forceFile;
2291  forceFile = nullptr;
2292  delete [] backtransFile;
2293  backtransFile = nullptr;
2294  delete backtranslationAlig;
2295  backtranslationAlig = nullptr;
2296 
2297  delete vcfs;
2298  vcfs = nullptr;
2299 
2300  delete CS;
2301  CS = nullptr;
2302 
2303 }
2304 
2305 /**inline**/ void trimAlManager::menu() {
2306  // Create a timer that will report times upon its destruction
2307  // which means the end of the current scope.
2308  StartTiming("void trimAlManager::menu(void) ");
2309 
2310  // Simple idiom to allow including a text file into a char array at compile time
2311  // Explanation: https://stackoverflow.com/a/25021520
2312  std::string menu = {
2313  #include "RawText/menu.txt"
2314  };
2315 
2318  utils::ReplaceStringInPlace(menu, "[version]", VERSION);
2319  utils::ReplaceStringInPlace(menu, "[revision]", REVISION);
2320  utils::ReplaceStringInPlace(menu, "[build]", BUILD);
2321  utils::ReplaceStringInPlace(menu, "[authors]", AUTHORS);
2322 
2323  using namespace utils::TerminalColors;
2324 
2325  utils::ReplaceStringInPlace(menu, "[b][u]", colors[BOLD] + colors[UNDERLINE]);
2326  utils::ReplaceStringInPlace(menu, "[b]", colors[BOLD]);
2327  utils::ReplaceStringInPlace(menu, "[u]", colors[UNDERLINE]);
2328  utils::ReplaceStringInPlace(menu, "[r]", colors[RESET]);
2329 
2330  std::cout << menu;
2331 }
2332 
2333 /**inline**/ void trimAlManager::examples() {
2334  // Create a timer that will report times upon its destruction
2335  // which means the end of the current scope.
2336  StartTiming("void trimAlManager::examples(void) ");
2337 
2338  // Simple idiom to allow including a text file into a char array at compile time
2339  // Explanation: https://stackoverflow.com/a/25021520
2340  std::string examples = {
2341  #include "RawText/examples.txt"
2342  };
2343 
2344  using namespace utils::TerminalColors;
2345 
2346  utils::ReplaceStringInPlace(examples, "[b][u]", colors[BOLD] + colors[UNDERLINE]);
2347  utils::ReplaceStringInPlace(examples, "[b]", colors[BOLD]);
2348  utils::ReplaceStringInPlace(examples, "[u]", colors[UNDERLINE]);
2349  utils::ReplaceStringInPlace(examples, "[r]", colors[RESET]);
2350 
2351  std::cout << examples;
2352 }
2353 
2355  return this->formatManager;
2356 }
void removeDuplicates()
Definition: Cleaner.cpp:1610
float conservationThreshold
Similarity Threshold to use while trimming.
Alignment * cleanCombMethods(bool complementary, bool variable)
Method to clean an alignment. It carries out strict and strictplus. The method:
Definition: Cleaner.cpp:980
bool check_stats_incompatibilities()
Method to check statistics incompatibilities.
std::string filename
Filename where this alignment was loaded from.
Definition: Alignment.h:84
argumentReport html_out_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the html output file.
argumentReport split_by_stop_codon_argument(const int *argc, char *argv[], int *currentArg)
Method to parse split by stop codon argument.
argumentReport max_identity_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the max identity argument.
1 << 1 = 2
Definition: defines.h:80
bool check_residue_and_sequence_overlap()
Method to check if both of them (residue overlap and sequence overlap) have been defined by the user ...
argumentReport select_cols_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the select columns argument.
bool terminalOnly
Flag to use the Terminal Only option.
Definition: trimalManager.h:93
Similarity * similarity
Similarity submodule.
Definition: Manager.h:63
bool selectSeqs
Flag to select sequences manually from the alignment.
Definition: trimalManager.h:90
void defaultNTDegeneratedSimMatrix()
Method to load the default DEG NT similarity matrix.
Class to handle Format Handlers . It serves as a proxy to the handlers, so the code outside the Form...
Definition: FormatManager.h:64
bool check_and_prepare_coding_sequence()
Method to check and prepare the coding sequence.
Alignment * clean(float baseLine, float GapsPct, float conservationPct, bool complementary)
Method to trim an alignment based on the similarity and gaps distribution values. ...
Definition: Cleaner.cpp:784
float gapThreshold
Gap Threshold to use while trimming.
argumentReport ignore_filter_argument(const int *argc, char *argv[], int *currentArg)
char * compareset
Pointer to the argument that contains the compareset file.
bool check_arguments_incompatibilities()
Method to check argument incompatibilities. Take in mind that an incompatibility is between two argum...
bool check_file_aligned()
Method to check if an alignment needs to be aligned depending on the methods that have been asked to ...
argumentReport strict_plus_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the strictplus argument.
void postprocess_alignment()
1 = Info, warning and error messages
Definition: reportsystem.h:47
#define GAPPYOUT
Definition: defines.h:38
int automatedMethodCount
Integer counter of the automatic methods. If the counter is bigger than 0, we are using an automati...
#define AUTHORS
Definition: defines.h:36
void verbosity_argument(const int *argc, char *argv[])
Method to parse the verbosity argument. This check is done before any other check. This is due to trimAl not performing any action if any help argument has been provided. .
float similarityThreshold
Similarity Threshold to use while trimming.
argumentReport keep_seqs_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the keepSeqs argument.
1 << 2 = 4
Definition: defines.h:84
Cleaner * Cleaning
Trimming submodule. It contains methods and variables related to trimming.
Definition: Alignment.h:58
void delete_variables()
Method to delete all variables that need to be deallocated.
argumentReport out_format_arguments(const int *argc, char *argv[], int *currentArg)
Method to parse the output formats as -fasta -clustal or -formats [...].
#define REVISION
Definition: defines.h:35
void set_window_size()
Method to set correct window sizes depending on values for them given by the user.
argumentReport similarity_threshold_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the similarity threshold argument.
SequenceTypes
Definition: defines.h:72
void defaultAASimMatrix()
Method to load the default AA similarity matrix.
std::string replaceINtag(const Alignment &alignment, const std::string &outPattern)
argumentReport window_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the Window argument.
bool processArguments(char *argv[])
Method to process the information obtained by trimAlManager::parseArguments It checks for argument in...
bool isFileAligned()
isAligned getter.
Definition: Alignment.cpp:495
Alignment * getClustering(float identityThreshold)
Method to select the most representative sequence (the longest one) for each cluster from the input a...
Definition: Cleaner.cpp:1211
bool splitByStopCodon
Flag to use the SplitByCodonStop option.
Definition: trimalManager.h:92
bool check_inFile_incompatibilities()
Method to check the inFile argument incompatibilities.
int selectMethod()
Method that selects the best cleaning method based on statistics of the alignment.
Definition: Cleaner.cpp:42
bool strict
Flag to use the strict trimming method.
Definition: trimalManager.h:79
argumentReport automated1_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the automated1 argument.
std::string * sequencesNames
Temporal variable to use in backtranslation option to compare with infile.
Class to calculate the consistency between several MSA containing the same sequences, differently aligned. Using this statistics, the class is able to select the most consistent alignment between all alignments provided. It is possible to forcefully select an alignment, but to calculate the statistics for latter use. After selecting an alignment (most consistent or manually selected), it is possible to use this statistic to trim the alignment, removing columns that are not consistent enough with the other alignments.
Definition: Consistency.h:58
char * backtransFile
File to load the alignment containing the backtranslation information.
Definition: VCFHandler.h:42
argumentReport remove_duplicates_argument(const int *argc, char *argv[], int *currentArg)
bool check_output_relevance()
Method to check if, being asked to give an HTML report, it makes logic, depending on the functionalit...
bool check_outputs_coincidence()
Method to check if both output patterns (alignment output and html report output) are the same...
#define stat_check(stat)
Consistency()
Default Construtor.
argumentReport back_trans_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the backtranslation argument.
std::ifstream compare
Temporal variable to open files in trimAlManager::check_multiple_files_comparison function...
Alignment * removeSequences(int *seqs, int init, int size, bool complementary)
Method to remove sequences, expressed as ranges.
Definition: Cleaner.cpp:1262
bool sgt
Flag to show the Accumulated Gaps Scores.
Definition: trimalManager.h:83
Alignment * removeColumns(int *columns, int init, int size, bool complementary)
Method to remove columns, expressed as ranges.
Definition: Cleaner.cpp:1240
static void printStatisticsFileAcl(Alignment &alig, float *compareVect)
Print the accumulated consistency value from the selected alignment.
bool sft
Flag to show the Accumulated Sum of Pairs.
Definition: trimalManager.h:87
float residuesOverlap
Residues Overlap to use while trimming.
char * outfile
File to output the trimmed alignment. This can contain tags which will be traduced to some variables:...
int perform()
Method to perform the analysis if all checks have passed.
argumentReport col_numbering_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the column numbering argument.
int blockSize
Block Size to use while trimming.
argumentReport help_arguments(const int *argc, char **argv, int *currentArg)
Method to parse information arguments as help and menu.
argumentReport seqs_select_argument(const int *argc, char *argv[], int *currentArg)
Method to parse que select sequences argument.
Alignment * cleanGaps(float baseLine, float gapsPct, bool complementary)
Method to trim an alignment based on the gap distribution values. Column blocks that don&#39;t have a min...
Definition: Cleaner.cpp:736
void printSeqIdentity()
Method to print different identity values computed from the alignment. In this method we assess the i...
Definition: Alignment.cpp:912
void alternativeSimilarityMatrices(int matrix_code, int datatype)
Method to load alternative similarity matrices also included on the suite. Currently, only one type of alternative matrix is available: matrix_code: 1 datatype SequenceTypes::AA.
bool statSVG(const char *const destFile)
Definition: Alignment.cpp:1431
statistics::Manager * Statistics
Statistics submodule. It contains methods and variables related to statistics calculation and reporti...
Definition: Alignment.h:60
bool automated1
Flag to use the automated1 trimming method.
Definition: trimalManager.h:81
std::string ReplaceString(std::string subject, const std::string &search, const std::string &replace)
Function that replaces a substring with another substring in a string. It makes a copy of the origina...
Definition: utils.cpp:820
#define StartTiming(name)
bool setSimilarityMatrix(similarityMatrix *sm)
Method to set a similarity matrix.
Definition: Manager.cpp:100
Alignment * cleanNoAllGaps(bool complementary)
Method to remove columns composed only by gaps This method is specially useful when we remove missali...
Definition: Cleaner.cpp:1049
bool getComplementary
Flag to return the complementary alignment.
Definition: trimalManager.h:73
static void printStatisticsFileColumns(Alignment &alig, float *compareVect)
Print the consistency value for each column from the selected alignment.
bool check_backtranslations()
Method to check backtranslation needs.
3 = Only error messages
Definition: reportsystem.h:51
Alignment * loadAlignment(const std::string &inFile)
Function that loads an alignment given a file path. It automatically detects the format of the file...
Namespace that encapsulates all logic referent to Load, Save and Recognize Multiple Sequence Alignm...
Definition: FormatManager.h:52
4 = No output messages
Definition: reportsystem.h:53
bool check_automated_manual_incompatibilities()
Check if only one method, either automatic or manual has been asked.
VerboseLevel Level
Level of Verbosity. The report system won&#39;t output messages that are lower than the current level...
Definition: reportsystem.h:377
argumentReport no_all_gaps_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the noallgaps argument.
float * getValues()
Stat Getter .
argumentReport consistency_window_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the Consistency Window argument.
argumentReport compareset_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the comparset argument.
int similarityWindow
Similarity Window to use while trimming.
int * delSequences
Vector that contains the sequence indexes the user specified to be removed.
void printStatisticsGapsTotal()
Wrapper to Statistics::Gaps::printGapsAcl() It calls to calculateGapStats() to make sure the informat...
Definition: Manager.cpp:131
Class containing an alignment This class stores the alignment sequences with it&#39;s names...
Definition: Alignment.h:49
argumentReport matrix_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the custom matrix argument.
argumentReport residue_overlap_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the residue overlap argument.
bool loadSimMatrix(char *filename)
Method to load a custom matrix.
bool noallgaps
Flag to use the noallgaps option.
Definition: trimalManager.h:77
argumentReport ignore_stop_codon_argument(const int *argc, char *argv[], int *currentArg)
Method to parse ignore by stop codon argument.
VerboseLevel
VerboseLevel used to report messages.
Definition: reportsystem.h:44
argumentReport gap_window_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the Gap Window argument.
bool getComplementarySeq
Definition: trimalManager.h:74
Class that contains information of similarity matrices. These are used to calculate the similarity be...
void printStatisticsConservationTotal()
Wrapper to Statistics::Similarity::printGapsTotal() It calls to calculateConservationStats() to make ...
Definition: Manager.cpp:86
FormatHandling::BaseFormatHandler * getFormatFromToken(const std::string &token)
bool check_vcf_incompatibility()
argumentReport svg_out_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the svg output file.
std::string extension
String that contains the main extension of the format.
argumentReport similarity_window_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the Similarity Window argument.
argumentReport sequence_overlap_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the sequence overlap argument.
void print_statistics()
Method to print statistics requested.
argumentReport in_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the input file argument.
void setBlockSize(int blockSize)
BlockSize Setter.
Definition: Alignment.cpp:267
bool appearErrors
Flag to trace errors.
Definition: trimalManager.h:71
bool check_force_selection()
Method to check dependency of force select argument.
void printCorrespondence()
Method to print the vector containing the keep/reject (Alignment::saveResidues) values of the associa...
Definition: Manager.cpp:144
2 = Error and warning messages
Definition: reportsystem.h:49
argumentReport complementary_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the complementary argument.
void CleanResiduesNonAuto()
Method to trim the alignment using non automatic methods:
bool check_codon_behaviour_incompatibility()
Method to check incompatibilities related to how the algorithm should treat stop codons.
bool checkCorrespondence(std::string *names, int *lenghts, int totalInputSequences, int multiple)
Function to check CDS file. .
Definition: Alignment.cpp:716
int alternative_matrix
Int that represents which alternative matrix to use, where &#39;-1&#39; means no alternative matrix...
void printStatisticsConservationColumns()
Wrapper to Statistics::Similarity::printConservationAcl() It calls to calculateConservationStats() to...
Definition: Manager.cpp:73
int gapAbsoluteThreshold
void report(ErrorCode message, const char *vars)
Method to report an Error. It will be displayed if Level is equal or higher to VerboseLevel::ERROR.
int numberOfResidues
Number of residues present on the alignment if it is aligned.
Definition: Alignment.h:74
ErrorCode
Definition: reportsystem.h:56
bool soverlap
Flag to show overlap scores in the alignment.
Definition: trimalManager.h:89
void defaultNTSimMatrix()
Method to load the default NT similarity matrix.
std::vector< std::string > oformats
Formats names we are going to output our trimmed alignment.
Alignment * singleAlig
Alignment obtained by making modifications to singleAlig or backtranslationAlig.
Namespace containing all classes related to statistics handling.
Definition: Similarity.h:44
argumentReport terminal_only_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the terminal only argument.
argumentReport vcf_argument(const int *argc, char *argv[], int *currentArg)
Method to parse vcf argument.
argumentReport min_quality_argument(const int *argc, char *argv[], int *currentArg)
bool removeOnlyTerminal()
Method to detect right and left borders. Borders are the first column found with no gaps...
Definition: Cleaner.cpp:1283
argumentReport out_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the output file pattern.
void clean_alignment()
Core Method of the program. This is where almost all cleaning methods are called from.
int windowSize
Window Size to use while trimming.
reporting::reportManager debug
FormatHandling::FormatManager & getFormatManager()
bool keepHeader
Tag to know if the machine should keep original headers.
bool check_arguments_needs(char *argv[])
Method that checks dependencies between arguments. Take in mind that dependencies may be between mult...
bool keepSeqs
Flag to keep sequences in the alignment.
Definition: trimalManager.h:94
std::string * seqsName
String vector containing the sequences names.
Definition: Alignment.h:80
void readVCF(const AlignmentVector &sources, const StringVector &filenames, const float minQuality, const float minCoverage, const bool ignoreFilter, const char *const replacementChar)
Definition: VCFHandler.cpp:619
bool check_thresholds_incompatibilities()
Method to check incompatibilities with manual thresholds.
statistics::Consistency * CS
void setWindowsSize(int ghWindow, int shWindow)
Windows setter.
Definition: Alignment.cpp:259
void setTrimTerminalGapsFlag(bool terminalOnly_)
Setter method to Terminal Only Flag.
Definition: Cleaner.cpp:1194
float sequenceOverlap
Sequence Overlap to use while trimming.
void check_output_format()
Method to check if an output format has been given. If no output format has been given, it will use the inFile format.
bool check_windows_incompatibilities()
Method to check windows incompatibilities.
int originalNumberOfSequences
Number of sequences the alignment had when it was loaded.
Definition: Alignment.h:68
void report(InfoCode message, std::string *vars=nullptr)
Method to report an Info message. It will be displayed if Level is equal or higher to VerboseLevel:...
argumentReport timetracker_out_argument(const int *argc, char *argv[], int *currentArg)
Method to parse InternalBenchmarker output argument. Need to be checked before any other argument...
int consistencyWindow
Consistency Window to use while trimming.
char * htmlOutFile
File to output the html report.
Alignment * getTranslationCDS(Alignment *proteinAlignment)
Method to back translate a protein alignment using the sequences present on the current alignment...
Definition: Alignment.cpp:169
std::string getOutputFormatsAvailable()
Function to obtain all format names available by this object that can save an alignment.
Alignment * tempAlig
Temporal alignment that allows us to make some changes to trimAlManager::singleAlig, destroy it and set trimAlManager::singleAlig to this.
void report(ErrorCode message, std::string *vars=nullptr)
Method to report an Error. It will be displayed if Level is equal or higher to VerboseLevel::ERROR...
void menu()
Method to show the menu of the program.
bool sgc
Flag to show the Gaps Scores per column.
Definition: trimalManager.h:82
std::vector< std::string > * vcfs
Definition: trimalManager.h:68
char * svgStatsOutFile
File to output the svg graph showing the stats along the alignment.
void examples()
Method to show the examples information about the program.
FormatHandling::FormatManager formatManager
Read Write Machine that allows to manage formats easily.
int clusters
Number of most representative sequences we are going to use.
statistics::similarityMatrix * similMatrix
Temporal Similarity Matrix.
argumentReport gap_threshold_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the gap threshold argument.
bool check_coding_sequences_type()
Method to check the type of sequences present in the backtranslationAlig.
Gaps * gaps
Gaps submodule.
Definition: Manager.h:59
int numberOfSequences
Number of sequences present on the alignment.
Definition: Alignment.h:70
int * sequencesLengths
Vector that contains the sequences lengths of each sequence in the backtranslation option...
bool check_backtranslation_infile_names_correspondence()
Method to check if the origAlig and backtranslationAlig are compatible in names to make the backtrans...
argumentReport clusters_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the clusters argument.
bool gappyout
Flag to use the gappyout trimming method.
Definition: trimalManager.h:78
char * forceFile
Forcefile to use in combination with multiple files comparison, to compare them against this...
argumentReport consistency_threshold_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the consistency threshold argument.
std::string getFileFormatName(const std::string &inFile)
Function to obtain the format name of a given file.
int gapWindow
Gap Window Size to use while trimming.
bool check_absolute_gap_theshold()
bool sfc
Flag to show the Sum of Pairs scores per column.
Definition: trimalManager.h:86
std::vector< Alignment * > splitAlignmentKeeping(const Alignment &alignment)
Function to divide an alignment into different alignments, each one with a sequence from the original...
bool nogaps
Flag to use the nogaps option.
Definition: trimalManager.h:76
bool check_clusters_incompatibilities()
Method to check clusters incompatibilities.
std::map< terminalColor, const std::string > colors
Definition: utils.cpp:965
argumentReport gappy_out_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the gappyout argument.
int getAlignmentType() const
Alignment type getter. See SequenceTypes.
Definition: Alignment.cpp:469
#define LegacyFormatArgumentWrapper(arg, format)
size_t argumentLength
Temp variable to use when there is a need to copy an argument to a char array.
int stats
Stats Flag to use in reporting. For each stat requested, this flag is decreased by one...
Alignment * cleanSpuriousSeq(float overlapColumn, float minimumOverlap, bool complementary)
Method to remove sequences missaligned with the rest of sequences in the alignment. For each residue in the sequence, it tests it&#39;s similarity. If the similarity of that residue is higher than overlapColumn value, it counts as a hit for the sequence. After calculating the number of hits for the sequence, it removes the sequence if it has a proportion hits/residues lower tan minimumOverlap.
Definition: Cleaner.cpp:934
void check_compareset_window_argument()
Method to check and warn if windowsize and compareset has been given.
void setKeepSequencesFlag(bool newFlagValue)
Keep Sequences setter.
Definition: Alignment.cpp:274
bool columnNumbering
Flag to return column numbering in report.
Definition: trimalManager.h:75
int * readNumbers(const std::string &line)
Reads a line and converts it to an array of number.
Definition: utils.cpp:624
std::string name
String that contains a well known acronym to the format.
void getSequences(std::string *names, int *lenghts)
Getter for the sequences names and its lenghts.
Definition: Alignment.cpp:424
void CleanResiduesAuto()
Method to trim the alignment using automatic or semi-automatic methods:
argumentReport stats_arguments(const int *argc, char *argv[], int *currentArg)
Method to parse stats arguments.
Utilities class. This class contains shared methods to be used in multiple parts of the code...
Definition: utils.h:50
int getNumAminos()
Residues number getter. It counts gaps as residue.
Definition: Alignment.cpp:252
#define VERSION
Definition: defines.h:34
argumentReport svg_stats_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the svg stats output file.
void CleanSequences()
Method to trim or reduce the number of sequences in an alignment. It performs one or none of the foll...
bool check_input_file_with_coding_sequences_argument()
Method to check dependency between custom coding sequence file and infile arguments.
1 << 3 = 8
Definition: defines.h:88
char * matrixFile
File that contains a user defined similarity matrix.
bool performCompareset()
Method to check if multiple files comparison has been set correctly. It also perform some calculation...
void computeComplementaryAlig(bool residues, bool sequences)
Method for computing the complementary alignment. Complementary alignment is an alignment containing...
Definition: Cleaner.cpp:1589
bool check_similarity_matrix()
Method to check if given a similarity matrix, there is a need to use it.
argumentReport keep_header_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the keepHeader argument.
bool sident
Flag to show identity scores in the alignment.
Definition: trimalManager.h:88
Alignment * cleanConservation(float baseLine, float conservationPct, bool complementary)
Method to trim an alignment based on the similarity distribution values.
Definition: Cleaner.cpp:760
InfoCode
Definition: reportsystem.h:291
Alignment * backtranslationAlig
Alignment used on the backtranslation functionality.
bool check_col_numbering()
Method to check if column numbering makes sense based on the functionality asked. ...
bool check_combinations_among_thresholds_incompatibility()
As some thresholds are incompatible between them, we check their incompatibilities.
Alignment * origAlig
Main alignment used/loaded on trimAl in combination with singleAlig.
argumentReport force_select_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the force select argument.
int i
Argument Iterator Variable.
bool check_output_file_with_statistics()
Method to check if there is an output file to allow statistics to be given on terminal.
argumentReport strict_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the strict argument.
bool check_select_cols_and_seqs_incompatibilities()
Method to check incompatibilities with select cols and select seqs arguments.
#define checkArgument(argument)
bool selectCols
Flag to select columns manually from the alignment.
Definition: trimalManager.h:91
argumentReport block_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the Block Size argument.
float consistencyThreshold
Consistency Threshold to use while trimming.
bool check_max_identity_incompatibilities()
Method to check max identity incompatibilities.
argumentReport no_gaps_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the nogaps argument.
void printSeqOverlap()
Prints the overlap between sequences.
Definition: Alignment.cpp:1001
1 << 4 = 16
Definition: defines.h:92
void ReplaceStringInPlace(std::string &subject, const std::string &search, const std::string &replace)
Function that replaces a substring with another substring in a string. It does not make a copy of the...
Definition: utils.cpp:810
float getCutPointClusters(int clusterNumber)
Method that calculates the optimal cut point for a given clusters number. The idea is to obtain a cu...
Definition: Cleaner.cpp:1068
bool alignmentSummarySVG(Alignment &trimmedAlig, const char *destFile, int blocks)
Method to report the trimming results in SVG. Outputs a SVG file that shows visually what has been do...
Definition: Alignment.cpp:1708
bool perform(char *comparesetFilePath, FormatHandling::FormatManager &formatManager, trimAlManager &manager, char *forceFile)
Method to compare a set of MSA, all containing the same sequences and residues. The number of residue...
Definition: Consistency.cpp:45
Alignment * cleanCompareFile(float cutpoint, float baseLine, float *vectValues, bool complementary)
Method to trim an alignment based on consistency values obtained from a dataset of alignments...
Definition: Cleaner.cpp:820
bool alignmentSummaryHTML(const Alignment &trimmedAlig, const char *const destFile)
Method to report the trimming results in HTML. Outputs an HTML file that shows visually what has been...
Definition: Alignment.cpp:1167
char ** filesToCompare
Vector containing the files to compare in trimAlManager::check_multiple_files_comparison function...
bool removeDuplicates
Definition: trimalManager.h:97
std::string getInputFormatsAvailable()
Function to obtain all format names available by this object that can load an alignment.
bool saveAlignment(const std::string &outPattern, const std::vector< std::string > &outFormats, Alignment &alignment)
Function to save an alignment to a file. It searches among the available_states one that can write th...
bool ignoreStopCodon
Flag to use the Ignore Stop Codon option.
Definition: trimalManager.h:95
bool ssc
Flag to show the Similarity Scores per column.
Definition: trimalManager.h:84
argumentReport conservation_threshold_argument(const int *argc, char *argv[], int *currentArg)
Method to parse the similarity threshold argument.
argumentReport min_coverage_argument(const int *argc, char *argv[], int *currentArg)
char * svgOutFile
File to output the svg report.
bool isNumber(char *num)
String-is-number checking.
Definition: utils.cpp:116
Consistency * consistency
Consistency submodule.
Definition: Manager.h:67
void printStatisticsGapsColumns()
Wrapper to Statistics::Gaps::printGapsColumns() It calls to calculateGapStats() to make sure the info...
Definition: Manager.cpp:118
float maxIdentity
Max Identity to use while trimming.
Alignment * clean2ndSlope(bool complementary)
Method that carries the gappyout approach. This methods calculates the slope in gaps distribution on ...
Definition: Cleaner.cpp:957
bool check_automated_methods_incompatibilities()
Method to check incompatibilities related to automated trimming methods.
int getNumSpecies()
Number of sequences getter.
Definition: Alignment.cpp:245
void check_thresholds_dependencies()
Main class of trimAl. It is strutured to work with 3 calls:
Definition: trimalManager.h:62
int * delColumns
Vector that contains the column indexes the user specified to be removed.
char * infile
File to load the alignment when only one alignment has trimming interest.
int parseArguments(int argc, char **argv)
Method to parse arguments into usable structure in trimal.
Alignment ** compareAlignmentsArray
Alignment Vector used on trimAlManager::check_multiple_files_comparison to compare them...
bool prepareCodingSequence(bool splitByStopCodon, bool ignoreStopCodon, Alignment *proteinAlignment)
Method to check if the CDS file is correct. Based on nature of residues: DNA/RNA (Most of the residue...
Definition: Alignment.cpp:528
#define BUILD
Definition: defines.h:33
bool sst
Flag to show the Accumulated Similarity Scores.
Definition: trimalManager.h:85
bool strictplus
Flag to use the strictplus trimming method.
Definition: trimalManager.h:80
bool create_or_use_similarity_matrix()
Method to create, load and use a similarity matrix, depending on alignment residue nature...
bool check_block_size()
Method to check if the block size is bigger than allowed depending on size of alignment.