コード例 #1
0
        public IList <PeakData> ImportFile(TextReader peakViewReader)
        {
            var peakDatas   = new List <PeakData>();
            var msFileNames = new List <string>();
            var fileReader  = new DsvFileReader(peakViewReader, TextUtil.SEPARATOR_TSV);

            Assert.AreEqual(fileReader.GetFieldIndex(PROTEIN), 0);
            Assert.AreEqual(fileReader.GetFieldIndex(PEPTIDE), 1);
            Assert.AreEqual(fileReader.GetFieldIndex(LABEL), 2);
            Assert.AreEqual(fileReader.GetFieldIndex(PRECURSOR), 3);
            Assert.AreEqual(fileReader.GetFieldIndex(CHARGE), 4);
            Assert.AreEqual(fileReader.GetFieldIndex(RT), 5);
            Assert.AreEqual(fileReader.GetFieldIndex(DECOY), 6);
            for (int i = 7; i < fileReader.NumberOfFields; ++i)
            {
                msFileNames.Add(fileReader.FieldNames[i]);
            }
            while (fileReader.ReadLine() != null)
            {
                string modifiedSequence = fileReader.GetFieldByName(PEPTIDE);
                string decoyString      = fileReader.GetFieldByName(DECOY);
                bool   decoy;
                Assert.IsTrue(bool.TryParse(decoyString, out decoy));
                foreach (var msFileName in msFileNames)
                {
                    string dataFieldString = fileReader.GetFieldByName(msFileName);
                    double dataField;
                    Assert.IsTrue(double.TryParse(dataFieldString, out dataField));
                    var peakData = new PeakData(dataField, modifiedSequence, msFileName, decoy);
                    peakDatas.Add(peakData);
                }
            }
            return(peakDatas);
        }
コード例 #2
0
        Dictionary <DataProcessedRowKey, double?> ReadDataProcessedRows(TextReader reader)
        {
            DsvFileReader csvReader = new DsvFileReader(reader, TextUtil.SEPARATOR_CSV);
            var           rows      = new Dictionary <DataProcessedRowKey, double?>();

            while (null != csvReader.ReadLine())
            {
                DataProcessedRowKey dataProcessedRow = new DataProcessedRowKey
                {
                    Protein    = csvReader.GetFieldByName("PROTEIN"),
                    Peptide    = csvReader.GetFieldByName("PEPTIDE"),
                    Transition = csvReader.GetFieldByName("TRANSITION"),
                    Run        = int.Parse(csvReader.GetFieldByName("RUN"), CultureInfo.InvariantCulture),
                };

                String strAbundance = csvReader.GetFieldByName("ABUNDANCE");
                double?abundance    = "NA" == strAbundance
                    ? default(double?)
                    : double.Parse(strAbundance, CultureInfo.InvariantCulture);
                rows.Add(dataProcessedRow, abundance);
            }
            return(rows);
        }
コード例 #3
0
        protected override void DoTest()
        {
            Assert.AreEqual(_language, CultureInfo.CurrentUICulture);
            RunUI(() => SkylineWindow.Paste(TextUtil.LineSeparate("ELVIS", "LIVES")));
            var exportLiveReportDlg = ShowDialog <ExportLiveReportDlg>(SkylineWindow.ShowExportReportDialog);

            RunUI(() => exportLiveReportDlg.ReportName = Resources.Resources_ReportSpecList_GetDefaults_Peptide_Quantification);

            Directory.CreateDirectory(TestContext.TestDir);
            string outputFile = Path.Combine(TestContext.TestDir, "file.csv");

            OkDialog(exportLiveReportDlg, () => exportLiveReportDlg.OkDialog(outputFile, TextUtil.CsvSeparator));
            using (var textReader = new StreamReader(outputFile))
            {
                var csvReader = new DsvFileReader(textReader, TextUtil.CsvSeparator);
                CollectionAssert.Contains(csvReader.FieldNames, ColumnCaptions.CalibrationCurve);
                Assert.IsNotNull(csvReader.ReadLine());
                string actualCalibrationCurve   = csvReader.GetFieldByName(ColumnCaptions.CalibrationCurve);
                string expectedCalibrationCurve = string.Format(
                    QuantificationStrings.CalibrationCurve_ToString_Slope___0_,
                    1.0.ToString(Formats.CalibrationCurve));
                Assert.AreEqual(expectedCalibrationCurve, actualCalibrationCurve);
            }
        }
コード例 #4
0
        public static IDictionary <string, LinearFitResult> ReadExpectedResults(Type type, string resourceName)
        {
            var result = new Dictionary <string, LinearFitResult>();

            using (var reader = GetTextReaderForManifestResource(type, resourceName))
            {
                var csvReader = new DsvFileReader(reader, ',');
                while (null != csvReader.ReadLine())
                {
                    string protein         = csvReader.GetFieldByName("Protein");
                    var    linearFitResult = new LinearFitResult(Convert.ToDouble(csvReader.GetFieldByName("log2FC"), CultureInfo.InvariantCulture))
                                             .SetStandardError(Convert.ToDouble(csvReader.GetFieldByName("SE"), CultureInfo.InvariantCulture))
                                             .SetTValue(Convert.ToDouble(csvReader.GetFieldByName("Tvalue"), CultureInfo.InvariantCulture))
                                             .SetDegreesOfFreedom(Convert.ToInt32(csvReader.GetFieldByName("DF"), CultureInfo.InvariantCulture))
                                             .SetPValue(Convert.ToDouble(csvReader.GetFieldByName("pvalue"), CultureInfo.InvariantCulture));
                    result.Add(protein, linearFitResult);
                }
            }
            return(result);
        }