From: <bre...@us...> - 2013-02-19 03:25:49
|
Revision: 4346 http://sourceforge.net/p/proteowizard/code/4346 Author: brendanx Date: 2013-02-19 03:25:46 +0000 (Tue, 19 Feb 2013) Log Message: ----------- Skyline (v1.4): Fix Agilent transition list export to differentiate between label types in CompoundName - Fix export Agilent triggered-MRM to always include a trigger transition, even when an analyte precursor is not present Modified Paths: -------------- branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Model/Export.cs branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Model/Import.cs branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Test/SrmDocumentTest.cs branches/skyline_1_4/pwiz/pwiz_tools/Skyline/TestFunctional/ExportMethodDialogTest.zip Modified: branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Model/Export.cs =================================================================== --- branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Model/Export.cs 2013-02-17 21:30:21 UTC (rev 4345) +++ branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Model/Export.cs 2013-02-19 03:25:46 UTC (rev 4346) @@ -1114,8 +1114,11 @@ writer.Write(nodePepGroup.Name); writer.Write(FieldSeparator); // Write modified sequence for the light peptide molecule - writer.Write(Document.Settings.GetModifiedSequence(nodePep.Peptide.Sequence, - IsotopeLabelType.light, nodePep.ExplicitMods)); + string modifiedSequence = Document.Settings.GetModifiedSequence(nodePep.Peptide.Sequence, + IsotopeLabelType.light, nodePep.ExplicitMods); + string compoundName = string.Format("{0}.{1}", modifiedSequence, nodeTranGroup.TransitionGroup.LabelType); + writer.Write(compoundName); + writer.Write(FieldSeparator); var istdTypes = Document.Settings.PeptideSettings.Modifications.InternalStandardTypes; writer.Write(istdTypes.Contains(nodeTranGroup.TransitionGroup.LabelType) // ISTD? @@ -1145,7 +1148,7 @@ writer.Write(FieldSeparator); // Trigger must be rank 1 transition, of analyte type and minimum precursor charge bool trigger = false; - if (nodeTranGroup.TransitionGroup.LabelType.IsLight && rank.HasValue && rank.Value == 1) + if (IsTriggerType(nodePep, nodeTranGroup, istdTypes) && rank.HasValue && rank.Value == 1) { int minCharge = nodePep.TransitionGroups.Select(g => g.TransitionGroup.PrecursorCharge).Min(); if (nodeTranGroup.TransitionGroup.PrecursorCharge == minCharge) @@ -1191,6 +1194,31 @@ writer.Write(nodeTran.LibInfo.Rank); writer.WriteLine(); } + + private static bool IsTriggerType(PeptideDocNode nodePep, TransitionGroupDocNode nodeTranGroup, IList<IsotopeLabelType> istdTypes) + { + // If there is a light precursor, then it is always the trigger + if (nodeTranGroup.TransitionGroup.LabelType.IsLight) + return true; + // Get all precursors with the same charge state and at least 1 transition, including this one + var arrayTranGroups = nodePep.TransitionGroups + .Where(g => g.TransitionGroup.PrecursorCharge == nodeTranGroup.TransitionGroup.PrecursorCharge && + g.TransitionCount > 0).ToArray(); + // If it is the only precursor of this charge state, then it must be the trigger + if (arrayTranGroups.Length == 1) + return true; + // If there is no light precursor + var firstGroup = arrayTranGroups.First(); + if (!firstGroup.TransitionGroup.LabelType.IsLight) + { + // See if there is a precursor not of an internal standard type, and use the first such precursor + var analyteGroup = arrayTranGroups.FirstOrDefault(g => !istdTypes.Contains(g.TransitionGroup.LabelType)); + if (analyteGroup != null) + return ReferenceEquals(analyteGroup, nodeTranGroup); + } + // Otherwise, the first precursor in the list is the trigger. + return ReferenceEquals(firstGroup, nodeTranGroup); + } } public class AgilentMethodExporter : AgilentMassListExporter @@ -1397,7 +1425,7 @@ protected override void WriteHeaders(TextWriter writer) { - // TODO: L1ON? + // Not L10N writer.Write("protein.name"); writer.Write(FieldSeparator); writer.Write("peptide.seq"); // modified sequence to support 1:1 requirement with precursor m/z Modified: branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Model/Import.cs =================================================================== --- branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Model/Import.cs 2013-02-17 21:30:21 UTC (rev 4345) +++ branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Model/Import.cs 2013-02-19 03:25:46 UTC (rev 4346) @@ -745,7 +745,7 @@ private static string RemoveSequenceNotes(string seq) { - if (seq.IndexOf('[') == -1) // Not L10N + if (seq.IndexOf('[') == -1 && seq.IndexOf('.') == -1) // Not L10N return seq; StringBuilder seqBuild = new StringBuilder(seq.Length); bool inNote = false; @@ -763,7 +763,11 @@ inNote = false; } } - return seqBuild.ToString(); + string seqClean = seqBuild.ToString(); + int dotIndex = seqClean.IndexOf('.'); // Not L10N + if (dotIndex != -1) + seqClean = seqClean.Substring(0, dotIndex); + return seqClean; } private static readonly string[] EXCLUDE_PROTEIN_VALUES = new[] { "true", "false", "heavy", "light", "unit" }; // Not L10N Modified: branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Test/SrmDocumentTest.cs =================================================================== --- branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Test/SrmDocumentTest.cs 2013-02-17 21:30:21 UTC (rev 4345) +++ branches/skyline_1_4/pwiz/pwiz_tools/Skyline/Test/SrmDocumentTest.cs 2013-02-19 03:25:46 UTC (rev 4346) @@ -195,12 +195,29 @@ count = EqualCsvs(DOC_0_1_BOVINE, 4, ThermoExporters, ExportStrategy.Single, 1, null, ExportMethodType.Standard); Assert.AreEqual(1, count); + count = ExportAll(DOC_0_1_PEPTIDES_NO_EMPTY, 4, CreateWatersExporter, ExportStrategy.Single, 2, null, + ExportMethodType.Standard); + Assert.AreEqual(1, count); count = EqualCsvs(DOC_0_1_PEPTIDES_NO_EMPTY, 0, CreateAbiExporters, ExportStrategy.Buckets, 1, 6, ExportMethodType.Standard); // TODO: Test scheduled runs Assert.AreEqual(3, count); } + /// <summary> + /// Test export and reimport of Waters and Agilent transition list formats + /// </summary> + [TestMethod] + public void DocumentExportImportTest() + { + int count = ExportAll(DOC_0_1_PEPTIDES_NO_EMPTY, 4, CreateWatersExporter, ExportStrategy.Single, 2, null, + ExportMethodType.Standard); + Assert.AreEqual(1, count); + count = ExportAll(DOC_0_1_PEPTIDES_NO_EMPTY, 4, CreateAgilentExporter, ExportStrategy.Single, 2, null, + ExportMethodType.Standard); + Assert.AreEqual(1, count); + } + private static int EqualCsvs(string xml, int countFields, CreateExporters exporters, ExportStrategy strategy, int minTransition, int? maxTransition, ExportMethodType methodType) { @@ -210,7 +227,7 @@ return EqualCsvs(target, actual, countFields, exporters, strategy, minTransition, maxTransition, methodType); } - private static int EqualCsvs(XmlSrmDocument target, SrmDocument actual, int coundFields, CreateExporters exporters, + private static int EqualCsvs(XmlSrmDocument target, SrmDocument actual, int countFields, CreateExporters exporters, ExportStrategy strategy, int minTransition, int? maxTransition, ExportMethodType methodType) { XmlMassListExporter exporterTarget; @@ -240,8 +257,8 @@ string actualList = exportedActual[key].ToString(); Assert.AreNotEqual(0, targetList.Length); - if (coundFields > 0) - AssertEx.FieldsEqual(targetList, actualList, coundFields); + if (countFields > 0) + AssertEx.FieldsEqual(targetList, actualList, countFields); else AssertEx.NoDiff(targetList, actualList); @@ -260,6 +277,41 @@ return exportedTarget.Count; } + private static int ExportAll(string xml, int countFields, CreateExporter exporters, + ExportStrategy strategy, int minTransition, int? maxTransition, + ExportMethodType methodType) + { + SrmDocument actual = AssertEx.Deserialize<SrmDocument>(xml); + + return ExportAll(actual, countFields, exporters, strategy, minTransition, maxTransition, methodType); + } + + private static int ExportAll(SrmDocument actual, int countFields, CreateExporter exporter, + ExportStrategy strategy, int minTransition, int? maxTransition, + ExportMethodType methodType) + { + AbstractMassListExporter exporterActual; + exporter(actual, out exporterActual); + exporterActual.Export(null); + var exportedActual = exporterActual.MemoryOutput; + + // Make sure the resulting output can be imported + SrmDocument docImport = new SrmDocument(actual.Settings); + foreach (string key in exportedActual.Keys) + { + string actualList = exportedActual[key].ToString(); + + // Import the exported list + using (var readerImport = new StringReader(actualList)) + { + IdentityPath pathAdded; + IFormatProvider provider = CultureInfo.InvariantCulture; + docImport = docImport.ImportMassList(readerImport, provider, ',', IdentityPath.ROOT, out pathAdded); + } + } + return exportedActual.Count; + } + private delegate void CreateExporters(XmlSrmDocument target, out XmlMassListExporter exporterTarget, SrmDocument actual, out AbstractMassListExporter exporterActual); @@ -277,6 +329,18 @@ exporterActual = new AbiMassListExporter(actual); } + private delegate void CreateExporter(SrmDocument actual, out AbstractMassListExporter exporterActual); + + private static void CreateWatersExporter(SrmDocument actual, out AbstractMassListExporter exporterActual) + { + exporterActual = new WatersMassListExporter(actual); + } + + private static void CreateAgilentExporter(SrmDocument actual, out AbstractMassListExporter exporterActual) + { + exporterActual = new AgilentMassListExporter(actual); + } + private static void CheckImportSimilarity(SrmDocument document, SrmDocument docImport) { CheckImportSimilarity(document.PeptideGroups, docImport.PeptideGroups, Modified: branches/skyline_1_4/pwiz/pwiz_tools/Skyline/TestFunctional/ExportMethodDialogTest.zip =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |