コード例 #1
0
        protected override string buildHeaderLine()
        {
            var data = new List <string>
            {
                "scan_num",
                "charge",
                "abundance",
                "mz",
                "fit",
                "average_mw",
                "monoisotopic_mw",
                "mostabundant_mw",
                "fwhm",
                "signal_noise",
                "mono_abundance",
                "mono_plus2_abundance",
                "flag",
                "interference_score"
            };

            // Uncomment to write out the fit_count_basis
            //            //data.Add("fit_basis_count");

            return(string.Join(Delimiter.ToString(), data));
        }
コード例 #2
0
        protected override string buildResultOutput(TargetBase target)
        {
            Check.Require(target is PeptideTarget, "Exported result is of the wrong type.");

            var result = (PeptideTarget)target;

            var data = new List <string>
            {
                target.ID.ToString(),
                DblToString(target.MonoIsotopicMass, 6),
                target.Code,
                target.ChargeState.ToString(),
                target.EmpiricalFormula,
                target.ModCount.ToString(),
                target.ModDescription,
                target.ObsCount.ToString(),
                DblToString(target.MZ, 6),
                DblToString(target.NormalizedElutionTime, 6),
                result.RefID.ToString(),
                result.GeneReference,
                result.ProteinDescription
            };

            return(string.Join(Delimiter.ToString(), data));
        }
コード例 #3
0
        public static Blob TextToBytes(string text, bool useDTE = true, Delimiter delimiter = Delimiter.Null)
        {
            Blob bytes = new byte[text.Length + 1];
            int  i = 0, j = 0;

            while (i < text.Length - 1)
            {
                var twoChars = text.Substring(i, 2);
                if (BytesByText.ContainsKey(twoChars) && (useDTE || twoChars[0] == '@' || twoChars[0] == '€' || twoChars[0] == '§'))
                {
                    bytes[j++] = BytesByText[twoChars];
                    i         += 2;
                }
                else
                {
                    bytes[j++] = BytesByText[text[i++].ToString()];
                }
            }

            if (i < text.Length)
            {
                bytes[j++] = BytesByText[text[i++].ToString()];
            }

            if (delimiter != Delimiter.Empty)
            {
                bytes[j++] = (byte)delimiter;
            }

            return(bytes.SubBlob(0, j));
        }
コード例 #4
0
ファイル: ToolsIOCSV.cs プロジェクト: kozzion/KozzionCSharp
 public static string[,] ReadCSVFile(
     string file_path,
     Delimiter field_delimiter,
     Delimiter text_sparator)
 {
     return(ReadCSVLines(System.IO.File.ReadAllLines(file_path), field_delimiter, text_sparator));
 }
コード例 #5
0
ファイル: ToolsIOCSV.cs プロジェクト: kozzion/KozzionCSharp
 public static string[,] ReadCSVLines(
     List <string> lines,
     Delimiter field_delimiter,
     Delimiter text_delimiter)
 {
     return(ReadCSVLines(lines.ToArray(), field_delimiter, text_delimiter));
 }
コード例 #6
0
        protected override void Execute(CodeActivityContext context)
        {
            var inputString = InputString.Get(context);
            var delimiter   = Delimiter.Get(context);

            var strArray = inputString.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

            // Declare DataTable object.
            var dt = new System.Data.DataTable();

            // Add columns to the DataTable
            dt.Columns.Add("LINENUMBER", typeof(String));
            dt.Columns.Add("PARTNUMBER", typeof(String));
            dt.Columns.Add("DESCRIPTION", typeof(String));
            dt.Columns.Add("ORDERQTY", typeof(String));
            dt.Columns.Add("UNITPRICE", typeof(String));

            // Add strings from string array to datatable
            foreach (string str in strArray)
            {
                var drow = dt.NewRow();   // Here you will get an actual instance of a DataRow

                var strArrayTemp = str.Split(new string[] { delimiter }, StringSplitOptions.None);

                drow[0] = strArrayTemp[0];
                drow[1] = strArrayTemp[1];
                drow[2] = strArrayTemp[2];
                drow[3] = strArrayTemp[3];
                drow[4] = strArrayTemp[4];

                dt.Rows.Add(drow);             // Don't forget to add the row to the DataTable.
            }

            dtOutput.Set(context, dt);
        }
