public void CompactId_IO_EndToEnd() { const string expectedResults = "ENSP00000334393.3"; var id = CompactId.Convert("ENSP00000334393", 3); ICompactId observedId; using (var ms = new MemoryStream()) { using (var writer = new ExtendedBinaryWriter(ms, Encoding.UTF8, true)) { id.Write(writer); } ms.Position = 0; using (var reader = new BufferedBinaryReader(ms)) { observedId = CompactId.Read(reader); } } Assert.NotNull(observedId); Assert.Equal(expectedResults, observedId.WithVersion); }
public static ITranslation Read(ExtendedBinaryReader reader, string[] peptideSeqs) { var codingRegion = DataStructures.CodingRegion.Read(reader); var proteinId = CompactId.Read(reader); var peptideIndex = reader.ReadOptInt32(); var peptideSeq = peptideIndex == -1 ? null : peptideSeqs[peptideIndex]; return(new Translation(codingRegion, proteinId, peptideSeq)); }
public static IRegulatoryRegion Read(IBufferedBinaryReader reader, IDictionary <ushort, IChromosome> chromosomeIndexDictionary) { var refIndex = reader.ReadOptUInt16(); int start = reader.ReadOptInt32(); int end = reader.ReadOptInt32(); var type = (RegulatoryRegionType)reader.ReadByte(); var id = CompactId.Read(reader); return(new RegulatoryRegion(chromosomeIndexDictionary[refIndex], start, end, id, type)); }
public static IGene Read(IBufferedBinaryReader reader, IDictionary <ushort, IChromosome> indexToChromosome) { ushort referenceIndex = reader.ReadOptUInt16(); int start = reader.ReadOptInt32(); int end = reader.ReadOptInt32(); bool onReverseStrand = reader.ReadBoolean(); string symbol = reader.ReadAsciiString(); int hgncId = reader.ReadOptInt32(); var entrezId = CompactId.Read(reader); var ensemblId = CompactId.Read(reader); return(new Gene(indexToChromosome[referenceIndex], start, end, onReverseStrand, symbol, hgncId, entrezId, ensemblId)); }
public static ITranscript Read(BufferedBinaryReader reader, IDictionary <ushort, IChromosome> chromosomeIndexDictionary, IGene[] cacheGenes, ITranscriptRegion[] cacheTranscriptRegions, IInterval[] cacheMirnas, string[] cachePeptideSeqs) { // transcript var referenceIndex = reader.ReadOptUInt16(); var start = reader.ReadOptInt32(); var end = reader.ReadOptInt32(); var id = CompactId.Read(reader); // gene var geneIndex = reader.ReadOptInt32(); var gene = cacheGenes[geneIndex]; // encoded data var encoded = EncodedTranscriptData.Read(reader); // transcript regions var transcriptRegions = encoded.HasTranscriptRegions ? ReadIndices(reader, cacheTranscriptRegions) : null; ushort numExons = reader.ReadOptUInt16(); // protein function predictions int siftIndex = encoded.HasSift ? reader.ReadOptInt32() : -1; int polyphenIndex = encoded.HasPolyPhen ? reader.ReadOptInt32() : -1; // translation var translation = encoded.HasTranslation ? DataStructures.Translation.Read(reader, cachePeptideSeqs) : null; // attributes var mirnas = encoded.HasMirnas ? ReadIndices(reader, cacheMirnas) : null; var rnaEdits = encoded.HasRnaEdits ? ReadItems(reader, RnaEdit.Read) : null; var selenocysteines = encoded.HasSelenocysteines ? ReadItems(reader, x => x.ReadOptInt32()) : null; return(new Transcript(chromosomeIndexDictionary[referenceIndex], start, end, id, translation, encoded.BioType, gene, ExonUtilities.GetTotalExonLength(transcriptRegions), encoded.StartExonPhase, encoded.IsCanonical, transcriptRegions, numExons, mirnas, siftIndex, polyphenIndex, encoded.TranscriptSource, encoded.CdsStartNotFound, encoded.CdsEndNotFound, selenocysteines, rnaEdits)); }