当前位置: 首页>>代码示例>>C#>>正文


C# Workspace.ReadBuffer方法代码示例

本文整理汇总了C#中Workspace.ReadBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.ReadBuffer方法的具体用法?C# Workspace.ReadBuffer怎么用?C# Workspace.ReadBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Workspace的用法示例。


在下文中一共展示了Workspace.ReadBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main(string[] args)
        {
            var @out = Console.Out;
            //var @out = new StreamWriter("output.json");
            var error = Console.Error;

            if (args.Length != 3)
            {
                error.WriteLine("Invalid arguments parameters");
                Environment.Exit(-1);
            }

            var fileName = args[0];
            var path = args[1];
            var value = args[2];

            var source = JArray.Parse(File.ReadAllText(path));
            var dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(value);
            var source2 =
                from c in source
                where c["Tag"] != null
                select new TagInfo
                {
                    Accession = c["Accession"].ToObject<string>(),
                    Tag = c["Tag"].ToObject<string>(),
                    BeginIndex = c["LocationBegin"].ToObject<int>(),
                    EndIndex = c["LocationEnd"].ToObject<int>()
                };

            var source3 = (from c in source2
                           orderby c.Accession, c.BeginIndex
                           group c by c.Accession into g
                           select g).ToList();

            var uniprot = Biosek.Formats.UniProt.uniprot.LoadFromFile(fileName);
            var workspace = new Workspace();
            foreach (var site in dictionary)
            {
                var list = (from accession in source3
                            let proteinsInAccession = accession.ToList()
                            from index in Enumerable.Range(1, proteinsInAccession.Count - 1)
                            let proteinA = proteinsInAccession[index - 1]
                            let proteinB = proteinsInAccession[index]
                            where proteinA.EndIndex == proteinB.BeginIndex - 1 &&
                            string.Concat(proteinA.Tag, "-", proteinB.Tag) == site.Key
                            select Tuple.Create(proteinA, proteinB)).ToList();

                error.WriteLine("Found {0} cleavage sites for {1}", list.Count, site.Key);

                if (site.Value is JArray)
                {
                    foreach (var current in site.Value as JArray)
                    {
                        var windowString = current.ToObject<string>();
                        Sample(site.Key, uniprot, list, windowString, workspace);
                    }
                }
                else
                {
                    Sample(site.Key, uniprot, list, site.Value as string, workspace);
                }

            }
            var jsonSerializer = new JsonSerializer();
            var value2 = from c in workspace.Dataset
                         select new
                         {
                             tag = c.Class,
                             positives = from d in c.Positives.Entries
                                         select new { i = d.Begin, c = d.Samples },
                             negatives = from d in c.Negatives.Entries
                                         select new { i = d.Begin, c = d.Samples }
                         };
            //jsonSerializer.Formatting = Formatting.Indented;
            jsonSerializer.Serialize(@out, new { buffer = workspace.ReadBuffer(0, workspace.BufferLength), samples = value2 });
            @out.Close();
        }
开发者ID:jairov4,项目名称:accel-oil,代码行数:77,代码来源:Program.cs


注:本文中的Workspace.ReadBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。