コード例 #7
0
ファイル: CSVParser.cs プロジェクト: yutokun/CSV-Parser
    /// <summary>
    /// Load CSV data from specified path.
    /// </summary>
    /// <param name="path">CSV file path.</param>
    /// <param name="delimiter">Delimiter.</param>
    /// <param name="encoding">Type of text encoding. (default UTF-8)</param>
    /// <returns>Nested list that CSV parsed.</returns>
    public static List <List <string> > LoadFromPath(string path, Delimiter delimiter = Delimiter.Comma, Encoding encoding = null)
    {
        encoding = encoding ?? Encoding.UTF8;
        var data = File.ReadAllText(path, encoding);

        return(Parse(data, delimiter));
    }
コード例 #8
0
        protected override string buildResultOutput(IsosResult result)
        {
            Check.Require(result is UIMFIsosResult, "UIMF Isos Exporter is only used with UIMF results");
            var uimfResult = (UIMFIsosResult)result;

            var data = new List <string>
            {
                uimfResult.ScanSet.PrimaryScanNumber.ToString(),
                (uimfResult.IMSScanSet.PrimaryScanNumber + 1).ToString(),                // Add 1 to PrimaryScanNumber (which is 0-based)
                uimfResult.IsotopicProfile.ChargeState.ToString(),
                DblToString(uimfResult.IsotopicProfile.GetAbundance(), 4, true),
                DblToString(uimfResult.IsotopicProfile.GetMZ(), 5),
                DblToString(uimfResult.IsotopicProfile.GetScore(), 4),
                DblToString(uimfResult.IsotopicProfile.AverageMass, 5),
                DblToString(uimfResult.IsotopicProfile.MonoIsotopicMass, 5),
                DblToString(uimfResult.IsotopicProfile.MostAbundantIsotopeMass, 5),
                DblToString(uimfResult.IsotopicProfile.GetFWHM(), 4),
                DblToString(uimfResult.IsotopicProfile.GetSignalToNoise(), 2),
                DblToString(uimfResult.IsotopicProfile.GetMonoAbundance(), 4, true),
                DblToString(uimfResult.IsotopicProfile.GetMonoPlusTwoAbundance(), 4, true),
                DblToString(uimfResult.IsotopicProfile.OriginalIntensity, 4, true),
                uimfResult.IsotopicProfile.IsSaturatedAsNumericText,
                DblToString(uimfResult.DriftTime, 3),
                ProcessingTasks.ResultValidators.ResultValidationUtils.GetStringFlagCode(result.Flags),
                DblToString(uimfResult.InterferenceScore, 4)
            };

            return(string.Join(Delimiter.ToString(), data));
        }
コード例 #9
0
        protected override string buildHeaderLine()
        {
            var data = new List <string>
            {
                "frame_num",
                "ims_scan_num",
                "charge",
                "abundance",
                "mz",
                "fit",
                "average_mw",
                "monoisotopic_mw",
                "mostabundant_mw",
                "fwhm",
                "signal_noise",
                "mono_abundance",
                "mono_plus2_abundance",
                "orig_intensity",
                "TIA_orig_intensity",
                "drift_time",
                "flag",
                "interference_score"
            };

            return(string.Join(Delimiter.ToString(), data));
        }
