public static void main(String[] args) {
		Configuration config = readArgs(args);
		String[][] pairs = FileUtils.readPairs(config.pairs);
		HashMap<String, Sequence> seqLib = FileUtils.readSeqLib(config.seqlib);
		Substitutionmatrix matrix = FileUtils.readSubstitutionMatrix(config.matrix);

		StringBuilder falseAlignments = new StringBuilder();
                StringBuilder output = new StringBuilder();
		for (String[] pair : pairs) {
			Sequence seq1 = seqLib.get(pair[0]);
			Sequence seq2 = seqLib.get(pair[1]);
			Gotoh gotoh;
                        String formatString = "%2." + (int) Math.log10((double) matrix.multiplicationFactor) + "f";
			if (config.mode.equals("global")) {
				gotoh = new GlobalGotoh(seq1, seq2, matrix, config.gapOpen, config.gapExtend, config.multiplicationFactor);
			} else if (config.mode.equals("local")) {
				gotoh = new LocalGotoh(seq1, seq2, matrix, config.gapOpen, config.gapExtend, config.multiplicationFactor);
			} else {
				gotoh = new FreeshiftGotoh(seq1, seq2, matrix, config.gapOpen, config.gapExtend, config.multiplicationFactor);
			}
			Alignment ali = gotoh.runAlignment();
			output.append('>');
			output.append(seq1.getID());
                        output.append(' ');
                        output.append(seq2.getID());
                        output.append(' ');
                        output.append(String.format(Locale.US, formatString, ali.maxScore));
                        output.append('\n');


                        if (config.printali) {
				gotoh.backtrack(ali);
                                output.append(gotoh.seq1.getID());
                                output.append(": ");
                                output.append(ali.aliSeq1);
                                output.append('\n');
                                output.append(gotoh.seq2.getID());
                                output.append(": ");
                                output.append(ali.aliSeq2);
                                output.append('\n');
			}
			if (config.check) {
				double checkScore = gotoh.checkScore(ali);
				if (checkScore - ali.maxScore > 0.01) {
					falseAlignments.append(">").append(gotoh.seq1.getID()).append(":").append(gotoh.seq2.getID()).append(" ").append(ali.maxScore).append(" ").append(checkScore).append("\n");
					falseAlignments.append(ali.aliSeq1).append("\n");
					falseAlignments.append(ali.aliSeq2).append("\n");
					falseAlignments.append("\n");
				}
			}
                    switch (config.printmatrices) {
                        case "txt":
                            output.append("MATRIX A");
                            output.append(printMatrix(gotoh.matrixA));
                            output.append('\n');
                            output.append("MATRIX I");
                            output.append(printMatrix(gotoh.matrixI));
                            output.append('\n');
                            output.append("MATRIX D");
                            output.append(printMatrix(gotoh.matrixD));
                            output.append('\n');
                            break;
                        case "html":
                            output.append("<html><pre>");
                            output.append("MATRIX A");
                            output.append(printMatrix(gotoh.matrixA));
                            output.append('\n');
                            output.append("MATRIX I");
                            output.append(printMatrix(gotoh.matrixI));
                            output.append('\n');
                            output.append("MATRIX D");
                            output.append(printMatrix(gotoh.matrixD));
                            output.append('\n');
                            output.append("</pre></html>");
                            break;
                    }
		}
		if (!(falseAlignments.length() == 0)) {
			FileUtils.writeFalseAlignments("gotoh_out_false_alignments.txt", falseAlignments.toString());
		}
                System.out.println(output);
	}