/** * Constructor. * * @param exportFeatures the features to export in this section * @param indexes indicates whether the line index should be written * @param header indicates whether the table header should be written * @param writer the writer which will write to the file */ public PsPeptideSection( ArrayList<ExportFeature> exportFeatures, boolean indexes, boolean header, ExportWriter writer) { ArrayList<ExportFeature> psmFeatures = new ArrayList<ExportFeature>(); for (ExportFeature exportFeature : exportFeatures) { if (exportFeature instanceof PsPeptideFeature) { peptideFeatures.add((PsPeptideFeature) exportFeature); } else if (exportFeature instanceof PsPsmFeature || exportFeature instanceof PsIdentificationAlgorithmMatchesFeature || exportFeature instanceof PsFragmentFeature) { psmFeatures.add(exportFeature); } else { throw new IllegalArgumentException( "Export feature of type " + exportFeature.getClass() + " not recognized."); } } Collections.sort(peptideFeatures); if (!psmFeatures.isEmpty()) { psmSection = new PsPsmSection(psmFeatures, indexes, header, writer); } this.indexes = indexes; this.header = header; this.writer = writer; }
/** * Writes the title of the section. * * @throws IOException exception thrown whenever an error occurred while writing the file */ public void writeHeader() throws IOException { if (indexes) { writer.writeHeaderText(""); writer.addSeparator(); } boolean firstColumn = true; for (ExportFeature exportFeature : peptideFeatures) { if (firstColumn) { firstColumn = false; } else { writer.addSeparator(); } writer.writeHeaderText(exportFeature.getTitle()); } writer.newLine(); }