Search in sources :

Example 1 with PsAnnotationFeature

use of com.compomics.util.io.export.features.peptideshaker.PsAnnotationFeature in project peptide-shaker by compomics.

the class PsAnnotationSection method writeSection.

/**
 * Writes the desired section.
 *
 * @param annotationPreferences the annotation preferences of the project
 * @param waitingHandler the waiting handler
 *
 * @throws IOException exception thrown whenever an error occurred while
 * writing the file.
 */
public void writeSection(AnnotationParameters annotationPreferences, WaitingHandler waitingHandler) throws IOException {
    if (waitingHandler != null) {
        waitingHandler.setSecondaryProgressCounterIndeterminate(true);
    }
    if (header) {
        if (indexes) {
            writer.writeHeaderText("");
            writer.addSeparator();
        }
        writer.writeHeaderText("Parameter");
        writer.addSeparator();
        writer.writeHeaderText("Value");
        writer.newLine();
    }
    int line = 1;
    for (ExportFeature exportFeature : annotationFeatures) {
        if (indexes) {
            writer.write(Integer.toString(line));
            writer.addSeparator();
        }
        writer.write(exportFeature.getTitle());
        writer.addSeparator();
        PsAnnotationFeature annotationFeature = (PsAnnotationFeature) exportFeature;
        switch(annotationFeature) {
            case automatic_annotation:
                if (annotationPreferences.isAutomaticAnnotation()) {
                    writer.write("Yes");
                } else {
                    writer.write("No");
                }
                break;
            case fragment_ion_accuracy:
                writer.write(Double.toString(annotationPreferences.getFragmentIonAccuracy()));
                break;
            case intensity_limit:
                writer.write(Double.toString(annotationPreferences.getAnnotationIntensityLimit()));
                break;
            case neutral_losses:
                String neutralLosses = annotationPreferences.getNeutralLosses().stream().map(neutralLoss -> neutralLoss.name).collect(Collectors.joining(", "));
                writer.write(neutralLosses);
                break;
            case neutral_losses_sequence_dependence:
                String value = annotationPreferences.areNeutralLossesSequenceAuto() ? "Yes" : "No";
                writer.write(value);
                break;
            case selected_ions:
                String ions = annotationPreferences.getFragmentIonTypes().stream().map(fragmentType -> PeptideFragmentIon.getSubTypeAsString(fragmentType)).collect(Collectors.joining(", "));
                writer.write(ions);
                break;
            default:
                writer.write("Not implemented");
        }
        writer.newLine();
        line++;
    }
}
Also used : WaitingHandler(com.compomics.util.waiting.WaitingHandler) ExportWriter(com.compomics.util.io.export.ExportWriter) PeptideFragmentIon(com.compomics.util.experiment.biology.ions.impl.PeptideFragmentIon) ExportFeature(com.compomics.util.io.export.ExportFeature) PsAnnotationFeature(com.compomics.util.io.export.features.peptideshaker.PsAnnotationFeature) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) AnnotationParameters(com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters) EnumSet(java.util.EnumSet) ArrayList(java.util.ArrayList) ExportFeature(com.compomics.util.io.export.ExportFeature) PsAnnotationFeature(com.compomics.util.io.export.features.peptideshaker.PsAnnotationFeature)

Aggregations

PeptideFragmentIon (com.compomics.util.experiment.biology.ions.impl.PeptideFragmentIon)1 AnnotationParameters (com.compomics.util.experiment.identification.spectrum_annotation.AnnotationParameters)1 ExportFeature (com.compomics.util.io.export.ExportFeature)1 ExportWriter (com.compomics.util.io.export.ExportWriter)1 PsAnnotationFeature (com.compomics.util.io.export.features.peptideshaker.PsAnnotationFeature)1 WaitingHandler (com.compomics.util.waiting.WaitingHandler)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 Collectors (java.util.stream.Collectors)1