public static void setCDSTranslationReport(ExtendedResult<CdsFeatureTranslationCheck.TranslationReportInfo> cdsCheckResult) {

        try {
            CdsFeatureTranslationCheck.TranslationReportInfo translationInfo = cdsCheckResult.getExtension();
            StringWriter translationReportWriter = new StringWriter();

            TranslationResult translationResult = translationInfo.getTranslationResult();
            CdsFeature cdsFeature = translationInfo.getCdsFeature();

            if (translationResult != null && cdsFeature != null) {
                String providedTranslation = cdsFeature.getTranslation();

                new TranslationResultWriter(translationResult, providedTranslation).write(translationReportWriter);
                String translationReport = translationReportWriter.toString();
                StringWriter reportString = new StringWriter();
                reportString.append("The results of the automatic translation are shown below.\n\n");
                CompoundLocation<Location> compoundLocation = translationInfo.getCdsFeature().getLocations();
                reportString.append("Feature location : ");
                reportString.append(FeatureLocationWriter.renderCompoundLocation(compoundLocation)).append("\n");
                reportString.append("Base count : ").append(Integer.toString(translationResult.getBaseCount()))
                        .append("\n");
                reportString.append("Translation length : ")
                        .append(Integer.toString(translationResult.getTranslation().length())).append("\n\n");

                reportString.append("Translation table info : ");
                TranslationTable translationTable = translationInfo.getTranslationTable();
                String translationTableName = "NOT SET";
                String translationTableNumber = "NOT SET";

                if (translationTable != null) {
                    translationTableName = translationTable.getName();
                    translationTableNumber = Integer.toString(translationTable.getNumber());
                }

                reportString.append("Table name - \"").append(translationTableName).append("\" ");
                reportString.append("Table number - \"").append(translationTableNumber).append("\"\n\n");

                if (translationReport != null && !translationReport.isEmpty()) {
                    reportString.append("The amino acid codes immediately below the dna triplets is the actual " +
                            "translation based on the information you provided.");

                    List<Qualifier> providedtranslations =
                            translationInfo.getCdsFeature().getQualifiers(Qualifier.TRANSLATION_QUALIFIER_NAME);
                    if (!providedtranslations.isEmpty()) {
                        reportString
                                .append("\nThe second row of amino acid codes is the translation you provided in the CDS " +
                                        "feature. These translations should match.");
                    }

                    reportString.append("\n\n");
                    reportString.append(translationReport);
                } else {
                    reportString.append("No translation made\n\n");
                }

                /**
                 * set in all messages and the validation result - used differently in webapp to the command line tool
                 */
                cdsCheckResult.setReportMessage(reportString.toString());
                for (ValidationMessage message : cdsCheckResult.getMessages()) {
                    message.setReportMessage(reportString.toString());
                }
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
public static void setCDSTranslationReport ( ExtendedResult < CdsFeatureTranslationCheck . TranslationReportInfo > cdsCheckResult ) { try { CdsFeatureTranslationCheck . TranslationReportInfo translationInfo = cdsCheckResult . getExtension ( ) ; StringWriter translationReportWriter = new StringWriter ( ) ; TranslationResult translationResult = translationInfo . getTranslationResult ( ) ; CdsFeature cdsFeature = translationInfo . getCdsFeature ( ) ; if ( translationResult != null && cdsFeature != null ) { String providedTranslation = cdsFeature . getTranslation ( ) ; new TranslationResultWriter ( translationResult , providedTranslation ) . write ( translationReportWriter ) ; String translationReport = translationReportWriter . toString ( ) ; StringWriter reportString = new StringWriter ( ) ; reportString . append ( "The results of the automatic translation are shown below.\n\n" ) ; CompoundLocation < Location > compoundLocation = translationInfo . getCdsFeature ( ) . getLocations ( ) ; reportString . append ( "Feature location : " ) ; reportString . append ( FeatureLocationWriter . renderCompoundLocation ( compoundLocation ) ) . append ( "\n" ) ; reportString . append ( "Base count : " ) . append ( Integer . toString ( translationResult . getBaseCount ( ) ) ) . append ( "\n" ) ; reportString . append ( "Translation length : " ) . append ( Integer . toString ( translationResult . getTranslation ( ) . length ( ) ) ) . append ( "\n\n" ) ; reportString . append ( "Translation table info : " ) ; TranslationTable translationTable = translationInfo . getTranslationTable ( ) ; String translationTableName = "NOT SET" ; String translationTableNumber = "NOT SET" ; if ( translationTable != null ) { translationTableName = translationTable . getName ( ) ; translationTableNumber = Integer . toString ( translationTable . getNumber ( ) ) ; } reportString . append ( "Table name - \"" ) . append ( translationTableName ) . append ( "\" " ) ; reportString . append ( "Table number - \"" ) . append ( translationTableNumber ) . append ( "\"\n\n" ) ; if ( translationReport != null && ! translationReport . isEmpty ( ) ) { reportString . append ( "The amino acid codes immediately below the dna triplets is the actual " + "translation based on the information you provided." ) ; List < Qualifier > providedtranslations = translationInfo . getCdsFeature ( ) . getQualifiers ( Qualifier . TRANSLATION_QUALIFIER_NAME ) ; if ( ! providedtranslations . isEmpty ( ) ) { reportString . append ( "\nThe second row of amino acid codes is the translation you provided in the CDS " + "feature. These translations should match." ) ; } reportString . append ( "\n\n" ) ; reportString . append ( translationReport ) ; } else { reportString . append ( "No translation made\n\n" ) ; } cdsCheckResult . setReportMessage ( reportString . toString ( ) ) ; for ( ValidationMessage message : cdsCheckResult . getMessages ( ) ) { message . setReportMessage ( reportString . toString ( ) ) ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Takes all the messages in a CdsFeatureTranslationCheck ExtendedResult ValidationResult object and writes a
report for the CDS translation. Uses extra information from the ExtendedResult. Have put this here as it uses
Writers from the FF package and the embl-api-core package does not have access to these.

@param cdsCheckResult