コード例 #10
0
    /// <summary>
    /// Goes through it's usersettings dictionary and writes each enum and value to a instance in the usersetting file
    /// </summary>
    /// <returns></returns>
    public bool SaveSettings()
    {
        try
        {
            if (!File.Exists(Application.persistentDataPath + userSettingsPath))
            {
                File.Create(Application.persistentDataPath + userSettingsPath);
            }

            StreamWriter sw = new StreamWriter(Application.persistentDataPath + userSettingsPath);

            foreach (UserSetting us in UserSettings.Keys)
            {
                if (UserSettings[us] != null)
                {
                    sw.Write(Enum.GetName(typeof(UserSetting), us)
                             + Delimiter.ToString()
                             + UserSettings[us].ToString() + sw.NewLine);
                }
            }

            sw.Close();

            return(true);
        }
        catch (Exception e)
        {
            Debug.Log(e);
            return(false);
        }
    }
コード例 #11
0
        public string Serialize <T>(IEnumerable <T> input, Delimiter delimiter) where T : class
        {
            var properties = typeof(T).GetProperties();

            if (properties.Length == 0)
            {
                return(string.Empty);
            }

            // get headers
            var header = properties
                         .Select(GetHeaderName)
                         .Aggregate((a, b) => a + delimiter.Value + b);

            //create lines out of values
            var csvLines = input.Select(item => item.GetType()
                                        .GetProperties()
                                        .Select(property => GetPropertyValue(item, property.Name))
                                        .Aggregate((a, b) => a + delimiter.Value + b));

            var body = new StringBuilder();

            foreach (var line in csvLines)
            {
                body.AppendLine(line);
            }

            //join header and body
            return(string.Join(Environment.NewLine, header, body));
        }
コード例 #12
0
    /// <summary>
    /// Goes through it's PlayControl dictionary and writes each key and value to a line in the control setting file
    /// </summary>
    /// <returns>Success of the save</returns>
    public bool SavePlayerData()
    {
        try
        {
            if (!File.Exists(Application.persistentDataPath + controlSettingsPath))
            {
                File.Create(Application.persistentDataPath + controlSettingsPath);
            }

            StreamWriter sw = new StreamWriter(Application.persistentDataPath + controlSettingsPath);

            foreach (KeyCode key in PlayControl.Keys)
            {
                sw.Write(Enum.GetName(typeof(KeyboardToEventHelper.KeyFunction), PlayControl[key].InputToFunction())
                         + Delimiter.ToString()
                         + Enum.GetName(typeof(KeyCode), key) + sw.NewLine);
            }

            sw.Close();

            return(true);
        }
        catch (Exception e)
        {
            Debug.Log(e);
            return(false);
        }
    }
コード例 #13
0
ファイル: XsvParser.cs プロジェクト: coulank/upm.XsvUtility
        public static IList <IDictionary <string, string> > ParseWithHeader(Delimiter delimiter, string text)
        {
            var rows = Parse(delimiter, text);

            if (rows == null || rows.Count == 0)
            {
                return(new List <IDictionary <string, string> >());
            }
            var result = new List <IDictionary <string, string> >();
            var header = rows[0];
            var index  = 0;

            foreach (var row in rows)
            {
                if (index++ == 0)
                {
                    continue;
                }

                var line = new Dictionary <string, string>();
                for (var i = 0; i < header.Count; i++)
                {
                    line[header[i]] = row[i];
                }
                result.Add(line);
            }

            return(result);
        }
コード例 #14
0
        internal ChoCSVRecordConfiguration(Type recordType) : base(recordType)
        {
            CSVRecordFieldConfigurations = new List <ChoCSVRecordFieldConfiguration>();

            if (recordType != null)
            {
                Init(recordType);
            }

            if (Delimiter.IsNullOrEmpty())
            {
                if (Culture != null)
                {
                    Delimiter = Culture.TextInfo.ListSeparator;
                }

                if (Delimiter.IsNullOrWhiteSpace())
                {
                    Delimiter = ",";
                }
            }

            Sanitize            = false;
            InjectionChars      = "=@+-";
            InjectionEscapeChar = '\t';

            FileHeaderConfiguration = new ChoCSVFileHeaderConfiguration(recordType, Culture);
        }
