Exemplo n.º 1
0
 private static void FormatCsvArray(TextWriter writer, IList<float> floatArray, CultureInfo cultureInfo)
 {
     char intensitySeparator = TextUtil.GetCsvSeparator(cultureInfo);
     for (int i = 0; i < floatArray.Count; ++i)
     {
         if (i > 0)
             writer.Write(intensitySeparator);
         writer.WriteDsvField(System.Convert.ToString(floatArray[i], cultureInfo), intensitySeparator);
     }
 }
Exemplo n.º 2
0
 private static void FormatHeader(TextWriter writer, IList<string> fieldNames)
 {
     for (int i = 0; i < fieldNames.Count; ++i)
     {
         if (i > 0)
             writer.Write(MAIN_SEPARATOR);
         writer.WriteDsvField(fieldNames[i], MAIN_SEPARATOR);
     }
     writer.WriteLine();
 }
Exemplo n.º 3
0
        protected override void WriteTransition(TextWriter writer,
            XmlFastaSequence sequence,
            XmlPeptide peptide,
            XmlTransition transition)
        {
            char separator = TextUtil.GetCsvSeparator(_cultureInfo);
            writer.Write(transition.PrecursorMz.ToString(_cultureInfo));
            writer.Write(separator);
            writer.Write(transition.ProductMz.ToString(_cultureInfo));
            writer.Write(separator);
            if (MethodType == ExportMethodType.Standard)
                writer.Write(Math.Round(DwellTime, 2).ToString(_cultureInfo));
            else
            {
                if (!peptide.PredictedRetentionTime.HasValue)
                    throw new InvalidOperationException(Resources.XmlThermoMassListExporter_WriteTransition_Attempt_to_write_scheduling_parameters_failed);
                writer.Write(peptide.PredictedRetentionTime.Value.ToString(_cultureInfo));
            }
            writer.Write(separator);

            // Write special ID for ABI software
            var fastaSequence = new FastaSequence(sequence.Name, sequence.Description, null, peptide.Sequence);
            var newPeptide = new Peptide(fastaSequence, peptide.Sequence, 0, peptide.Sequence.Length, peptide.MissedCleavages);
            var nodePep = new PeptideDocNode(newPeptide);
            string modifiedPepSequence = AbiMassListExporter.GetSequenceWithModsString(nodePep, _document.Settings); // Not L10N;

            string extPeptideId = string.Format("{0}.{1}.{2}.{3}", // Not L10N
                                                sequence.Name,
                                                modifiedPepSequence,
                                                GetTransitionName(transition),
                                                "light"); // Not L10N : file format

            writer.WriteDsvField(extPeptideId, separator);
            writer.Write(separator);
            writer.Write(Math.Round(transition.DeclusteringPotential ?? 0, 1).ToString(_cultureInfo));

            writer.Write(separator);
            writer.Write(Math.Round(transition.CollisionEnergy, 1).ToString(_cultureInfo));

            writer.WriteLine();
        }
Exemplo n.º 4
0
 private static void FormatChromLine(TextWriter writer,
     IEnumerable<string> fieldArray,
     IList<float> times,
     IList<float> intensities,
     CultureInfo cultureInfo)
 {
     foreach (string field in fieldArray)
     {
         writer.WriteDsvField(field, MAIN_SEPARATOR);
         writer.Write(MAIN_SEPARATOR);
     }
     FormatCsvArray(writer, times, cultureInfo);
     writer.Write(MAIN_SEPARATOR);
     FormatCsvArray(writer, intensities, cultureInfo);
     writer.WriteLine();
 }
Exemplo n.º 5
0
        private static void WriteHeader(TextWriter writer)
        {
            const char separator = TextUtil.SEPARATOR_TSV;
            // ReSharper disable NonLocalizedString
            var namesArray = new List<string>
                {
                    "FileName",
                    "PeptideModifiedSequence",
                    "Apex",
                    "annotation_Score",
                    "annotation_QValue",
                    "decoy"
                };
            // ReSharper restore NonLocalizedString

            bool first = true;
            foreach (var name in namesArray)
            {
                if (first)
                    first = false;
                else
                    writer.Write(separator);
                writer.WriteDsvField(name, separator);
            }
            writer.WriteLine();
        }
Exemplo n.º 6
0
 private static void WriteLine(TextWriter writer,
     CultureInfo cultureInfo,
     string file,
     string modifiedSequence,
     double rt,
     double score,
     double qValue,
     bool decoy)
 {
     const char separator = TextUtil.SEPARATOR_TSV;
     var fieldsArray = new List<string>
         {
             file,
             modifiedSequence,
             Convert.ToString(rt, cultureInfo),
             Convert.ToString(score, cultureInfo),
             Convert.ToString(qValue, cultureInfo),
             Convert.ToString(decoy, cultureInfo)
         };
     bool first = true;
     foreach (var name in fieldsArray)
     {
         if (first)
             first = false;
         else
             writer.Write(separator);
         writer.WriteDsvField(name, separator);
     }
     writer.WriteLine();
 }
