public PositionMapping(MZTabColumnFactory factory, String[] headerList) { String header; for (int physicalPosition = 0; physicalPosition < headerList.length; physicalPosition++) { header = headerList[physicalPosition]; MZTabColumn column = factory.findColumnByHeader(header); if (column != null) { put(physicalPosition, column.getLogicPosition()); } } }
/** * Based on {@link #section} to generate stable columns, and store them into {@link * #stableColumnMapping} and {@link #columnMapping} which maintain all columns in the factory. * * @param section SHOULD be {@link Section#Protein_Header}, {@link Section#Peptide_Header} {@link * Section#PSM_Header} or {@link Section#Small_Molecule_Header}. */ public static MZTabColumnFactory getInstance(Section section) { section = Section.toHeaderSection(section); if (section == null) { throw new IllegalArgumentException( "Section should use Protein_Header, Peptide_Header, PSM_Header or Small_Molecule_Header."); } MZTabColumnFactory factory = new MZTabColumnFactory(); switch (section) { case Protein_Header: addStableColumn(factory, ProteinColumn.ACCESSION); addStableColumn(factory, ProteinColumn.DESCRIPTION); addStableColumn(factory, ProteinColumn.TAXID); addStableColumn(factory, ProteinColumn.SPECIES); addStableColumn(factory, ProteinColumn.DATABASE); addStableColumn(factory, ProteinColumn.DATABASE_VERSION); addStableColumn(factory, ProteinColumn.SEARCH_ENGINE); addStableColumn(factory, ProteinColumn.AMBIGUITY_MEMBERS); addStableColumn(factory, ProteinColumn.MODIFICATIONS); addStableColumn(factory, ProteinColumn.PROTEIN_COVERAGE); break; case Peptide_Header: addStableColumn(factory, PeptideColumn.SEQUENCE); addStableColumn(factory, PeptideColumn.ACCESSION); addStableColumn(factory, PeptideColumn.UNIQUE); addStableColumn(factory, PeptideColumn.DATABASE); addStableColumn(factory, PeptideColumn.DATABASE_VERSION); addStableColumn(factory, PeptideColumn.SEARCH_ENGINE); addStableColumn(factory, PeptideColumn.MODIFICATIONS); addStableColumn(factory, PeptideColumn.RETENTION_TIME); addStableColumn(factory, PeptideColumn.RETENTION_TIME_WINDOW); addStableColumn(factory, PeptideColumn.CHARGE); addStableColumn(factory, PeptideColumn.MASS_TO_CHARGE); addStableColumn(factory, PeptideColumn.SPECTRA_REF); break; case PSM_Header: addStableColumn(factory, PSMColumn.SEQUENCE); addStableColumn(factory, PSMColumn.PSM_ID); addStableColumn(factory, PSMColumn.ACCESSION); addStableColumn(factory, PSMColumn.UNIQUE); addStableColumn(factory, PSMColumn.DATABASE); addStableColumn(factory, PSMColumn.DATABASE_VERSION); addStableColumn(factory, PSMColumn.SEARCH_ENGINE); addStableColumn(factory, PSMColumn.MODIFICATIONS); addStableColumn(factory, PSMColumn.RETENTION_TIME); addStableColumn(factory, PSMColumn.CHARGE); addStableColumn(factory, PSMColumn.EXP_MASS_TO_CHARGE); addStableColumn(factory, PSMColumn.CALC_MASS_TO_CHARGE); addStableColumn(factory, PSMColumn.SPECTRA_REF); addStableColumn(factory, PSMColumn.PRE); addStableColumn(factory, PSMColumn.POST); addStableColumn(factory, PSMColumn.START); addStableColumn(factory, PSMColumn.END); break; case Small_Molecule_Header: addStableColumn(factory, SmallMoleculeColumn.IDENTIFIER); addStableColumn(factory, SmallMoleculeColumn.CHEMICAL_FORMULA); addStableColumn(factory, SmallMoleculeColumn.SMILES); addStableColumn(factory, SmallMoleculeColumn.INCHI_KEY); addStableColumn(factory, SmallMoleculeColumn.DESCRIPTION); addStableColumn(factory, SmallMoleculeColumn.EXP_MASS_TO_CHARGE); addStableColumn(factory, SmallMoleculeColumn.CALC_MASS_TO_CHARGE); addStableColumn(factory, SmallMoleculeColumn.CHARGE); addStableColumn(factory, SmallMoleculeColumn.RETENTION_TIME); addStableColumn(factory, SmallMoleculeColumn.TAXID); addStableColumn(factory, SmallMoleculeColumn.SPECIES); addStableColumn(factory, SmallMoleculeColumn.DATABASE); addStableColumn(factory, SmallMoleculeColumn.DATABASE_VERSION); addStableColumn(factory, SmallMoleculeColumn.SPECTRA_REF); addStableColumn(factory, SmallMoleculeColumn.SEARCH_ENGINE); addStableColumn(factory, SmallMoleculeColumn.MODIFICATIONS); break; default: throw new IllegalArgumentException("Can not use Comment, Metadata section."); } factory.columnMapping.putAll(factory.stableColumnMapping); factory.section = section; return factory; }
@Test public void testUnique() throws Exception { pepParser.checkUnique(pehFactory.findColumnByHeader("unique"), "x"); assertError(FormatErrorType.MZBoolean); }