コード例 #15
0
        protected override string buildIsosResultOutput(IsosResult result)
        {
            Check.Require(result is O16O18IsosResult, "Cannot use this O16O18ResultExporter with this type of result: " + result);

            var o16o18result = (O16O18IsosResult)result;

            var data = new List <string>
            {
                o16o18result.ScanSet.PrimaryScanNumber.ToString(),
                o16o18result.IsotopicProfile.ChargeState.ToString(),
                DblToString(o16o18result.IsotopicProfile.GetAbundance(), 4, true),
                DblToString(o16o18result.IsotopicProfile.GetMZofMostAbundantPeak(), 5),
                DblToString(o16o18result.IsotopicProfile.Score, 4),
                DblToString(o16o18result.IsotopicProfile.AverageMass, 5),
                DblToString(o16o18result.IsotopicProfile.MonoIsotopicMass, 5),
                DblToString(o16o18result.IsotopicProfile.MostAbundantIsotopeMass, 5),
                DblToString(o16o18result.IsotopicProfile.GetFWHM(), 4),
                DblToString(o16o18result.IsotopicProfile.GetSignalToNoise(), 2),
                DblToString(o16o18result.IsotopicProfile.GetMonoAbundance(), 4, true),
                DblToString(o16o18result.MonoPlus2Abundance, 4, true),
                DblToString(o16o18result.MonoPlus4Abundance, 4, true),
                DblToString(o16o18result.MonoMinus4Abundance, 4, true),
                ResultValidators.ResultValidationUtils.GetStringFlagCode(o16o18result.Flags),
                DblToString(o16o18result.InterferenceScore, 5)
            };

            //traditionally, the m/z of the most abundant peak is reported. If you want the m/z of the mono peak, get the monoIsotopic mass

            return(string.Join(Delimiter.ToString(), data));
        }