Exemplo n.º 7
0
 public void WriteLine(TextWriter writer,
               string dataset,
               string toolName,
               double peptides01,
               double peptides05,
               double peptidesAll,
               double qValue01,
               double qValue05)
 {
     const char separator = TextUtil.SEPARATOR_TSV;
     var fieldsArray = new List<string>
     {
         dataset,
         toolName,
         Convert.ToString(peptides01, CultureInfo.InvariantCulture),
         Convert.ToString(peptides05, CultureInfo.InvariantCulture),
         Convert.ToString(peptidesAll, CultureInfo.InvariantCulture),
         Convert.ToString(qValue01, CultureInfo.InvariantCulture),
         Convert.ToString(qValue05, CultureInfo.InvariantCulture),
     };
     bool first = true;
     foreach (var name in fieldsArray)
     {
         if (first)
             first = false;
         else
             writer.Write(separator);
         writer.WriteDsvField(name, separator);
     }
     writer.WriteLine();
 }
Exemplo n.º 8
0
        public void WriteHeader(TextWriter writer)
        {
            const char separator = TextUtil.SEPARATOR_TSV;
            // ReSharper disable NonLocalizedString
            var namesArray = new List<string>
                {
                    "DataSet",
                    "ToolName",
                    "Peptides01",
                    "Peptides05",
                    "PeptdesAll",
                    "QValue01",
                    "QValue05"
                };
            // ReSharper restore NonLocalizedString

            bool first = true;
            foreach (var name in namesArray)
            {
                if (first)
                    first = false;
                else
                    writer.Write(separator);
                writer.WriteDsvField(name, separator);
            }
            writer.WriteLine();
        }
Exemplo n.º 9
0
        private static void WriteRow(TextWriter writer,
            PeakTransitionGroupFeatures features,
            PeakGroupFeatures peakGroupFeatures,
            CultureInfo cultureInfo,
            double mProphetScore,
            double pValue,
            double qValue)
        {
            char separator = TextUtil.GetCsvSeparator(cultureInfo);
            string fileName = SampleHelp.GetFileName(features.Id.FilePath);
            var fieldsArray = new List<string>
                {
                    Convert.ToString(features.Id, cultureInfo),
                    Convert.ToString(features.Id.Run, cultureInfo),
                    fileName,
                    Convert.ToString(peakGroupFeatures.RetentionTime, cultureInfo),
                    Convert.ToString(peakGroupFeatures.StartTime, cultureInfo),
                    Convert.ToString(peakGroupFeatures.EndTime, cultureInfo),
                    features.Id.NodePep.RawUnmodifiedTextId, // Unmodified sequence, or custom ion name
                    features.Id.NodePep.RawTextId, // Modified sequence, or custom ion name
                    features.Id.NodePepGroup.Name,
                    Convert.ToString(features.Id.NodePep.IsDecoy ? 1 : 0, cultureInfo),
                    ToFieldString((float) mProphetScore, cultureInfo),
                    ToFieldString((float) pValue, cultureInfo),
                    ToFieldString((float) qValue, cultureInfo)
                };
            if (IsFilterTestData)
            {
                fieldsArray.Add(peakGroupFeatures.GetFilterPairsText(cultureInfo));
            }

            foreach (var name in fieldsArray)
            {
                writer.WriteDsvField(name, separator);
                writer.Write(separator);
            }
            bool first = true;
            foreach (float featureColumn in peakGroupFeatures.Features)
            {
                if (!first)
                    writer.Write(separator);
                writer.WriteDsvField(ToFieldString(featureColumn, cultureInfo), separator);
                first = false;
            }
            writer.WriteLine();
        }
Exemplo n.º 10
0
        private static void WriteHeaderRow(TextWriter writer, IEnumerable<IPeakFeatureCalculator> calcs, CultureInfo cultureInfo)
        {
            char separator = TextUtil.GetCsvSeparator(cultureInfo);
            // ReSharper disable NonLocalizedString
            var namesArray = new List<string>
                {
                    "transition_group_id",
                    "run_id",
                    "FileName",
                    "RT",
                    "MinStartTime",
                    "MaxEndTime",
                    "Sequence",
                    "PeptideModifiedSequence",
                    "ProteinName",
                    "PrecursorIsDecoy",
                    "mProphetScore",
                    "pValue",
                    "qValue"
                };
            if (IsFilterTestData)
            {
                namesArray.Add("FoundIonFilters");
            }
            // ReSharper restore NonLocalizedString

            foreach (var name in namesArray)
            {
                writer.WriteDsvField(name, separator);
                writer.Write(separator);
            }
            bool first = true;
            foreach (var peakFeatureCalculator in calcs)
            {
                if (!first)
                    writer.Write(separator);
                writer.Write(first ? "main_var_{0}" : "var_{0}", peakFeatureCalculator.HeaderName.Replace(" ", "_")); // Not L10N
                first = false;
            }
            writer.WriteLine();
        }
Exemplo n.º 11
0
        public static void WriteReportHelper(ResultSet results, char separator, TextWriter writer, CultureInfo ci)
        {
            for (int i = 0; i < results.ColumnInfos.Count; i++)
            {
                var columnInfo = results.ColumnInfos[i];
                if (columnInfo.IsHidden)
                    continue;

                if (i > 0)
                    writer.Write(separator);
                writer.WriteDsvField(columnInfo.Caption, separator);
            }
            writer.WriteLine();
            for (int iRow = 0; iRow < results.RowCount; iRow++)
            {
                for (int iColumn = 0; iColumn < results.ColumnInfos.Count; iColumn++)
                {
                    var columnInfo = results.ColumnInfos[iColumn];
                    if (columnInfo.IsHidden)
                        continue;

                    if (iColumn > 0)
                        writer.Write(separator);
                    string value = results.FormatValue(iRow, iColumn, ci);
                    writer.WriteDsvField(value, separator);
                }
                writer.WriteLine();
            }
        }