Exemplo n.º 1
0
        public static (int Start, int End, string Id, bool OnReverseStrand) Parse(IImportNode importNode)
        {
            var objectValue = importNode.GetObjectValueNode();

            if (objectValue == null)
            {
                throw new InvalidDataException("Encountered a gene import node that could not be converted to an object value node.");
            }

            int    start           = -1;
            int    end             = -1;
            string stableId        = null;
            var    onReverseStrand = false;

            foreach (var node in objectValue.Values)
            {
                // sanity check: make sure we know about the keys are used for
                if (!KnownKeys.Contains(node.Key))
                {
                    throw new InvalidDataException($"Encountered an unknown key in the dumper gene object: {node.Key}");
                }

                // handle each key
                switch (node.Key)
                {
                case ImportKeys.End:
                    end = node.GetInt32();
                    break;

                case ImportKeys.StableId:
                    stableId = node.GetString();
                    break;

                case ImportKeys.Start:
                    start = node.GetInt32();
                    break;

                case ImportKeys.Strand:
                    onReverseStrand = TranscriptUtilities.GetStrand(node);
                    break;

                default:
                    throw new InvalidDataException($"Unknown key found: {node.Key}");
                }
            }

            return(start, end, stableId, onReverseStrand);
        }
                       TranslateableSequence, string SiftData, string PolyPhenData, int[] SelenocysteinePositions) Parse(IImportNode importNode)
        {
            var objectValue = importNode.GetObjectValueNode();

            if (objectValue == null)
            {
                throw new InvalidDataException("Encountered a variant effect feature cache node that could not be converted to an object value node.");
            }

            MutableTranscriptRegion[] cdnaMaps = null;
            IInterval[] introns               = null;
            string      peptideSequence       = null;
            string      translateableSequence = null;
            string      siftData              = null;
            string      polyphenData          = null;

            int[] selenocysteinePositions = null;

            foreach (var node in objectValue.Values)
            {
                // sanity check: make sure we know about the keys are used for
                if (!KnownKeys.Contains(node.Key))
                {
                    throw new InvalidDataException($"Encountered an unknown key in the dumper variant effect feature cache object: {node.Key}");
                }

                switch (node.Key)
                {
                case ImportKeys.CodonTable:
                case ImportKeys.FivePrimeUtr:
                case ImportKeys.ProteinFeatures:
                case ImportKeys.Selenocysteines:
                case ImportKeys.SortedExons:
                case ImportKeys.SplicedSequence:
                case ImportKeys.ThreePrimeUtr:
                    // not used
                    break;

                case ImportKeys.Introns:
                    introns = node.ParseListObjectKeyValueNode(ImportIntron.ParseList);
                    break;

                case ImportKeys.Mapper:
                    cdnaMaps = node.ParseObjectKeyValueNode(ImportTranscriptMapper.Parse);
                    break;

                case ImportKeys.Peptide:
                    peptideSequence = node.GetString();
                    break;

                case ImportKeys.ProteinFunctionPredictions:
                    if (node is ObjectKeyValueNode predictionsNode)
                    {
                        (siftData, polyphenData) = ImportProteinFunctionPredictions.Parse(predictionsNode.Value);
                    }
                    else
                    {
                        throw new InvalidDataException($"Could not transform the AbstractData object into an ObjectKeyValue: [{node.GetType()}]");
                    }
                    break;

                case ImportKeys.SeqEdits:
                    selenocysteinePositions = node.ParseListObjectKeyValueNode(ImportSeqEdits.Parse);
                    break;

                case ImportKeys.TranslateableSeq:
                    translateableSequence = node.GetString();
                    break;

                default:
                    throw new InvalidDataException($"Unknown key found: {node.Key}");
                }
            }

            return(cdnaMaps, introns, peptideSequence, translateableSequence, siftData, polyphenData, selenocysteinePositions);
        }
Exemplo n.º 3
0
                       endExon) Parse(IImportNode importNode, IChromosome currentChromosome)
        {
            var objectValue = importNode.GetObjectValueNode();

            if (objectValue == null)
            {
                throw new InvalidDataException("Encountered a translation import node that could not be converted to an object value node.");
            }

            int         start          = -1;
            int         end            = -1;
            string      proteinId      = null;
            byte        proteinVersion = 0;
            MutableExon startExon      = null;
            MutableExon endExon        = null;

            foreach (var node in objectValue.Values)
            {
                // sanity check: make sure we know about the keys are used for
                if (!KnownKeys.Contains(node.Key))
                {
                    throw new InvalidDataException($"Encountered an unknown key in the dumper mapper object: {node.Key}");
                }

                ObjectKeyValueNode exonNode;

                switch (node.Key)
                {
                case ImportKeys.Adaptor:
                case ImportKeys.Sequence:
                case ImportKeys.DbId:
                case ImportKeys.Transcript:
                    // skip this key
                    break;

                case ImportKeys.StartExon:
                    exonNode = node as ObjectKeyValueNode;
                    if (exonNode != null)
                    {
                        startExon = ImportExon.Parse(exonNode.Value, currentChromosome);
                    }
                    break;

                case ImportKeys.EndExon:
                    exonNode = node as ObjectKeyValueNode;
                    if (exonNode != null)
                    {
                        endExon = ImportExon.Parse(exonNode.Value, currentChromosome);
                    }
                    break;

                case ImportKeys.StableId:
                    proteinId = node.GetString();
                    break;

                case ImportKeys.End:
                    end = node.GetInt32();
                    break;

                case ImportKeys.Start:
                    start = node.GetInt32();
                    break;

                case ImportKeys.Version:
                    proteinVersion = (byte)node.GetInt32();
                    break;

                default:
                    throw new InvalidDataException($"Unknown key found: {node.Key}");
                }
            }

            return(start, end, proteinId, proteinVersion, startExon, endExon);
        }