示例#1
0
 private string GetReportRows(SrmDocument document, ViewSpec viewSpec, IProgressMonitor progressMonitor)
 {
     var container = new MemoryDocumentContainer();
     container.SetDocument(document, container.Document);
     var dataSchema = new SkylineDataSchema(container, DataSchemaLocalizer.INVARIANT);
     var viewContext = new DocumentGridViewContext(dataSchema);
     var status = new ProgressStatus(string.Format(Resources.ReportSpec_ReportToCsvString_Exporting__0__report,
         viewSpec.Name));
     var writer = new StringWriter();
     if (viewContext.Export(progressMonitor, ref status, viewContext.GetViewInfo(null, viewSpec), writer,
         new DsvWriter(CultureInfo.InvariantCulture, TextUtil.SEPARATOR_CSV)))
     {
         return writer.ToString();
     }
     return null;
 }
示例#2
0
        public void ConsoleReportExportTest()
        {
            var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);
            string docPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi.sky");
            string outPath = testFilesDir.GetTestPath("Exported_test_report.csv");

            // Import the first RAW file (or mzML for international)
            string rawPath = testFilesDir.GetTestPath("ah_20101011y_BSA_MS-MS_only_5-2" +
                ExtensionTestContext.ExtThermoRaw);
            const string replicate = "Single";

            //Before generating this report, check that it exists
            string reportName = Resources.ReportSpecList_GetDefaults_Peptide_Ratio_Results;
            Settings.Default.PersistedViews.ResetDefaults();
            Assert.IsNotNull(Settings.Default.PersistedViews.GetViewSpecList(PersistedViews.MainGroup.Id)
                .GetView(Resources.ReportSpecList_GetDefaults_Peptide_Ratio_Results));

            //First, programmatically generate the report
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            //Attach replicate
            ProgressStatus status;
            doc = CommandLine.ImportResults(doc, docPath, replicate, MsDataFileUri.Parse(rawPath), null, null, out status);
            Assert.IsNull(status);

            string programmaticReport;
            MemoryDocumentContainer memoryDocumentContainer = new MemoryDocumentContainer();
            Assert.IsTrue(memoryDocumentContainer.SetDocument(doc, memoryDocumentContainer.Document));
            SkylineDataSchema skylineDataSchema = new SkylineDataSchema(memoryDocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            DocumentGridViewContext viewContext = new DocumentGridViewContext(skylineDataSchema);
            ViewInfo viewInfo = viewContext.GetViewInfo(PersistedViews.MainGroup.Id.ViewName(reportName));
            StringWriter writer = new StringWriter();
            status = new ProgressStatus("Exporting report");
            viewContext.Export(null, ref status, viewInfo, writer,
                new DsvWriter(CultureInfo.CurrentCulture, TextUtil.GetCsvSeparator(LocalizationHelper.CurrentCulture)));
            programmaticReport = writer.ToString();

            RunCommand("--in=" + docPath,
                       "--import-file=" + rawPath,
                       "--import-replicate-name=" + replicate,
                       "--report-name=" + reportName,
                       "--report-format=CSV",
                       "--report-file=" + outPath);

            string reportLines = File.ReadAllText(outPath);
            AssertEx.NoDiff(reportLines, programmaticReport);
        }