Ejemplo n.º 1
0
        /// <summary>
        /// writes the transcript to the binary writer
        /// </summary>
        public void Write(IExtendedBinaryWriter writer, Dictionary <IGene, int> geneIndices,
                          Dictionary <ITranscriptRegion, int> transcriptRegionIndices, Dictionary <IInterval, int> microRnaIndices,
                          Dictionary <string, int> peptideIndices)
        {
            // transcript
            writer.WriteOpt(Chromosome.Index);
            writer.WriteOpt(Start);
            writer.WriteOpt(End);
            // ReSharper disable once ImpureMethodCallOnReadonlyValueField
            Id.Write(writer);

            // gene
            writer.WriteOpt(GetIndex(Gene, geneIndices));

            // encoded data
            var encoded = EncodedTranscriptData.GetEncodedTranscriptData(BioType, CdsStartNotFound, CdsEndNotFound,
                                                                         Source, IsCanonical, SiftIndex != -1, PolyPhenIndex != -1, MicroRnas != null, RnaEdits != null,
                                                                         Selenocysteines != null, TranscriptRegions != null, Translation != null, StartExonPhase);

            encoded.Write(writer);

            // transcript regions
            if (encoded.HasTranscriptRegions)
            {
                WriteIndices(writer, TranscriptRegions, transcriptRegionIndices);
            }
            writer.WriteOpt(NumExons);

            // protein function predictions
            if (encoded.HasSift)
            {
                writer.WriteOpt(SiftIndex);
            }
            if (encoded.HasPolyPhen)
            {
                writer.WriteOpt(PolyPhenIndex);
            }

            // translation
            if (encoded.HasTranslation)
            {
                // ReSharper disable once PossibleNullReferenceException
                var peptideIndex = GetIndex(Translation.PeptideSeq, peptideIndices);
                Translation.Write(writer, peptideIndex);
            }

            // attributes
            if (encoded.HasMirnas)
            {
                WriteIndices(writer, MicroRnas, microRnaIndices);
            }
            if (encoded.HasRnaEdits)
            {
                WriteItems(writer, RnaEdits, (x, y) => x.Write(y));
            }
            if (encoded.HasSelenocysteines)
            {
                WriteItems(writer, Selenocysteines, (x, y) => y.WriteOpt(x));
            }
        }
Ejemplo n.º 2
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.WriteOptAscii(Name);
     writer.WriteOptAscii(Version);
     writer.WriteOpt(ReleaseDateTicks);
     writer.WriteOptAscii(Description);
 }
Ejemplo n.º 3
0
        public void Write(IExtendedBinaryWriter writer)
        {
            if (_currentNode != null)
            {
                _nodes.Add(_currentNode);
            }

            writer.WriteOptAscii(ReferenceSequence);
            writer.WriteOpt(_nodes.Count);
            foreach (var node in _nodes)
            {
                node.Write(writer);
            }

            writer.WriteOpt(_largeVariants.Count);
            if (_largeVariants.Count == 0)
            {
                return;
            }

            foreach (var interval in _largeVariants.OrderBy(x => x.Begin).ThenBy(x => x.End))
            {
                WriteInterval(interval, writer);
            }
        }
Ejemplo n.º 4
0
        public void Write(IExtendedBinaryWriter writer)
        {
            writer.Write(KeyName);
            writer.Write(VcfkeyName);
            writer.Write(AltAllele);

            byte flags = 0;

            if (MatchByAllele)
            {
                flags |= 1;
            }
            if (IsArray)
            {
                flags |= 2;
            }
            writer.Write(flags);

            writer.Write(VcfString);

            writer.WriteOpt(JsonStrings.Length);
            foreach (var jsonString in JsonStrings)
            {
                writer.Write(jsonString);
            }
        }
