Exemplo n.º 1
0
        /// <summary>
        /// Create new instance of <see cref="TextureDescriptor"/> struct describing 2D texture.
        /// </summary>
        /// <param name="width">The width</param>
        /// <param name="height">The height</param>
        /// <param name="mipMap">Whether to compute mip levels from width and height, otherwise 1.</param>
        /// <param name="arrayLayers">The array layers count.</param>
        /// <param name="format">The <see cref="PixelFormat"/></param>
        /// <param name="textureUsage">The texture usage.</param>
        /// <param name="samples">The number of samples.</param>
        /// <returns></returns>
        public static TextureDescriptor Texture2D(
            int width,
            int height,
            bool mipMap,
            int arrayLayers           = 1,
            PixelFormat format        = PixelFormat.RGBA8UNorm,
            TextureUsage textureUsage = TextureUsage.ShaderRead,
            SampleCount samples       = SampleCount.Count1)
        {
            int mipLevels = 1;

            if (mipMap)
            {
                while (height > 1 || width > 1)
                {
                    ++mipLevels;

                    if (height > 1)
                    {
                        height >>= 1;
                    }

                    if (width > 1)
                    {
                        width >>= 1;
                    }
                }
            }

            width       = Math.Max(width, 1);
            height      = Math.Max(height, 1);
            arrayLayers = Math.Max(arrayLayers, 1);

            return(new TextureDescriptor(TextureType.Texture2D, width, height, 1, mipLevels, arrayLayers, format, textureUsage, samples));
        }
Exemplo n.º 2
0
    void CheckShaderStates(bool force)
    {
        if (!force)
        {
            if (__useNoise == (NoiseTexture != null) &&
                __cutoffEnabled == CutoffEnabled &&
                __lumContribution == LumContribution &&
                __occlusionColor == OcclusionColor &&
                __samples == Samples)
            {
                return;
            }
        }

        Material.shaderKeywords = new string[]
        {
            (NoiseTexture != null) ? "NOISE_ON" : "NOISE_OFF",
            (CutoffEnabled) ? "DISTANCE_CUTOFF_ON" : "DISTANCE_CUTOFF_OFF",
            (LumContribution > 0.0001f) ? "LUM_CONTRIB_ON" : "LUM_CONTRIB_OFF",
            (OcclusionColor == Color.black) ? "CUSTOM_COLOR_OFF" : "CUSTOM_COLOR_ON",
            (Samples == SampleCount.Low) ? "SAMPLES_LOW"
                                : (Samples == SampleCount.Medium) ? "SAMPLES_MEDIUM"
                                : (Samples == SampleCount.High) ? "SAMPLES_HIGH"
                                : "SAMPLES_VERY_LOW"
        };

        __useNoise        = (NoiseTexture != null);
        __cutoffEnabled   = CutoffEnabled;
        __lumContribution = LumContribution;
        __occlusionColor  = OcclusionColor;
        __samples         = Samples;
    }
Exemplo n.º 3
0
 /// <summary>
 /// Configure the pass with the source and destination to execute on.
 /// </summary>
 /// <param name="source">Source Render Target</param>
 /// <param name="destination">Destination Render Target</param>
 public void Setup(RenderTextureDescriptor baseDescriptor, SampleCount sampleCount, RenderTargetHandle source, RenderTargetHandle intermediate, RenderTargetHandle destination)
 {
     this.source       = source;
     this.destination  = destination;
     this.intermediate = intermediate;
     descriptor        = baseDescriptor;
     this.sampleCount  = sampleCount;
 }
 /// <summary>
 /// Configure the pass
 /// </summary>
 public void Setup(
     RenderTextureDescriptor baseDescriptor,
     RenderTargetHandle colorAttachmentHandle,
     SampleCount samples)
 {
     this.colorAttachmentHandle = colorAttachmentHandle;
     this.samples = samples;
     descriptor   = baseDescriptor;
 }
        /// <summary>
        /// Configure the pass before execution
        /// </summary>
        /// <param name="baseDescriptor">Current target descriptor</param>
        /// <param name="colorAttachmentHandle">Color attachment to render into</param>
        /// <param name="depthAttachmentHandle">Depth attachment to render into</param>
        /// <param name="configuration">Specific render configuration</param>
        public void Setup(
            RenderTextureDescriptor baseDescriptor,
            RenderTargetHandle colorAttachmentHandle,
            RenderTargetHandle depthAttachmentHandle,
            RendererConfiguration configuration,
            SampleCount samples)
        {
            this._ColorAttachmentHandle = colorAttachmentHandle;
            this._DepthAttachmentHandle = depthAttachmentHandle;
            _Descriptor            = baseDescriptor;
            _RendererConfiguration = configuration;

            if ((int)samples > 1)
            {
                baseDescriptor.bindMS      = false;
                baseDescriptor.msaaSamples = (int)samples;
            }

            baseDescriptor.colorFormat     = RenderTextureFormat.ARGBHalf;
            baseDescriptor.depthBufferBits = 0;
            _DescriptorAC = baseDescriptor;

            baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RHalf)
                ? RenderTextureFormat.RHalf
                : RenderTextureFormat.ARGBHalf;
            _DescriptorAA = baseDescriptor;

            _AccumColorHandle.Init("_AccumColor");
            _AccumGIHandle.Init("_AccumGI");
            _AccumAlphaHandle.Init("_AccumAlpha");

            _AccumBinding = new RenderTargetBinding(new RenderTargetIdentifier[]
            {
                _AccumColorHandle.Identifier(),
                _AccumGIHandle.Identifier(),
                _AccumAlphaHandle.Identifier(),
            },
                                                    new RenderBufferLoadAction[]
            {
                RenderBufferLoadAction.DontCare,
                RenderBufferLoadAction.DontCare,
                RenderBufferLoadAction.DontCare,
            },
                                                    new RenderBufferStoreAction[]
            {
                RenderBufferStoreAction.Store,
                RenderBufferStoreAction.Store,
                RenderBufferStoreAction.Store,
            },
                                                    _DepthAttachmentHandle.Identifier(),
                                                    RenderBufferLoadAction.Load,
                                                    RenderBufferStoreAction.DontCare);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Create new instance of <see cref="TextureDescriptor"/> struct describing 2D texture.
 /// </summary>
 /// <param name="width">The width</param>
 /// <param name="height">The height</param>
 /// <param name="mipLevels">The number of mip levels.</param>
 /// <param name="arrayLayers">The array layers count.</param>
 /// <param name="format">The <see cref="PixelFormat"/></param>
 /// <param name="textureUsage">The texture usage</param>
 /// <param name="samples">The number of samples.</param>
 /// <returns></returns>
 public static TextureDescriptor Texture2D(
     int width,
     int height,
     int mipLevels             = 1,
     int arrayLayers           = 1,
     PixelFormat format        = PixelFormat.RGBA8UNorm,
     TextureUsage textureUsage = TextureUsage.ShaderRead,
     SampleCount samples       = SampleCount.Count1)
 {
     width       = Math.Max(width, 1);
     height      = Math.Max(height, 1);
     mipLevels   = Math.Max(mipLevels, 1);
     arrayLayers = Math.Max(arrayLayers, 1);
     return(new TextureDescriptor(TextureType.Texture2D, width, height, 1, mipLevels, arrayLayers, format, textureUsage, samples));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextureDescriptor"/> struct.
 /// </summary>
 /// <param name="textureType">The texture type</param>
 /// <param name="width">The width</param>
 /// <param name="height">The height</param>
 /// <param name="depth">The depth</param>
 /// <param name="mipLevels">The mipLevels</param>
 /// <param name="arrayLayers">The array layers</param>
 /// <param name="format">The <see cref="PixelFormat"/></param>
 /// <param name="usage">The texture usage</param>
 /// <param name="samples">The samples</param>
 public TextureDescriptor(TextureType textureType,
                          int width, int height, int depth,
                          int mipLevels, int arrayLayers,
                          PixelFormat format,
                          TextureUsage usage,
                          SampleCount samples)
 {
     TextureType = textureType;
     Width       = width;
     Height      = height;
     Depth       = depth;
     MipLevels   = mipLevels;
     ArrayLayers = arrayLayers;
     Format      = format;
     Usage       = usage;
     Samples     = samples;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Configure the pass
        /// </summary>
        public void Setup(
            RenderTextureDescriptor baseDescriptor,
            RenderTargetHandle depthAttachmentHandle,
            SampleCount samples)
        {
            this.depthAttachmentHandle     = depthAttachmentHandle;
            baseDescriptor.colorFormat     = RenderTextureFormat.Depth;
            baseDescriptor.depthBufferBits = kDepthBufferBits;

            if ((int)samples > 1)
            {
                baseDescriptor.bindMS      = (int)samples > 1;
                baseDescriptor.msaaSamples = (int)samples;
            }

            descriptor = baseDescriptor;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Create a new instance of <see cref="Texture"/> class.
        /// </summary>
        /// <param name="device">The creation device.</param>
        /// <param name="descriptor">The texture descriptor.</param>
        protected Texture(GraphicsDevice device, ref TextureDescriptor descriptor)
            : base(device, GraphicsResourceType.Texture, GraphicsResourceUsage.Default)
        {
            Guard.IsTrue(descriptor.TextureType != TextureType.Unknown, nameof(descriptor), $"TextureType cannot be {nameof(TextureType.Unknown)}");
            Guard.MustBeGreaterThanOrEqualTo(descriptor.Width, 1, nameof(descriptor.Width));
            Guard.MustBeGreaterThanOrEqualTo(descriptor.Height, 1, nameof(descriptor.Height));
            Guard.MustBeGreaterThanOrEqualTo(descriptor.Depth, 1, nameof(descriptor.Depth));

            TextureType = descriptor.TextureType;
            Width       = descriptor.Width;
            Height      = descriptor.Height;
            Depth       = descriptor.Depth;
            MipLevels   = descriptor.MipLevels;
            ArrayLayers = descriptor.ArrayLayers;
            Format      = descriptor.Format;
            Usage       = descriptor.Usage;
            Samples     = descriptor.Samples;
        }
        protected override void Window(int windowId)
        {
            EditorGUILayout.BeginHorizontal();
            m_sampleCount = (SampleCount)SynthGraphEditorFactory.EnumFieldWithLabel( m_sampleCount, "Sample Count" );
            m_fftWindow   = (FFTWindow)SynthGraphEditorFactory.EnumFieldWithLabel( m_fftWindow, "Window Type" );
            EditorGUILayout.EndHorizontal();

            if ( ( m_windowRect.width >= MIN_GRAPH_WIDTH) && ( m_windowRect.height >= MIN_GRAPH_HEIGHT ) )
            {
                DrawGrid();

                if ( m_playbackObject == null )
                {
                    SetRequiresContiniousUpdates( false );
                }
                else
                {
                    DrawPlaybackSpectrum();
                }
            }
        }
Exemplo n.º 11
0
    void CheckShaderStates(bool force)
    {
        if (!HighPrecision)
        {
            m_Camera.depthTextureMode |= DepthTextureMode.Depth;
        }

        if (!force &&
            __aoMode == Mode &&
            __useNoise == (NoiseTexture != null) &&
            __highPrecision == HighPrecision &&
            __lumContribution == LumContribution &&
            __occlusionColor == OcclusionColor &&
            __samples == Samples)
        {
            return;
        }

        Material.shaderKeywords = new string[]
        {
            (NoiseTexture != null) ? "NOISE_ON" : "NOISE_OFF",
            (HighPrecision) ? "HIGH_PRECISION_ON" : "HIGH_PRECISION_OFF",
            (LumContribution > 0.0001f) ? "LUM_CONTRIB_ON" : "LUM_CONTRIB_OFF",
            (OcclusionColor == Color.black) ? "CUSTOM_COLOR_OFF" : "CUSTOM_COLOR_ON",
            (Samples == SampleCount.Low) ? "SAMPLES_LOW"
                                : (Samples == SampleCount.Medium) ? "SAMPLES_MEDIUM"
                                : (Samples == SampleCount.High) ? "SAMPLES_HIGH"
                                : "SAMPLES_VERY_LOW"
        };

        __useNoise        = (NoiseTexture != null);
        __highPrecision   = HighPrecision;
        __lumContribution = LumContribution;
        __occlusionColor  = OcclusionColor;
        __samples         = Samples;
        __aoMode          = Mode;
    }
Exemplo n.º 12
0
 //  Sort largest count first
 int scomp(SampleCount a, SampleCount b)
 {
     return b.Count - a.Count;
 }
Exemplo n.º 13
0
        private void cmdSampInfo_Click(object sender, EventArgs e)
        {
            int    Hour, Minute, Second;
            int    Month, Day, Year;
            int    SampleInterval, SampleCount;
            int    StartDate, StartTime;
            int    Postfix;
            string PostfixStr, StartDateStr;
            string StartTimeStr;

            PostfixStr     = "";
            SampleInterval = 0;
            SampleCount    = 0;
            StartDate      = 0;
            StartTime      = 0;

            // Get the sample information
            //  Parameters:
            //    Filename            :name of file to get information from
            //    SampleInterval      :time between samples
            //    SampleCount         :number of samples in the file
            //    StartDate           :date of first sample
            //    StartTime           :time of first sample

            ULStat = logger.GetSampleInfo(ref SampleInterval, ref SampleCount, ref StartDate, ref StartTime);
            if (ULStat.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                lblComment.Text = ULStat.Message + ".";
            }
            else
            {
                //Parse the date from the StartDate parameter
                Month        = (StartDate >> 8) & 0xff;
                Day          = StartDate & 0xff;
                Year         = (StartDate >> 16) & 0xffff;
                StartDateStr = Month.ToString("00") + "/" +
                               Day.ToString("00") + "/" + Year.ToString("0000");

                //Parse the time from the StartTime parameter
                Hour    = (StartTime >> 16) & 0xffff;
                Minute  = (StartTime >> 8) & 0xff;
                Second  = StartTime & 0xff;
                Postfix = (StartTime >> 24) & 0xff;
                if (Postfix == 0)
                {
                    PostfixStr = " AM";
                }
                if (Postfix == 1)
                {
                    PostfixStr = " PM";
                }
                StartTimeStr = Hour.ToString("00") + ":" +
                               Minute.ToString("00") + ":" + Second.ToString("00")
                               + PostfixStr;

                txtResults.Text =
                    "The sample properties of '" + logger.FileName + "' are:" +
                    "\r\n" + "\r\n" + "\t" + "SampleInterval: " + "\t" +
                    SampleInterval.ToString("0") + "\r\n" + "\t" + "SampleCount: " +
                    "\t" + SampleCount.ToString("0") + "\r\n" + "\t" +
                    "Start Date: " + "\t" + StartDateStr + "\r\n" + "\t" +
                    "Start Time: " + "\t" + StartTimeStr;
            }
        }
Exemplo n.º 14
0
 public Device(IntPtr instance, IntPtr phy, IntPtr dev, uint qFamIdx, SampleCount samples = SampleCount.Sample_1, uint qIndex = 0)
 {
     handle = NativeMethods.vkvg_device_create_multisample(instance, phy, dev, qFamIdx, qIndex, samples, false);
 }
Exemplo n.º 15
0
 internal static extern IntPtr vkvg_device_create_multisample(IntPtr inst, IntPtr phy, IntPtr vkdev, uint qFamIdx, uint qIndex, SampleCount samples, bool deferredResolve);
Exemplo n.º 16
0
 /// <summary>
 /// Configure the pass
 /// </summary>
 public void Setup(
     RenderTextureDescriptor baseDescriptor, RenderTargetHandle depthNormalsHandle, RenderTargetHandle depthAttachmentHandle, bool depthPrepass, SampleCount samples)
 {
     this.depthNormalsHandle        = depthNormalsHandle;
     this.depthAttachmentHandle     = depthAttachmentHandle;
     baseDescriptor.depthBufferBits = depthPrepass ? 0 : kDepthBufferBits;
     baseDescriptor.colorFormat     = RenderTextureFormat.ARGB32;
     if ((int)samples > 1 && depthPrepass)
     {
         baseDescriptor.bindMS      = false;
         baseDescriptor.msaaSamples = (int)samples;
     }
     descriptor = baseDescriptor;
     this.isDepthPrepassEnabled = depthPrepass;
 }
	void CheckShaderStates(bool force)
	{
		if (!force)
		{
			if (__useNoise == (NoiseTexture != null) &&
				__cutoffEnabled == CutoffEnabled &&
				__lumContribution == LumContribution &&
				__occlusionColor == OcclusionColor &&
				__samples == Samples)
			{
				return;
			}
		}

		Material.shaderKeywords = new string[]
		{
			(NoiseTexture != null) ? "NOISE_ON" : "NOISE_OFF",
			(CutoffEnabled) ? "DISTANCE_CUTOFF_ON" : "DISTANCE_CUTOFF_OFF",
			(LumContribution > 0.0001f) ? "LUM_CONTRIB_ON" : "LUM_CONTRIB_OFF",
			(OcclusionColor == Color.black) ? "CUSTOM_COLOR_OFF" : "CUSTOM_COLOR_ON",
			(Samples == SampleCount.Low) ? "SAMPLES_LOW"
				: (Samples == SampleCount.Medium) ? "SAMPLES_MEDIUM"
				: (Samples == SampleCount.High) ? "SAMPLES_HIGH"
				: "SAMPLES_VERY_LOW"
		};

		__useNoise = (NoiseTexture != null);
		__cutoffEnabled = CutoffEnabled;
		__lumContribution = LumContribution;
		__occlusionColor = OcclusionColor;
		__samples = Samples;
	}
    public override IEnumerable<string> Process()
    {
      var sampleInfos = new List<SampleCount>();
      using (var sw = new StreamWriter(options.OutputFile))
      using (var swUnfiltered = new StreamWriter(Path.ChangeExtension(options.OutputFile, ".unfiltered.tsv")))
      {
        var header = "File\tCategory\tName\tUniqueRead\tUniqueT2CRead\tUniqueT2CRate\tAvergeT2CIn10BasesOfUniqueRead\tAvergeT2COfUniqueRead\tTotalRead\tTotalT2CRead\tTotalT2CRate\tT2C_pvalue\tAverageT2CIn10BasesOfTotalRead\tAverageT2COfTotalRead";
        swUnfiltered.WriteLine(header);
        sw.WriteLine(header);

        var inputFiles = options.GetCountXmlFiles();

        foreach (var file in inputFiles)
        {
          var sc = new SampleCount();
          sc.Name = file.Name;
          sampleInfos.Add(sc);

          var subjects = new FeatureItemGroupXmlFormat().ReadFromFile(file.File);
          var group = subjects.GroupBy(m => m[0].Name.StringBefore(":")).ToList();
          foreach (var g in group)
          {
            var items = g.ToList();
            foreach (var item in items)
            {
              var queries = new HashSet<string>(item.GetAlignedLocations().ConvertAll(l => l.Parent.Qname));
              List<FeatureSamLocation> locs = new List<FeatureSamLocation>();
              foreach (var l in item)
              {
                foreach (var loc in l.Locations)
                {
                  foreach (var sl in loc.SamLocations)
                  {
                    if (queries.Contains(sl.SamLocation.Parent.Qname))
                    {
                      locs.Add(sl);
                      queries.Remove(sl.SamLocation.Parent.Qname);
                    }
                  }
                }
              }

              var t2c = locs.Where(m => m.NumberOfNoPenaltyMutation > 0).ToList();
              var ave_t2c_uniquereads = (t2c.Count > 0) ? t2c.ConvertAll(m => m.NumberOfNoPenaltyMutation * 10.0 / m.SamLocation.Parent.Sequence.Length).Average() : 0.0;
              var ave_t2c_perread_uniquereads = (t2c.Count > 0) ? t2c.ConvertAll(m => m.NumberOfNoPenaltyMutation).Average() : 0.0;

              double ave_t2c_allreads = 0.0;
              double ave_t2c_perread_allreads = 0.0;
              if (t2c.Count > 0)
              {
                List<double> values = new List<double>();
                List<double> perread_values = new List<double>();
                foreach (var t2citem in t2c)
                {
                  var v = t2citem.NumberOfNoPenaltyMutation * 10.0 / t2citem.SamLocation.Parent.Sequence.Length;
                  for (int i = 0; i < t2citem.SamLocation.Parent.QueryCount; i++)
                  {
                    values.Add(v);
                    perread_values.Add(t2citem.NumberOfNoPenaltyMutation);
                  }
                }
                ave_t2c_allreads = values.Average();
                ave_t2c_perread_allreads = perread_values.Average();
              }

              var totalCount = locs.Sum(l => l.SamLocation.Parent.QueryCount);
              var totalT2CCount = t2c.Sum(l => l.SamLocation.Parent.QueryCount);
              var pvalue = SmallRNAT2CMutationBuilder.CalculateT2CPvalue(totalCount, totalT2CCount, options.ExpectRate);
              var t2crate = totalT2CCount == 0 ? 0 : totalT2CCount * 1.0 / totalCount;
              var value = string.Format("{0}\t{1}\t{2}\t{3:0.###}\t{4:0.###}\t{5:0.###}\t{6:0.###}\t{7:0.###}\t{8:0.###}\t{9:0.###}\t{10:0.###}\t{11:0.###E+0}\t{12:0.###}\t{13:0.###}",
                file.Name,
                g.Key,
                item.Name,
                locs.Count,
                t2c.Count,
                t2c.Count * 1.0 / locs.Count,
                ave_t2c_uniquereads,
                ave_t2c_perread_uniquereads,
                totalCount,
                totalT2CCount,
                t2crate,
                pvalue,
                ave_t2c_allreads,
                ave_t2c_perread_allreads);

              swUnfiltered.WriteLine(value);
              if(!ParclipSmallRNAT2CBuilder.Accept(pvalue, totalCount, totalT2CCount, options.Pvalue, options.MinimumCount, options.ExpectRate))
              {
                continue;
              }

              sw.WriteLine(value);

              sc.GoodReadCount += totalCount;
              sc.GoodT2CReadCount += totalT2CCount;
              if (g.Key.Equals(SmallRNAConsts.miRNA))
              {
                sc.MiRNACount++;
              }
              else if (g.Key.Equals(SmallRNAConsts.tRNA))
              {
                sc.TRNACount++;
              }
              else
              {
                sc.OtherSmallRNACount++;
              }
            }
          }
        }
      }
      using (var sw = new StreamWriter(options.OutputFile + ".summary"))
      {
        sw.WriteLine("File\tTotalRead\tT2CRead\tT2CRate\tSmallRNA\tMicroRNA\ttRNA\tOtherSmallRNA");
        foreach (var si in sampleInfos)
        {
          sw.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}",
            si.Name,
            si.GoodReadCount,
            si.GoodT2CReadCount,
            si.GoodT2CRate,
            si.SmallRNACount,
            si.MiRNACount,
            si.TRNACount,
            si.OtherSmallRNACount);
        }
      }

      return new[] { Path.GetFullPath(options.OutputFile), Path.GetFullPath(options.OutputFile + ".summary") };
    }
        /// <summary>
        /// Configure the pass before execution
        /// </summary>
        /// <param name="baseDescriptor">Current target descriptor</param>
        /// <param name="colorAttachmentHandle">Color attachment to render into</param>
        /// <param name="depthAttachmentHandle">Depth attachment to render into</param>
        /// <param name="configuration">Specific render configuration</param>
        public bool Setup(
            RenderTextureDescriptor baseDescriptor,
            RenderTargetHandle colorAttachmentHandle,
            RenderTargetHandle depthAttachmentHandle,
            RendererConfiguration configuration,
            SampleCount samples,
            RenderingData renderingData)
        {
            if (!GetViewDepthMinMaxWithRenderQueue(renderingData.cameraData.camera, RenderQueueUtils.oit, out _ViewDepthMinMax))
            {
                return(false);
            }
            this._ColorAttachmentHandle = colorAttachmentHandle;
            this._DepthAttachmentHandle = depthAttachmentHandle;
            _RendererConfiguration      = configuration;

            if ((int)samples > 1)
            {
                baseDescriptor.bindMS      = false;
                baseDescriptor.msaaSamples = (int)samples;
            }

            baseDescriptor.depthBufferBits = 0;

            _Descriptor = baseDescriptor;

            _MomentsPrecision = renderingData.cameraData.momentsPrecision;

            if (_MomentsPrecision == FloatPrecision._Single)
            {
                baseDescriptor.colorFormat = RenderTextureFormat.ARGBFloat;
                _DescriptorFloat4          = baseDescriptor;

                baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGFloat)
                    ? RenderTextureFormat.RGFloat
                    : RenderTextureFormat.ARGBFloat;
                _DescriptorFloat2 = baseDescriptor;

                baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat)
                    ? RenderTextureFormat.RFloat
                    : RenderTextureFormat.ARGBFloat;
                _DescriptorFloat = baseDescriptor;
            }
            else
            {
                baseDescriptor.colorFormat = RenderTextureFormat.ARGBHalf;
                _DescriptorFloat4          = baseDescriptor;

                baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGHalf)
                    ? RenderTextureFormat.RGHalf
                    : RenderTextureFormat.ARGBHalf;
                _DescriptorFloat2 = baseDescriptor;

                baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RHalf)
                    ? RenderTextureFormat.RHalf
                    : RenderTextureFormat.ARGBHalf;
                _DescriptorFloat = baseDescriptor;
            }

            _B0Handle.Init("_B0");
            _B1Handle.Init("_B1");
            _B2Handle.Init("_B2");

            _MomentsCount = (MomentsCount)renderingData.cameraData.momentsCount;

            if (MomentsCount._4 != _MomentsCount)
            {
                _GMBinding = new RenderTargetBinding(
                    new RenderTargetIdentifier[]
                {
                    _B0Handle.Identifier(),
                    _B1Handle.Identifier(),
                    _B2Handle.Identifier(),
                },
                    new RenderBufferLoadAction[]
                {
                    RenderBufferLoadAction.DontCare,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferLoadAction.DontCare,
                },
                    new RenderBufferStoreAction[]
                {
                    RenderBufferStoreAction.Store,
                    RenderBufferStoreAction.Store,
                    RenderBufferStoreAction.Store,
                },
                    _DepthAttachmentHandle.Identifier(),
                    RenderBufferLoadAction.Load,
                    RenderBufferStoreAction.DontCare);
            }
            else
            {
                _GMBinding = new RenderTargetBinding(
                    new RenderTargetIdentifier[]
                {
                    _B0Handle.Identifier(),
                    _B1Handle.Identifier(),
                },
                    new RenderBufferLoadAction[]
                {
                    RenderBufferLoadAction.DontCare,
                    RenderBufferLoadAction.DontCare,
                },
                    new RenderBufferStoreAction[]
                {
                    RenderBufferStoreAction.Store,
                    RenderBufferStoreAction.Store,
                },
                    _DepthAttachmentHandle.Identifier(),
                    RenderBufferLoadAction.Load,
                    RenderBufferStoreAction.DontCare);
            }

            _MOITHandle.Init("_MOIT");
            _GIALHandle.Init("_GIAL");
            _RMBinding = new RenderTargetBinding(
                new RenderTargetIdentifier[]
            {
                _MOITHandle.Identifier(),
                _GIALHandle.Identifier(),
            },
                new RenderBufferLoadAction[]
            {
                RenderBufferLoadAction.DontCare,
                RenderBufferLoadAction.DontCare,
            },
                new RenderBufferStoreAction[]
            {
                RenderBufferStoreAction.Store,
                RenderBufferStoreAction.Store,
            },
                _DepthAttachmentHandle.Identifier(),
                RenderBufferLoadAction.Load,
                RenderBufferStoreAction.DontCare
                );
            return(true);
        }
