Example #1
0
 /// <summary>
 /// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with the data needed to serialize the target object.
 /// </summary>
 /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> to populate with data. </param><param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"/>) for this serialization. </param><exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
 public void GetObjectData(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     info.AddValue(Constants.ConfidenceDataKey, ToByteArray(ConfidenceData));
     info.AddValue(Constants.PeakLocationDataKey, ToByteArray(PeakLocations));
     info.AddValue(Constants.AdenineColorDataKey, Ab1ColorData.ToByteArray(AdenineColorData));
     info.AddValue(Constants.CytosineColorDataKey, Ab1ColorData.ToByteArray(CytosineColorData));
     info.AddValue(Constants.ThymineColorDataKey, Ab1ColorData.ToByteArray(ThymineColorData));
     info.AddValue(Constants.GuanineColorDataKey, Ab1ColorData.ToByteArray(GuanineColorData));
 }
Example #2
0
        /// <summary>
        /// Converts the color data to a byte array.  Does not include redundant information only the color data.
        /// </summary>
        /// <param name="data">Color Data</param>
        /// <returns>Readings</returns>
        public static byte[] ToByteArray(Ab1ColorData data)
        {
            if (data == null) throw new ArgumentNullException("data");
            int dataPointCount = data.DataByResidue.Sum(residue => residue.Data.Length);

            var values = new byte[dataPointCount * 2];
            int index = 0;
            foreach (Ab1ResidueColorData residue in data.DataByResidue)
            {
                short[] residueData = residue.Data;
                for (int i = 0; i < residueData.Length; i++)
                {
                    short value = residueData[i];
                    values[index++] = (byte)value;
                    values[index++] = (byte)(value >> 8);
                }
            }

            return values;
        }
Example #3
0
        /// <summary>
        /// Serialization constructor.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        private Ab1Metadata(SerializationInfo info, StreamingContext context)
        {
            if (info == null) throw new ArgumentNullException("info");
            ConfidenceData = Ab1ColorData.FromByteArray((byte[])info.GetValue(Constants.ConfidenceDataKey, typeof(byte[])));
            PeakLocations =
                Ab1ColorData.FromByteArray((byte[])info.GetValue(Constants.PeakLocationDataKey, typeof(byte[])));

            AdenineColorData = new Ab1ColorData(PeakLocations,
                                                Ab1ColorData.FromByteArray(
                                                    (byte[])info.GetValue(Constants.AdenineColorDataKey, typeof(byte[]))));
            CytosineColorData = new Ab1ColorData(PeakLocations,
                                                 Ab1ColorData.FromByteArray(
                                                     (byte[])info.GetValue(Constants.CytosineColorDataKey, typeof(byte[]))));
            ThymineColorData = new Ab1ColorData(PeakLocations,
                                                Ab1ColorData.FromByteArray(
                                                    (byte[])info.GetValue(Constants.ThymineColorDataKey, typeof(byte[]))));
            GuanineColorData = new Ab1ColorData(PeakLocations,
                                                Ab1ColorData.FromByteArray(
                                                    (byte[])info.GetValue(Constants.GuanineColorDataKey, typeof(byte[]))));
        }
Example #4
0
        /// <summary>
        /// Serialization constructor.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        private Ab1Metadata(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            ConfidenceData = Ab1ColorData.FromByteArray((byte[])info.GetValue(Constants.ConfidenceDataKey, typeof(byte[])));
            PeakLocations  =
                Ab1ColorData.FromByteArray((byte[])info.GetValue(Constants.PeakLocationDataKey, typeof(byte[])));

            AdenineColorData = new Ab1ColorData(PeakLocations,
                                                Ab1ColorData.FromByteArray(
                                                    (byte[])info.GetValue(Constants.AdenineColorDataKey, typeof(byte[]))));
            CytosineColorData = new Ab1ColorData(PeakLocations,
                                                 Ab1ColorData.FromByteArray(
                                                     (byte[])info.GetValue(Constants.CytosineColorDataKey, typeof(byte[]))));
            ThymineColorData = new Ab1ColorData(PeakLocations,
                                                Ab1ColorData.FromByteArray(
                                                    (byte[])info.GetValue(Constants.ThymineColorDataKey, typeof(byte[]))));
            GuanineColorData = new Ab1ColorData(PeakLocations,
                                                Ab1ColorData.FromByteArray(
                                                    (byte[])info.GetValue(Constants.GuanineColorDataKey, typeof(byte[]))));
        }
Example #5
0
 /// <summary>
 /// Sets color data based on the specific sequence.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="data"></param>
 public void SetColorData(byte item, Ab1ColorData data)
 {
     if (item == DnaAlphabet.Instance.A)
     {
         AdenineColorData = data;
     }
     else if (item == DnaAlphabet.Instance.T)
     {
         ThymineColorData = data;
     }
     else if (item == DnaAlphabet.Instance.G)
     {
         GuanineColorData = data;
     }
     else if (item == DnaAlphabet.Instance.C)
     {
         CytosineColorData = data;
     }
     else
     {
         throw new ArgumentException(item.ToString(CultureInfo.InvariantCulture), "item");
     }
 }
Example #6
0
        /// <summary>
        /// Converts the color data to a byte array.  Does not include redundant information only the color data.
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static byte[] ToByteArray(Ab1ColorData data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            int dataPointCount = data.DataByResidue.Sum(residue => residue.Data.Length);

            var values = new byte[dataPointCount * 2];
            int index  = 0;

            foreach (Ab1ResidueColorData residue in data.DataByResidue)
            {
                short[] residueData = residue.Data;
                for (int i = 0; i < residueData.Length; i++)
                {
                    short value = residueData[i];
                    values[index++] = (byte)value;
                    values[index++] = (byte)(value >> 8);
                }
            }

            return(values);
        }
Example #7
0
 /// <summary>
 /// Sets color data based on the specific sequence.
 /// </summary>
 /// <param name="item"></param>
 /// <param name="data"></param>
 public void SetColorData(byte item, Ab1ColorData data)
 {
     if (item == DnaAlphabet.Instance.A)
     {
         AdenineColorData = data;
     }
     else if (item == DnaAlphabet.Instance.T)
     {
         ThymineColorData = data;
     }
     else if (item == DnaAlphabet.Instance.G)
     {
         GuanineColorData = data;
     }
     else if (item == DnaAlphabet.Instance.C)
     {
         CytosineColorData = data;
     }
     else
     {
         throw new ArgumentException(item.ToString(CultureInfo.InvariantCulture), "item");
     }
 }