Ejemplo n.º 5
0
        public void Write(IExtendedBinaryWriter writer)
        {
            writer.WriteOptAscii(Id);
            writer.WriteOptAscii(AnnotationType);
            writer.WriteOptAscii(SaAltAllele);
            writer.Write(IsPositional);

            if (StringFields != null)
            {
                writer.WriteOpt(StringFields.Count);
                foreach (var stringField in StringFields)
                {
                    writer.WriteOptAscii(stringField.Key);
                    writer.WriteOptAscii(stringField.Value);
                }
            }
            else
            {
                writer.WriteOpt(0);
            }

            if (BooleanFields != null)
            {
                writer.WriteOpt(BooleanFields.Count);
                foreach (var booleanField in BooleanFields)
                {
                    writer.WriteOptAscii(booleanField);
                }
            }
            else
            {
                writer.WriteOpt(0);
            }
        }
Ejemplo n.º 6
0
 private static void WriteIndices <T>(IExtendedBinaryWriter writer, T[] items, IReadOnlyDictionary <T, int> indices)
 {
     writer.WriteOpt(items.Length);
     foreach (var item in items)
     {
         writer.WriteOpt(GetIndex(item, indices));
     }
 }
Ejemplo n.º 7
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(Start);
     writer.WriteOpt(End);
     writer.WriteOpt(CdnaStart);
     writer.WriteOpt(CdnaEnd);
     writer.WriteOpt(Length);
 }
Ejemplo n.º 8
0
 private static void WriteItems <T>(IExtendedBinaryWriter writer, T[] items, Action <T, IExtendedBinaryWriter> writeAction)
 {
     writer.WriteOpt(items.Length);
     foreach (var item in items)
     {
         writeAction(item, writer);
     }
 }
Ejemplo n.º 9
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.Write((byte)Type);
     writer.WriteOpt(Id);
     writer.WriteOpt(Start);
     writer.WriteOpt(End);
     writer.WriteOpt(CdnaStart);
     writer.WriteOpt(CdnaEnd);
 }
Ejemplo n.º 10
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.WriteOptAscii(GlobalMajorAllele);
     writer.WriteOpt(DataSources.Length);
     foreach (var dataSource in DataSources)
     {
         dataSource.Write(writer);
     }
 }
Ejemplo n.º 11
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.Write(GeneName);
     writer.WriteOpt(Annotations.Length);
     for (int i = 0; i < Annotations.Length; i++)
     {
         Annotations[i].Write(writer);
     }
 }
Ejemplo n.º 12
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(Chromosome.Index);
     writer.WriteOpt(Start);
     writer.WriteOpt(End);
     writer.Write((byte)Type);
     // ReSharper disable once ImpureMethodCallOnReadonlyValueField
     Id.Write(writer);
 }
Ejemplo n.º 13
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.Write(DataSource);
     writer.Write(IsArray);
     writer.WriteOpt(JsonStrings.Length);
     foreach (var jsonString in JsonStrings)
     {
         writer.Write(jsonString);
     }
 }
Ejemplo n.º 14
0
        private void WriteMaskedEntries(IExtendedBinaryWriter writer)
        {
            writer.WriteOpt(_maskedEntries.Length);

            foreach (var maskedEntry in _maskedEntries)
            {
                writer.WriteOpt(maskedEntry.Begin);
                writer.WriteOpt(maskedEntry.End);
            }
        }
Ejemplo n.º 15
0
        private void WriteCytogeneticBands(IExtendedBinaryWriter writer)
        {
            writer.WriteOpt(_cytogeneticBands.Length);

            foreach (var band in _cytogeneticBands)
            {
                writer.WriteOpt(band.Begin);
                writer.WriteOpt(band.End);
                writer.WriteOptAscii(band.Name);
            }
        }
Ejemplo n.º 16
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(Chromosome.Index);
     writer.WriteOpt(Start);
     writer.WriteOpt(End);
     writer.Write(OnReverseStrand);
     writer.WriteOptAscii(Symbol);
     writer.WriteOpt(HgncId);
     // ReSharper disable ImpureMethodCallOnReadonlyValueField
     EntrezGeneId.Write(writer);
     EnsemblId.Write(writer);
 }
