public PositionMapping(MZTabColumnFactory factory, string[] headerList) { for (int physicalPosition = 0; physicalPosition < headerList.Length; physicalPosition++){ string header = headerList[physicalPosition]; MZTabColumn column = factory.FindColumnByHeader(header); if (column != null){ put(physicalPosition, column.LogicPosition); } } }
/** * Parse a header line into {@link MZTabColumnFactory} structure. * * @param factory SHOULD NOT set null * @param metadata SHOULD NOT set null */ protected MZTabHeaderLineParser(MZTabColumnFactory factory, Metadata metadata) { if (factory == null){ throw new NullReferenceException("Header line should be parse first!"); } this.factory = factory; if (metadata == null){ throw new NullReferenceException("Metadata should be create first!"); } this.metadata = metadata; }
/** * Based on factory, navigate colUnitMap<defineLabel, valueLabel> * and refine colunit columns are correct or not. * * Notice: after refined phase, colunit definition can be record in the metadata. */ public void refineColUnit(MZTabColumnFactory factory) { foreach (string defineLabel in _colUnitMap.Keys){ if (defineLabel.Equals("colunit-" + Section.toDataSection(factory.Section).Name, StringComparison.InvariantCultureIgnoreCase)){ string valueLabel = _colUnitMap[defineLabel]; MZTabError error = checkColUnit(valueLabel, factory); if (error != null){ throw new MZTabException(error); } } } }
/** * Generate a mzTab data line parser. A couple of common method used to parse a data line into * {@link MZTabRecord} structure. * * NOTICE: {@link MZTabColumnFactory} maintain a couple of {@link MZTabColumn} which have internal logical * position and order. In physical mzTab file, we allow user not obey this logical position organized way, * and provide their date with own order. In order to distinguish them, we use physical position (a positive * integer) to record the column location in mzTab file. And use {@link PositionMapping} structure the maintain * the mapping between them. * * @param factory SHOULD NOT set null * @param positionMapping SHOULD NOT set null * @param metadata SHOULD NOT set null */ protected MZTabDataLineParser(MZTabColumnFactory factory, PositionMapping positionMapping, Metadata metadata, MZTabErrorList errorList) { if (factory == null){ throw new NullReferenceException("Column header factory should be create first."); } this.factory = factory; this.positionMapping = positionMapping; exchangeMapping = positionMapping.exchange(); mapping = factory.GetOffsetColumnsMap(); if (metadata == null){ throw new NullReferenceException("Metadata should be parser first."); } this.metadata = metadata; _errorList = errorList ?? new MZTabErrorList(); }
public SmallMolecule(MZTabColumnFactory factory, Metadata metadata) : base(factory) { this.metadata = metadata; }
public Peptide(MZTabColumnFactory factory, Metadata metadata) : base(factory) { this.metadata = metadata; }
/** * Set the Small Molecule header line column factory. * * @param smallMoleculeColumnFactory if null, system will ignore Small Molecule table output. */ public void setSmallMoleculeColumnFactory(MZTabColumnFactory smallMoleculeColumnFactory) { _smallMoleculeColumnFactory = smallMoleculeColumnFactory; }
/** * Set the PSM header line column factory. * * @param psmColumnFactory if null, system will ignore PSM table output. */ public void setPSMColumnFactory(MZTabColumnFactory psmColumnFactory) { _psmColumnFactory = psmColumnFactory; }
/** * Set the Protein header line column factory. * * @param proteinColumnFactory if null, system will ignore Protein table output. */ public void setProteinColumnFactory(MZTabColumnFactory proteinColumnFactory) { _proteinColumnFactory = proteinColumnFactory; }
/** * Set the Peptide header line column factory. * * @param peptideColumnFactory if null, system will ignore Peptide table output. */ public void setPeptideColumnFactory(MZTabColumnFactory peptideColumnFactory) { _peptideColumnFactory = peptideColumnFactory; }
public PositionMapping(MZTabColumnFactory factory, string headerLine) : this(factory, headerLine.Split('\t')) { }
protected void AddOptionalColumns(MZTabColumnFactory factory, List<MZTabColumn> columns, string elementName) { Regex regex = new Regex(String.Format(@"(opt)_{0}\[[0-9]+\]_(.*)", elementName)); IList<string> names = columns.Select(x => x.Name).ToList(); foreach (MZTabColumn col in factory.OptionalColumnMapping.Values) { if (regex.IsMatch(col.Name)) { var match = regex.Match(col.Name); string name = String.Format("{0}_{1}", match.Groups[1].Value, match.Groups[2].Value); if (names.Contains(name)) { continue; } names.Add(name); columns.Add(new MZTabColumn(name, col.Type, col.isOptional(), col.Order)); } } }
private static void AddStableColumn(MZTabColumnFactory factory, MZTabColumn column) { factory.stableColumnMapping.Add(column.LogicPosition, column); }
/** * 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 ArgumentException( "Section should use Protein_Header, Peptide_Header, PSM_Header or Small_Molecule_Header."); } MZTabColumnFactory factory = new MZTabColumnFactory(); if (section.Equals(Section.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); } else if (section.Equals(Section.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); } else if (section.Equals(Section.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); } else if (section.Equals(Section.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.BEST_SEARCH_ENGINE_SCORE); AddStableColumn(factory, SmallMoleculeColumn.MODIFICATIONS); } else{ throw new NotImplementedException("Section should be Protein, Peptide or " + "Small_Molecule. Others can not setting. "); } foreach (var column in factory.StableColumnMapping){ factory.ColumnMapping.Add(column.Key, column.Value); } factory.section = section; return factory; }
/** * valueLabel pattern like: column_name=param_string */ private MZTabError checkColUnit(string valueLabel, MZTabColumnFactory factory) { string[] items = valueLabel.Split('='); string columnName = items[0].Trim(); string value = items[1].Trim(); MZTabColumn column = factory.FindColumnByHeader(columnName); if (column == null){ // column_name not exists in the factory. return new MZTabError(FormatErrorType.ColUnit, _lineNumber, valueLabel, columnName); } Param param = MZTabUtils.ParseParam(value); if (param == null){ return new MZTabError(FormatErrorType.Param, _lineNumber, valueLabel, value); } if (factory.Section.Equals(Section.Protein_Header)){ _metadata.AddProteinColUnit(column, param); } else if (factory.Section.Equals(Section.Peptide_Header)){ _metadata.AddPeptideColUnit(column, param); } else if (factory.Section.Equals(Section.PSM_Header)){ _metadata.AddPSMColUnit(column, param); } else if (factory.Section.Equals(Section.Small_Molecule_Header)){ _metadata.AddSmallMoleculeColUnit(column, param); } return null; }
public PSMLineParser(MZTabColumnFactory factory, PositionMapping positionMapping, Metadata metadata, MZTabErrorList errorList) : base(factory, positionMapping, metadata, errorList) { }
public Protein(MZTabColumnFactory factory) : base(factory) { }