public static string GetUnmodifiedTargetText(LibraryKey key) { var peptideKey = key as PeptideLibraryKey; if (peptideKey != null) { return(peptideKey.UnmodifiedSequence); } var moleculeKey = key as MoleculeLibraryKey; if (moleculeKey != null) { if (!string.IsNullOrEmpty(moleculeKey.SmallMoleculeLibraryAttributes.MoleculeName)) { return(moleculeKey.SmallMoleculeLibraryAttributes.MoleculeName); } return(moleculeKey.ToString()); } var crosslinkKey = key as CrosslinkLibraryKey; if (crosslinkKey != null) { return(crosslinkKey.PeptideLibraryKeys.First().UnmodifiedSequence); } return(key.ToString()); }