Ejemplo n.º 17
0
        internal static void WriteItems <T>(IExtendedBinaryWriter writer, IReadOnlyCollection <T> items, Action <T> writeMethod)
        {
            if (items == null)
            {
                writer.WriteOpt(0);
            }
            else
            {
                writer.WriteOpt(items.Count);
                foreach (var item in items)
                {
                    writeMethod(item);
                }
            }

            writer.Write(CacheConstants.GuardInt);
        }
Ejemplo n.º 18
0
        private void WriteBlockOffsets(IExtendedBinaryWriter writer)
        {
            writer.WriteOpt(_blockPositions.Count);

            int  oldPosition    = 0;
            long oldBlockOffset = 0;

            foreach (var offset in _blockPositions.OrderBy(x => x.Position))
            {
                int  deltaPosition    = offset.Position - oldPosition;
                long deltaBlockOffset = offset.Offset - oldBlockOffset;

                writer.WriteOpt(deltaPosition);
                writer.WriteOpt(deltaBlockOffset);

                oldPosition    = offset.Position;
                oldBlockOffset = offset.Offset;
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// writes the cytogenetic bands to the file
        /// </summary>
        public void Write(IExtendedBinaryWriter writer)
        {
            var numReferences = _cytogeneticBands.Length;

            writer.WriteOpt(numReferences);

            for (var refIndex = 0; refIndex < numReferences; refIndex++)
            {
                var numRefEntries = _cytogeneticBands[refIndex].Length;
                writer.WriteOpt(numRefEntries);

                foreach (var band in _cytogeneticBands[refIndex])
                {
                    writer.WriteOpt(band.Begin);
                    writer.WriteOpt(band.End);
                    writer.WriteOptAscii(band.Name);
                }
            }
        }
Ejemplo n.º 20
0
        private static void WriteIntervals <T>(IExtendedBinaryWriter writer, IReadOnlyCollection <IntervalArray <T> > intervalArrays,
                                               Action <T> writeMethod)
        {
            writer.WriteOpt(intervalArrays.Count);

            foreach (var intervalArray in intervalArrays)
            {
                if (intervalArray == null)
                {
                    writer.WriteOpt(0);
                    continue;
                }

                writer.WriteOpt(intervalArray.Array.Length);
                foreach (var interval in intervalArray.Array)
                {
                    writeMethod(interval.Value);
                }
            }

            writer.Write(CacheConstants.GuardInt);
        }
Ejemplo n.º 21
0
 private void WriteBuffer(IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(_buffer.Length);
     writer.Write(_buffer);
 }
Ejemplo n.º 22
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.Write((byte)_id);
     writer.Write(_version);
     writer.Write(_info);
 }
Ejemplo n.º 23
0
 private void WriteMetadata(IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(_sequenceOffset);
     writer.WriteOpt(_numBases);
 }
Ejemplo n.º 24
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(Start);
     writer.WriteOpt(End);
     writer.WriteOptAscii(Bases);
 }
Ejemplo n.º 25
0
 internal void Write(IExtendedBinaryWriter writer)
 {
     writer.Write(_info);
     writer.Write(_contents);
 }
Ejemplo n.º 26
0
 public void Write(IExtendedBinaryWriter writer) => throw new System.NotImplementedException();
Ejemplo n.º 27
0
 public void Write(IExtendedBinaryWriter writer, int peptideIndex)
 {
     CodingRegion.Write(writer);
     ProteinId.Write(writer);
     writer.WriteOpt(peptideIndex);
 }
Ejemplo n.º 28
0
 private static void WriteInterval(Interval <long> interval, IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(interval.Begin);
     writer.WriteOpt(interval.End);
     writer.WriteOpt(interval.Value);
 }
Ejemplo n.º 29
0
 public void Write(IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(_start);
     writer.WriteOpt(_end - _start);
     writer.WriteOpt(FileLocation);
 }
Ejemplo n.º 30
0
 public static void Write(this IInterval interval, IExtendedBinaryWriter writer)
 {
     writer.WriteOpt(interval.Start);
     writer.WriteOpt(interval.End);
 }