protected void saveConsensus() {
        if (Globals.REFINE || Globals.CONSENSUS) {
            StringBuilder sb = new StringBuilder();
            sb.append(">CONSENSUS\n");

            Map<String, String> wobbles = new HashMap<>();
            wobbles.put("A", "A");
            wobbles.put("C", "C");
            wobbles.put("G", "G");
            wobbles.put("T", "T");
            wobbles.put("T", "T");
            wobbles.put("GT", "K");
            wobbles.put("AC", "M");
            wobbles.put("AG", "R");
            wobbles.put("CT", "Y");
            wobbles.put("CG", "S");
            wobbles.put("AT", "W");
            wobbles.put("CGT", "B");
            wobbles.put("ACG", "V");
            wobbles.put("ACT", "H");
            wobbles.put("AGT", "D");
            wobbles.put("ACGT", "N");
            wobbles.put("-", "N");
            wobbles.put("", "N");

            for (int L = alignment.length, j = 0; j < L; j++) {
                int max = -1;
                double sum = 0;
                int index = -1;
                for (int v = 0; v < 6; v++) {
                    sum += alignment[j][v];
                    if (alignment[j][v] > max) {
                        max = alignment[j][v];
                        index = v;
                    }
                }

                if (max >= Globals.MIN_CONS_COV) {
                    if (alignment[j][4] / sum > Globals.PLURALITY_N) {
                        sb.append("N");
                    } else {
                        sum -= alignment[j][4];
                        StringBuilder w_sb = new StringBuilder();
                        for (int v = 0; v < 4; v++) {
                            if (alignment[j][v] / sum > Globals.PLURALITY) {
                                w_sb.append(Utils.reverse(v));
                            }
                        }
                        sb.append(wobbles.get(w_sb.toString()));
                    }
                } else {
                    sb.append(Globals.GENOMES[0].getSequence().charAt(j));
                }
            }

            sb.append("\n");
            Utils.saveFile(Globals.output + "consensus.fasta", sb.toString());
        }
    }