public void MergeAlleleSpecificAnnotation(AlleleSpecificAnnotation otherAsa)
 {
     foreach (var dataSource in DataSourceCommon.GetAllDataSources())
     {
         var index = DataSourceCommon.GetIndex(dataSource);
         if (HasDataSource(dataSource) && otherAsa.HasDataSource(dataSource))
         {
             Annotations[index].MergeAnnotations(otherAsa.Annotations[index]);
             break;
         }
         if (!HasDataSource(dataSource) && otherAsa.HasDataSource(dataSource))
         {
             DataSourceCommon.AddDataSource(dataSource, ref SaDataSourceFlag);
             Annotations[index] = otherAsa.Annotations[index];
         }
     }
 }
        public static void Read(ExtendedBinaryReader reader, SupplementaryAnnotationPosition sa)
        {
            sa.GlobalMinorAllele          = reader.ReadAsciiString();
            sa.GlobalMinorAlleleFrequency = reader.ReadAsciiString();
            sa.GlobalMajorAllele          = reader.ReadAsciiString();
            sa.GlobalMajorAlleleFrequency = reader.ReadAsciiString();

            // read the allele-specific records
            var numAlleles = reader.ReadOptInt32();

            for (var alleleIndex = 0; alleleIndex < numAlleles; alleleIndex++)
            {
                var allele = reader.ReadAsciiString();
                var asa    = AlleleSpecificAnnotation.Read(reader);
                sa.AlleleSpecificAnnotations[allele] = asa;
            }

            // read cosmic records
            var numCosmic = reader.ReadOptInt32();

            for (var i = 0; i < numCosmic; i++)
            {
                var cosmicItem = new CosmicItem(reader);
                sa.CosmicItems.Add(cosmicItem);
            }

            // read clinVar items
            var numClinVar = reader.ReadOptInt32();

            for (var i = 0; i < numClinVar; i++)
            {
                var clinVarItem = new ClinVarItem(reader);
                sa.ClinVarItems.Add(clinVarItem);
            }

            // read custom annotation items
            var numCustom = reader.ReadOptInt32();

            for (var i = 0; i < numCustom; i++)
            {
                var customItem = new CustomItem(reader);
                sa.CustomItems.Add(customItem);
            }
        }
        public static AlleleSpecificAnnotation Read(ExtendedBinaryReader reader)
        {
            var asa = new AlleleSpecificAnnotation {
                SaDataSourceFlag = reader.ReadByte()
            };

            foreach (var dataSource in DataSourceCommon.GetAllDataSources())
            {
                if (!asa.HasDataSource(dataSource))
                {
                    continue;
                }
                var supplementaryAnnotation = SupplementaryAnnotationFactory.CreateSupplementaryAnnotation(dataSource);
                supplementaryAnnotation.Read(reader);
                asa.Annotations[DataSourceCommon.GetIndex(dataSource)] = supplementaryAnnotation;
            }

            return(asa);
        }