Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/MSDIAL5/MsdialCore/Export/SpectraExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -415,22 +415,26 @@ private static void WriteChromPeakFeatureInfoAsSdf(
{
WriteSdfDataItem(sb, "NAME", string.IsNullOrWhiteSpace(spotProperty.Name)? "Unknown": spotProperty.Name);
WriteSdfDataItem(sb, "SCANS", spotProperty.MasterAlignmentID.ToString());
WriteSdfDataItem(sb, "PRECURSOR MZ", Math.Round(spotProperty.MassCenter,5).ToString());
WriteSdfDataItem(sb, "PRECURSOR M/Z", Math.Round(spotProperty.MassCenter, 5).ToString());
WriteSdfDataItem(sb, "ION MODE", spotProperty.IonMode.ToString());

if (spotProperty.IsMsmsAssigned)
{
if (spotProperty.AdductType != null) WriteSdfDataItem(sb, "PRECURSOR TYPE", spotProperty.AdductType.AdductIonName);
if (!string.IsNullOrWhiteSpace(spotProperty.Formula.FormulaString)) WriteSdfDataItem(sb, "FORMULA", spotProperty.Formula.FormulaString);
if (!string.IsNullOrWhiteSpace(spotProperty.InChIKey)) WriteSdfDataItem(sb, "FORMULA", spotProperty.InChIKey);
if (!string.IsNullOrWhiteSpace(spotProperty.SMILES)) WriteSdfDataItem(sb, "FORMULA", spotProperty.SMILES);
if (spotProperty.Formula.Mass > 0d) WriteSdfDataItem(sb, "EXACT MASS", Math.Round(spotProperty.Formula.Mass, 5).ToString());
if (!string.IsNullOrWhiteSpace(spotProperty.InChIKey)) WriteSdfDataItem(sb, "INCHIKEY", spotProperty.InChIKey);
if (!string.IsNullOrWhiteSpace(spotProperty.SMILES)) WriteSdfDataItem(sb, "SMILES", spotProperty.SMILES);
if (spotProperty.TimesCenter != null && spotProperty.TimesCenter.RT != null && spotProperty.TimesCenter.RT.Value >= 0)
WriteSdfDataItem(sb, "RETENTION TIME", Math.Round(spotProperty.TimesCenter.RT.Value, 3).ToString());
if (!string.IsNullOrWhiteSpace(spotProperty.Ontology)) WriteSdfDataItem(sb, "ONTOLOGY", spotProperty.Ontology);
WriteSdfDataItem(sb, "MS LEVEL", "MS2");
var peaks = spectrum.Where(spec => spec.Intensity > 0).ToList();
WriteSdfDataItem(sb, "NUM PEAKS", peaks.Count.ToString());
var peaksText = string.Join(
"\n",
spectrum.Select(p =>
$"{Math.Round(p.Mass, 5)} {Math.Round(p.Intensity,0)}"
$"{Math.Round(p.Mass, 4)} {Math.Round(p.Intensity,0)}"
Comment thread
mikikot113 marked this conversation as resolved.
)
);
WriteSdfDataItem(sb, "MASS SPECTRAL PEAKS", peaksText);
Expand All @@ -443,15 +447,18 @@ private static void WriteChromPeakFeatureInfoAsSdf(
{
WriteSdfDataItem(sb, "NAME", string.IsNullOrWhiteSpace(spotProperty.Name) ? "Unknown" : spotProperty.Name);
WriteSdfDataItem(sb, "SCANS", spotProperty.PeakID.ToString());
WriteSdfDataItem(sb, "PRECURSOR MZ", Math.Round(spotProperty.PrecursorMz, 5).ToString());
WriteSdfDataItem(sb, "PRECURSOR M/Z", Math.Round(spotProperty.PrecursorMz, 5).ToString());
WriteSdfDataItem(sb, "ION MODE", spotProperty.IonMode.ToString());

if (spotProperty.IsMsmsContained)
{
if (spotProperty.AdductType != null) WriteSdfDataItem(sb, "PRECURSOR TYPE", spotProperty.AdductType.AdductIonName);
if (!string.IsNullOrWhiteSpace(spotProperty.Formula.FormulaString)) WriteSdfDataItem(sb, "FORMULA", spotProperty.Formula.FormulaString);
if (!string.IsNullOrWhiteSpace(spotProperty.InChIKey)) WriteSdfDataItem(sb, "FORMULA", spotProperty.InChIKey);
if (!string.IsNullOrWhiteSpace(spotProperty.SMILES)) WriteSdfDataItem(sb, "FORMULA", spotProperty.SMILES);
if (!string.IsNullOrWhiteSpace(spotProperty.Formula.Mass.ToString())) WriteSdfDataItem(sb, "EXACT MASS", Math.Round(spotProperty.Formula.Mass, 5).ToString());
Comment thread
mikikot113 marked this conversation as resolved.
if (!string.IsNullOrWhiteSpace(spotProperty.InChIKey)) WriteSdfDataItem(sb, "INCHIKEY", spotProperty.InChIKey);
if (!string.IsNullOrWhiteSpace(spotProperty.SMILES)) WriteSdfDataItem(sb, "SMILES", spotProperty.SMILES);
if (!string.IsNullOrWhiteSpace(spotProperty.ChromXs.RT.Value.ToString())) WriteSdfDataItem(sb, "RETENTION TIME", spotProperty.ChromXs.RT.Value.ToString());
Comment thread
mikikot113 marked this conversation as resolved.
if (!string.IsNullOrWhiteSpace(spotProperty.Ontology)) WriteSdfDataItem(sb, "ONTOLOGY", spotProperty.Ontology);
WriteSdfDataItem(sb, "MS LEVEL", "MS2");
var peaks = spectrum.Where(spec => spec.Intensity > 0).ToList();
WriteSdfDataItem(sb, "NUM PEAKS", peaks.Count.ToString());
Expand Down
Loading