コード例 #16
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of System.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (Delimiter.Expression != null)
            {
                targetCommand.AddParameter("Delimiter", Delimiter.Get(context));
            }

            if (UseCulture.Expression != null)
            {
                targetCommand.AddParameter("UseCulture", UseCulture.Get(context));
            }

            if (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

            if (Header.Expression != null)
            {
                targetCommand.AddParameter("Header", Header.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
コード例 #17
0
 private void DoWorkOnFileLines(string filename)
 {
     using (StreamReader sr = File.OpenText(filename)) {
         while (true)
         {
             string line = sr.ReadLine();
             if (line == null)
             {
                 break;
             }
             if (Delimiter == null)
             {
                 DoWork(line);
                 if (BreakTask.Break)
                 {
                     break;
                 }
             }
             else
             {
                 DoWork(line.Split(Delimiter.ToCharArray()));
                 if (BreakTask.Break)
                 {
                     break;
                 }
             }
         }
     }
 }
コード例 #18
0
        private string NodeToString(XmlNode node, Delimiter delimiter)
        {
            if (node.Attributes.Count == 0)
            {
                return(string.Empty);
            }
            StringBuilder segement           = new StringBuilder();
            string        nextattribName     = string.Empty;
            string        nodeName           = node.Name;
            int           nodeNameLength     = nodeName.Length;
            string        nextNodeElementPos = string.Empty;
            string        nodeElementPos     = string.Empty;

            for (int i = 1; i < node.Attributes.Count - 1; i++)
            {
                nextattribName = node.Attributes[i + 1].Name;
                //Using This as there is no more then 99 elements in a segement
                nodeElementPos     = node.Attributes[i].Name.Substring(nodeNameLength, 2);
                nextNodeElementPos = nextattribName.Substring(nodeNameLength, 2);
                if (node.Attributes[i].Name.Contains("-") && (nodeElementPos == nextNodeElementPos))
                {
                    segement.AppendFormat("{0}{1}", node.Attributes[i].Value, delimiter.CompositeSeperator);
                }
                else
                {
                    segement.AppendFormat("{0}{1}", node.Attributes[i].Value, delimiter.ElementSeperator);
                }
            }
            segement.AppendFormat("{0}{1}", node.Attributes[node.Attributes.Count - 1].Value, delimiter.SegementSeperator);
            return(segement.ToString());
        }
コード例 #19
0
        public void CreateConfiguration(string typeName, Delimiter delimiter, bool hasHeader)
        {
            using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
            var template = new Template
            {
                Detail = new Detail
                {
                    Delimiter   = delimiter != Delimiter.Unknown ? delimiter : Delimiter.Tab,
                    Description = "Test",
                    HasHeaders  = hasHeader,
                    MappingType = MappingType.ColumnOrder,
                    Name        = "Test"
                },
                ImportTemplateItems = new ImportTemplateItems
                {
                    Item = new[]
                    {
                        new Item {
                            ColumnNumber = 1, AtomField = "Id", AtomTable = typeName, ImportField = "Test Id"
                        }
                    }.ToList()
                }
            };
            var config = template.CreateConfiguration(loggerFactory.CreateLogger <DynamicImportMap <Model> >());

            Assert.IsType <CsvConfiguration>(config);
            Assert.True(config.HasHeaderRecord);
            Assert.Equal(template.Detail.Delimiter switch
            {
                Delimiter.Comma => ",",
                Delimiter.Tab => "\t",
                Delimiter.Pipe => "|",
                Delimiter.Unknown => "\0",
                _ => throw new NotImplementedException()
            }, config.Delimiter);
コード例 #20
0
        private void DeleteCsvColumns(Collection <string> deleteColumns)
        {
            StringBuilder stringBuilder = new StringBuilder();

            using (StreamReader streamReader = new StreamReader(CsvPathFileName, (Encoding == null ? Encoding.Default : Encoding)))
            {
                string           currentLine  = currentLine = streamReader.ReadLine();
                int              lineNumber   = 1;
                Collection <int> columnIndexs = new Collection <int>();
                var              columns      = currentLine.Split(Delimiter.ToCharArray()).ToList();
                foreach (var item in deleteColumns)
                {
                    columnIndexs.Add(columns.IndexOf(item));
                }
                foreach (var item in columnIndexs)
                {
                    columns.RemoveAt(item);
                }
                stringBuilder.AppendLine(string.Join(Delimiter, columns));

                while (!string.IsNullOrEmpty(currentLine = streamReader.ReadLine()))
                {
                    List <string> recordValues = currentLine.Split(Delimiter.ToCharArray()).ToList();
                    foreach (var item in columnIndexs)
                    {
                        recordValues.RemoveAt(item);
                    }
                    stringBuilder.AppendLine(string.Join(Delimiter, recordValues));
                    lineNumber++;
                }
            }
            File.WriteAllText(CsvPathFileName, stringBuilder.ToString(), Encoding);
        }
コード例 #21
0
ファイル: ToolsIOCSV.cs プロジェクト: kozzion/KozzionCSharp
        public static string GetDelimiterString(Delimiter delimiter)
        {
            switch (delimiter)
            {
            case Delimiter.Tab:
                return(new string(new char [] { (char)9 }));

            case Delimiter.Space:
                return(" ");

            case Delimiter.SemiColon:
                return(";");

            case Delimiter.DoubleQoute:
                char [] doublequote = { (char)34 };
                return(new string(new char [] { (char)34 }));

            case Delimiter.SingleQoute:
                return("'");

            case Delimiter.Comma:
                return(",");

            case Delimiter.None:
                return("");

            default:
                throw new Exception("unknown delimitor");
            }
        }
コード例 #22
0
        private void AddCsvColumns(List <string> addedColumns)
        {
            StringBuilder stringBuilder = new StringBuilder();

            using (StreamReader streamReader = new StreamReader(CsvPathFileName, (Encoding == null ? Encoding.Default : Encoding)))
            {
                string           currentLine  = currentLine = streamReader.ReadLine();
                int              lineNumber   = 1;
                Collection <int> columnIndexs = new Collection <int>();
                var              newColumns   = currentLine.Split(Delimiter.ToCharArray()).Concat(addedColumns).ToList();

                stringBuilder.AppendLine(string.Join(Delimiter, newColumns));

                while (!string.IsNullOrEmpty(currentLine = streamReader.ReadLine()))
                {
                    for (int i = 0; i < addedColumns.Count; i++)
                    {
                        currentLine += Delimiter;
                    }
                    stringBuilder.AppendLine(currentLine);
                    lineNumber++;
                }
            }
            File.WriteAllText(CsvPathFileName, stringBuilder.ToString(), Encoding);
        }
コード例 #23
0
ファイル: ToolsIOCSV.cs プロジェクト: kozzion/KozzionCSharp
 public static void WriteCSVFile(
     string file_path,
     string[,] table,
     Delimiter field_delimiter)
 {
     WriteCSVFile(file_path, table, field_delimiter, Delimiter.None);
 }
コード例 #24
0
        private void UpdateCsvColumns(Dictionary <string, FeatureSourceColumn> updateColumns)
        {
            StringBuilder stringBuilder = new StringBuilder();

            using (StreamReader streamReader = new StreamReader(CsvPathFileName, (Encoding == null ? Encoding.Default : Encoding)))
            {
                string           currentLine  = currentLine = streamReader.ReadLine();
                int              lineNumber   = 1;
                Collection <int> columnIndexs = new Collection <int>();
                string[]         newColumns   = currentLine.Split(Delimiter.ToCharArray());

                for (int i = 0; i < newColumns.Length; i++)
                {
                    if (updateColumns.ContainsKey(newColumns[i]))
                    {
                        newColumns[i] = updateColumns[newColumns[i]].ColumnName;
                    }
                }

                stringBuilder.AppendLine(string.Join(Delimiter, newColumns));

                while (!string.IsNullOrEmpty(currentLine = streamReader.ReadLine()))
                {
                    stringBuilder.AppendLine(currentLine);
                    lineNumber++;
                }
            }
            File.WriteAllText(CsvPathFileName, stringBuilder.ToString(), Encoding);
        }
コード例 #25
0
 private MongoDB.Bson.BsonDocument Aggrigate(MongoDB.Bson.BsonDocument _doc)
 {
     try
     {
         string   destinationValue = "";
         string[] sourceKeyArr     = SourceKeys.Split(',');
         foreach (string sourceKey in sourceKeyArr)
         {
             if (_doc[sourceKey] != null)
             {
                 if (this.SourceKeyTransformation.Key == sourceKey)
                 {
                     destinationValue += this.SourceKeyTransformation.Execute(_doc);
                 }
                 else
                 {
                     destinationValue += _doc[sourceKey] + Delimiter;
                 }
             }
         }
         if (destinationValue.EndsWith(Delimiter))
         {
             destinationValue = destinationValue.TrimEnd(Delimiter.ToCharArray());
         }
         _doc.Add(DestinationKey, destinationValue);
     }
     catch (Exception exp)
     {
         Console.WriteLine(exp.Message);
         throw;
     }
     return(_doc);
 }
コード例 #26
0
 public void WriteErrorMessage(string fileName)
 {
     using (StreamWriter streamWriter = new StreamWriter(fileName))
     {
         StringBuilder stringBuilder = new StringBuilder();
         foreach (DataColumn dataColumn in ErrorTable.Columns)
         {
             stringBuilder.Append(dataColumn.ColumnName + Delimiter);
         }
         if (stringBuilder.Length > 0)
         {
             streamWriter.WriteLine(stringBuilder.ToString().TrimEnd(Delimiter.ToCharArray()));
         }
         foreach (DataRow dataRow in ErrorTable.Rows)
         {
             stringBuilder.Clear();
             foreach (object obj in dataRow.ItemArray)
             {
                 string field = obj.ToString();
                 if (field.IndexOf(Delimiter) >= 0)
                 {
                     field = "\"" + field.Replace("\"", "\"\"") + "\"";
                 }
                 stringBuilder.Append(field + Delimiter);
             }
             if (stringBuilder.Length > 0)
             {
                 streamWriter.WriteLine(stringBuilder.ToString().TrimEnd(Delimiter.ToCharArray()));
             }
         }
     }
 }
コード例 #27
0
ファイル: Label.cs プロジェクト: taukita/mazes-and-minotaurs
        protected override void Drawing(ITerminal <TGlyph, TColor> terminal)
        {
            if (Text == null)
            {
                return;
            }
            var y     = 0;
            var lines = Text.Split(Delimiter.ToArray());

            foreach (var line in lines)
            {
                var parts = line.Split(Width);
                foreach (var part in parts)
                {
                    terminal.DrawString(Left, Top + y, part, ColorTheme.Foreground, ColorTheme.Background);
                    y++;
                    if (y >= Height)
                    {
                        break;
                    }
                }
                if (y >= Height)
                {
                    break;
                }
            }
        }
コード例 #28
0
ファイル: LogFile.cs プロジェクト: zhoufengzd/DotNet
 public static void LogIt <T>(string filePath, IEnumerable <T> collection)
 {
     using (LogFile log = new LogFile(filePath))
     {
         log.Write(Delimiter.ToString <T>(collection));
     }
 }
コード例 #29
0
ファイル: Lexic.cs プロジェクト: Damian109/VBTranslator
        //Функция заполнения таблиц ключевых слов и разделителей
        private void FillTerminalsAndDelimiters(Table tTer, Table tDel)
        {
            //Создаем таблицу ключевых слов
            //Количество
            Byte NT = 10;

            //Значения
            String[] strT = { "dim", "as", "select", "case", "end", "integer", "to", "else", "double", "decimal" };
            //Переписываем в лексемы
            Lexem[] Ter = new Lexem[NT];
            for (int i = 0; i < NT; i++)
            {
                Ter[i] = new Identifier();
                Ter[i].Set(strT[i]);
            }
            //Добавляем в таблицу
            tTer.SetTable(Ter);

            //Создаем таблицу разделителей
            //Количество
            Byte ND = 9;

            //Значения
            String[] strD = { "=", "(", ")", "*", "/", "-", "+", "#", "," };
            //Переписываем в лексемы
            Lexem[] Del = new Lexem[ND];
            for (int i = 0; i < ND; i++)
            {
                Del[i] = new Delimiter();
                Del[i].Set(strD[i]);
            }
            //Добавляем в таблицу
            tDel.SetTable(Del);
        }
コード例 #30
0
        protected override string buildIsosResultOutput(IsosResult result)
        {
            var data = new List <string>
            {
                result.ScanSet.PrimaryScanNumber.ToString(),
                result.IsotopicProfile.ChargeState.ToString(),
                DblToString(result.IntensityAggregate, 4, true),                    // Abundance
                DblToString(result.IsotopicProfile.GetMZofMostAbundantPeak(), 5),   // Traditionally, the m/z of the most abundant peak is reported. If you want the m/z of the mono peak, get the monoIsotopic mass
                DblToString(result.IsotopicProfile.Score, 4),                       // Fit score
                DblToString(result.IsotopicProfile.AverageMass, 5),
                DblToString(result.IsotopicProfile.MonoIsotopicMass, 5),
                DblToString(result.IsotopicProfile.MostAbundantIsotopeMass, 5),
                DblToString(result.IsotopicProfile.GetFWHM(), 4),
                DblToString(result.IsotopicProfile.GetSignalToNoise(), 2),
                DblToString(result.IsotopicProfile.GetMonoAbundance(), 4, true),
                DblToString(result.IsotopicProfile.GetMonoPlusTwoAbundance(), 4, true),
                ResultValidators.ResultValidationUtils.GetStringFlagCode(result.Flags),
                DblToString(result.InterferenceScore, 5)
            };

            // Abundance
            //traditionally, the m/z of the most abundant peak is reported. If you want the m/z of the mono peak, get the monoIsotopic mass
            // Fit score
            // Uncomment to write out the fit_count_basis
            //            //data.Add(result.IsotopicProfile.ScoreCountBasis);				// Number of points used for the fit score

            return(string.Join(Delimiter.ToString(), data));
        }
コード例 #31
0
 private void WriteDelimiters(BinaryWriter bw, uint OffsetX, uint OffsetY, uint RealX, uint RealY, sbyte Z, ushort KRGraphic)
 {
     List<Delimiter> delimiters = new List<Delimiter>();
     if (OffsetX == 0 && RealX>0)
     {
         Delimiter d = new Delimiter();
         d.z = Z;
         d.graphic = KRGraphic;
         d.direction = DelimiterDirection.LEFT;
         delimiters.Add(d);
     }
     if (OffsetX == 63 && RealX<mapwidth-1)
     {
         Delimiter d = new Delimiter();
         d.z = Z;
         d.graphic = KRGraphic;
         d.direction = DelimiterDirection.RIGHT;
         delimiters.Add(d);
     }
     if (OffsetY == 0 && RealY>0)
     {
         Delimiter d = new Delimiter();
         d.z = Z;
         d.graphic = KRGraphic;
         d.direction = DelimiterDirection.TOP;
         delimiters.Add(d);
     }
     if (OffsetY == 63 && RealX<mapheight-1)
     {
         Delimiter d = new Delimiter();
         d.z = Z;
         d.graphic = KRGraphic;
         d.direction = DelimiterDirection.BOTTOM;
         delimiters.Add(d);
     }
     if ((OffsetX == 0) && (OffsetY == 0) && RealX > 0 && RealY > 0)
     {
         Delimiter d = new Delimiter();
         d.z = Z;
         d.graphic = KRGraphic;
         d.direction = DelimiterDirection.TOPLEFT;
         delimiters.Add(d);
     }
     if ((OffsetX == 0) && (OffsetY == 63) && RealX > 0 && RealX < mapheight - 1)
     {
         Delimiter d = new Delimiter();
         d.z = Z;
         d.graphic = KRGraphic;
         d.direction = DelimiterDirection.BOTTOMLEFT;
         delimiters.Add(d);
     }
     if ((OffsetX == 63) && (OffsetY == 0) && RealX < mapwidth - 1 && RealY > 0)
     {
         Delimiter d = new Delimiter();
         d.z = Z;
         d.graphic = KRGraphic;
         d.direction = DelimiterDirection.TOPRIGHT;
         delimiters.Add(d);
     }
     if ((OffsetX == 63) && (OffsetY == 63) && RealX < mapwidth - 1 && RealX < mapheight - 1)
     {
         Delimiter d = new Delimiter();
         d.z = Z;
         d.graphic = KRGraphic;
         d.direction=DelimiterDirection.BOTTOMRIGHT;
         delimiters.Add(d);
     }
     if (delimiters.Count > 0)
     {
         Delimiter[] delmiterarr = delimiters.ToArray();
         uint i;
         for (i = 0; i<delmiterarr.Length; i++)
         {
             if (i == 0)
                 bw.Write((byte)delmiterarr.Length);
             else
                 bw.Write((byte)0);
             bw.Write((byte)delmiterarr[i].direction);
             bw.Write(delmiterarr[i].z);
             bw.Write(delmiterarr[i].graphic);
             bw.Write((byte)delmiterarr[i].unk);
         }                    
     }
     
 }