public string[] this[MzTabSection section, int index] { get { return(GetData(section, index)); } }
public string this[MzTabSection section, int index, string columnName] { get { return(GetData(section, index, columnName)); } }
public string[] GetColumns(MzTabSection section) { switch (section) { case MzTabSection.PSM: return(_psmDataTable != null?_psmDataTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray() : null); case MzTabSection.Peptide: return(_peptideDataTable != null?_peptideDataTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray() : null); case MzTabSection.Protein: return(_proteinDataTable != null?_proteinDataTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray() : null); case MzTabSection.SmallMolecule: return(_smallMoleculeDataTable != null?_smallMoleculeDataTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray() : null); default: return(null); } }
public string[] GetData(MzTabSection section, int index) { switch (section) { case MzTabSection.PSM: return(_psmDataTable != null ? (string[])_psmDataTable.Rows[index].ItemArray : null); case MzTabSection.Peptide: return(_peptideDataTable != null ? (string[])_peptideDataTable.Rows[index].ItemArray : null); case MzTabSection.Protein: return(_proteinDataTable != null ? (string[])_proteinDataTable.Rows[index].ItemArray : null); case MzTabSection.SmallMolecule: return(_smallMoleculeDataTable != null ? (string[])_smallMoleculeDataTable.Rows[index].ItemArray : null); default: return(null); } }
public string GetData(MzTabSection section, int index, string columnName) { switch (section) { case MzTabSection.PSM: return(_psmDataTable != null ? (string)_psmDataTable.Rows[index][columnName] : null); case MzTabSection.Peptide: return(_peptideDataTable != null ? (string)_peptideDataTable.Rows[index][columnName] : null); case MzTabSection.Protein: return(_proteinDataTable != null ? (string)_proteinDataTable.Rows[index][columnName] : null); case MzTabSection.SmallMolecule: return(_smallMoleculeDataTable != null ? (string)_smallMoleculeDataTable.Rows[index][columnName] : null); default: return(null); } }
public bool ContainsColumn(MzTabSection section, string columnName) { switch (section) { case MzTabSection.PSM: return(_psmDataTable != null && _psmDataTable.Columns.Contains(columnName)); case MzTabSection.Peptide: return(_peptideDataTable != null && _peptideDataTable.Columns.Contains(columnName)); case MzTabSection.Protein: return(_proteinDataTable != null && _proteinDataTable.Columns.Contains(columnName)); case MzTabSection.SmallMolecule: return(_smallMoleculeDataTable != null && _smallMoleculeDataTable.Columns.Contains(columnName)); default: return(false); } }
private IEnumerable <T> GetObjects <T>(MzTabSection section) where T : MzTabEntity, new() { DataTable table = null; switch (section) { case MzTabSection.PSM: table = _psmDataTable; break; case MzTabSection.Peptide: table = _peptideDataTable; break; case MzTabSection.SmallMolecule: table = _smallMoleculeDataTable; break; case MzTabSection.Protein: table = _proteinDataTable; break; } if (table == null || table.Rows.Count == 0) { yield break; } string[] columns = GetColumns(section); int count = columns.Length; foreach (DataRow row in table.Rows) { var item = new T(); for (int i = 0; i < count; i++) { item.SetValue(columns[i], (string)row.ItemArray[i]); } yield return(item); } }
private void WriteData <T>(MzTabSection section, IEnumerable <T> data, bool includeCommentLine = false) where T : MzTabEntity { if ((_currentState & MzTab.States.MetaData) != MzTab.States.MetaData) { throw new ArgumentException("Unable to write the " + section + " section, incorrect location. The Meta Data section must come first."); } List <T> objects = data.ToList(); if (objects.Count == 0) { return; } MzTab.LinePrefix headerPrefix = MzTab.LinePrefix.Comment; MzTab.LinePrefix prefix = MzTab.LinePrefix.Comment; switch (section) { case MzTabSection.SmallMolecule: headerPrefix = MzTab.LinePrefix.SmallMoleculeTable; prefix = MzTab.LinePrefix.SmallMoleculeData; _currentState |= MzTab.States.SmallMoleculeData; _currentState |= MzTab.States.SmallMoleculeHeader; break; case MzTabSection.Peptide: headerPrefix = MzTab.LinePrefix.PeptideTable; prefix = MzTab.LinePrefix.PeptideData; _currentState |= MzTab.States.PeptideData; _currentState |= MzTab.States.PeptideHeader; break; case MzTabSection.PSM: headerPrefix = MzTab.LinePrefix.PsmTable; prefix = MzTab.LinePrefix.PsmData; _currentState |= MzTab.States.PsmData; _currentState |= MzTab.States.PsmHeader; break; case MzTabSection.Protein: headerPrefix = MzTab.LinePrefix.ProteinTable; prefix = MzTab.LinePrefix.ProteinData; _currentState |= MzTab.States.ProteinData; _currentState |= MzTab.States.ProteinHeader; break; } // Write Header string[] header = MzTabEntity.GetHeader(objects).ToArray(); WriteLine(headerPrefix, header); if (includeCommentLine) { WriteComment(string.Join("\t", header)); } // Write table foreach (string[] values in objects.Select(datum => datum.GetStringValues(header).ToArray())) { WriteLine(prefix, values); } }