Exemplo n.º 20
0
 //  Sort largest count first
 int scomp(SampleCount a, SampleCount b)
 {
     return(b.Count - a.Count);
 }
        public override IEnumerable <string> Process()
        {
            var sampleInfos = new List <SampleCount>();

            using (var sw = new StreamWriter(options.OutputFile))
                using (var swUnfiltered = new StreamWriter(Path.ChangeExtension(options.OutputFile, ".unfiltered.tsv")))
                {
                    var header = "File\tCategory\tName\tUniqueRead\tUniqueT2CRead\tUniqueT2CRate\tAvergeT2CIn10BasesOfUniqueRead\tAvergeT2COfUniqueRead\tTotalRead\tTotalT2CRead\tTotalT2CRate\tT2C_pvalue\tAverageT2CIn10BasesOfTotalRead\tAverageT2COfTotalRead";
                    swUnfiltered.WriteLine(header);
                    sw.WriteLine(header);

                    var inputFiles = options.GetCountXmlFiles();

                    foreach (var file in inputFiles)
                    {
                        var sc = new SampleCount();
                        sc.Name = file.Name;
                        sampleInfos.Add(sc);

                        var subjects = new FeatureItemGroupXmlFormat().ReadFromFile(file.File);
                        var group    = subjects.GroupBy(m => m[0].Name.StringBefore(":")).ToList();
                        foreach (var g in group)
                        {
                            var items = g.ToList();
                            foreach (var item in items)
                            {
                                var queries = new HashSet <string>(item.GetAlignedLocations().ConvertAll(l => l.Parent.Qname));
                                List <FeatureSamLocation> locs = new List <FeatureSamLocation>();
                                foreach (var l in item)
                                {
                                    foreach (var loc in l.Locations)
                                    {
                                        foreach (var sl in loc.SamLocations)
                                        {
                                            if (queries.Contains(sl.SamLocation.Parent.Qname))
                                            {
                                                locs.Add(sl);
                                                queries.Remove(sl.SamLocation.Parent.Qname);
                                            }
                                        }
                                    }
                                }

                                var t2c = locs.Where(m => m.NumberOfNoPenaltyMutation > 0).ToList();
                                var ave_t2c_uniquereads         = (t2c.Count > 0) ? t2c.ConvertAll(m => m.NumberOfNoPenaltyMutation * 10.0 / m.SamLocation.Parent.Sequence.Length).Average() : 0.0;
                                var ave_t2c_perread_uniquereads = (t2c.Count > 0) ? t2c.ConvertAll(m => m.NumberOfNoPenaltyMutation).Average() : 0.0;

                                double ave_t2c_allreads         = 0.0;
                                double ave_t2c_perread_allreads = 0.0;
                                if (t2c.Count > 0)
                                {
                                    List <double> values         = new List <double>();
                                    List <double> perread_values = new List <double>();
                                    foreach (var t2citem in t2c)
                                    {
                                        var v = t2citem.NumberOfNoPenaltyMutation * 10.0 / t2citem.SamLocation.Parent.Sequence.Length;
                                        for (int i = 0; i < t2citem.SamLocation.Parent.QueryCount; i++)
                                        {
                                            values.Add(v);
                                            perread_values.Add(t2citem.NumberOfNoPenaltyMutation);
                                        }
                                    }
                                    ave_t2c_allreads         = values.Average();
                                    ave_t2c_perread_allreads = perread_values.Average();
                                }

                                var totalCount    = locs.Sum(l => l.SamLocation.Parent.QueryCount);
                                var totalT2CCount = t2c.Sum(l => l.SamLocation.Parent.QueryCount);
                                var pvalue        = SmallRNAT2CMutationBuilder.CalculateT2CPvalue(totalCount, totalT2CCount, options.ExpectRate);
                                var t2crate       = totalT2CCount == 0 ? 0 : totalT2CCount * 1.0 / totalCount;
                                var value         = string.Format("{0}\t{1}\t{2}\t{3:0.###}\t{4:0.###}\t{5:0.###}\t{6:0.###}\t{7:0.###}\t{8:0.###}\t{9:0.###}\t{10:0.###}\t{11:0.###E+0}\t{12:0.###}\t{13:0.###}",
                                                                  file.Name,
                                                                  g.Key,
                                                                  item.Name,
                                                                  locs.Count,
                                                                  t2c.Count,
                                                                  t2c.Count * 1.0 / locs.Count,
                                                                  ave_t2c_uniquereads,
                                                                  ave_t2c_perread_uniquereads,
                                                                  totalCount,
                                                                  totalT2CCount,
                                                                  t2crate,
                                                                  pvalue,
                                                                  ave_t2c_allreads,
                                                                  ave_t2c_perread_allreads);

                                swUnfiltered.WriteLine(value);
                                if (!ParclipSmallRNAT2CBuilder.Accept(pvalue, totalCount, totalT2CCount, options.Pvalue, options.MinimumCount, options.ExpectRate))
                                {
                                    continue;
                                }

                                sw.WriteLine(value);

                                sc.GoodReadCount    += totalCount;
                                sc.GoodT2CReadCount += totalT2CCount;
                                if (g.Key.Equals(SmallRNAConsts.miRNA))
                                {
                                    sc.MiRNACount++;
                                }
                                else if (g.Key.Equals(SmallRNAConsts.tRNA))
                                {
                                    sc.TRNACount++;
                                }
                                else
                                {
                                    sc.OtherSmallRNACount++;
                                }
                            }
                        }
                    }
                }
            using (var sw = new StreamWriter(options.OutputFile + ".summary"))
            {
                sw.WriteLine("File\tTotalRead\tT2CRead\tT2CRate\tSmallRNA\tMicroRNA\ttRNA\tOtherSmallRNA");
                foreach (var si in sampleInfos)
                {
                    sw.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}",
                                 si.Name,
                                 si.GoodReadCount,
                                 si.GoodT2CReadCount,
                                 si.GoodT2CRate,
                                 si.SmallRNACount,
                                 si.MiRNACount,
                                 si.TRNACount,
                                 si.OtherSmallRNACount);
                }
            }

            return(new[] { Path.GetFullPath(options.OutputFile), Path.GetFullPath(options.OutputFile + ".summary") });
        }