/// <summary> /// parses the relevant data from each intron object /// </summary> private static void ParseReference(ObjectValue objectValue, DataStructures.VEP.Intron intron, ImportDataStore dataStore) { // loop over all of the key/value pairs in the intron object foreach (AbstractData ad in objectValue) { // skip normal entries if (!DumperUtilities.IsReference(ad)) { continue; } // handle each key switch (ad.Key) { case Transcript.SliceKey: var referenceKeyValue = ad as ReferenceKeyValue; if (referenceKeyValue != null) { intron.Slice = Slice.ParseReference(referenceKeyValue.Value, dataStore); } break; default: throw new GeneralException($"Found an unhandled reference in the intron object: {ad.Key}"); } } }
/// <summary> /// parses the relevant data from each protein function prediction object /// </summary> public static void ParseReference(ObjectValue objectValue, DataStructures.VEP.ProteinFunctionPredictions cache, ImportDataStore dataStore) { // loop over all of the key/value pairs in the cache object foreach (AbstractData ad in objectValue) { if (!DumperUtilities.IsReference(ad)) { continue; } // handle each key var referenceKeyValue = ad as ReferenceKeyValue; if (referenceKeyValue == null) { continue; } switch (referenceKeyValue.Key) { case PolyPhenHumVarKey: cache.PolyPhen = PolyPhen.ParseReference(referenceKeyValue.Value, dataStore); break; case SiftKey: cache.Sift = Sift.ParseReference(referenceKeyValue.Value, dataStore); break; default: throw new GeneralException( $"Found an unhandled reference in the protein function prediction object: {ad.Key}"); } } }
/// <summary> /// parses the relevant data from each mapper pairs object /// </summary> public static List <DataStructures.VEP.MapperPair> ParseList(List <AbstractData> abstractDataList, ImportDataStore dataStore) { var mapperPairs = DumperUtilities.GetPopulatedList <DataStructures.VEP.MapperPair>(abstractDataList.Count); // loop over all of the key/value pairs in the mapper pairs object for (int mapperPairIndex = 0; mapperPairIndex < abstractDataList.Count; mapperPairIndex++) { var ad = abstractDataList[mapperPairIndex]; // skip references if (DumperUtilities.IsReference(ad)) { continue; } if (ad.DataType != DataType) { throw new GeneralException( $"Expected a mapper pair data type, but found the following data type: [{ad.DataType}]"); } var mapperPairNode = ad as ObjectValue; if (mapperPairNode == null) { throw new GeneralException( $"Could not transform the AbstractData object into an ObjectValue: [{ad.GetType()}]"); } var newMapperPair = Parse(mapperPairNode, dataStore.CurrentReferenceIndex); // DS.VEP.MapperPair oldMapperPair; // if (dataStore.MapperPairs.TryGetValue(newMapperPair, out oldMapperPair)) //{ // mapperPairs[mapperPairIndex] = oldMapperPair; //} // else //{ mapperPairs[mapperPairIndex] = newMapperPair; // dataStore.MapperPairs[newMapperPair] = newMapperPair; //} } return(mapperPairs); }
/// <summary> /// places a reference to already existing exons into the array of exons /// </summary> public static void ParseListReference(List <AbstractData> abstractDataList, DataStructures.VEP.Exon[] exons, ImportDataStore dataStore) { // loop over all of the exons for (int exonIndex = 0; exonIndex < abstractDataList.Count; exonIndex++) { var exonNode = abstractDataList[exonIndex]; // skip normal exons if (!DumperUtilities.IsReference(exonNode)) { continue; } var referenceStringValue = exonNode as ReferenceStringValue; if (referenceStringValue != null) { exons[exonIndex] = ParseReference(referenceStringValue.Value, dataStore); } } }
/// <summary> /// returns an array of miRNAs given a list of ObjectValues (AbstractData) /// </summary> public static SimpleInterval[] ParseList(List <AbstractData> abstractDataList) { var microRnas = new List <SimpleInterval>(); foreach (var ad in abstractDataList) { // skip references if (DumperUtilities.IsReference(ad)) { continue; } var objectValue = ad as ObjectValue; if (objectValue != null) { var newMicroRna = Parse(objectValue); if (newMicroRna != null) { // MicroRna oldMicroRna; // if (dataStore.MicroRnas.TryGetValue(newMicroRna, out oldMicroRna)) //{ // microRnas.Add(oldMicroRna); //} // else //{ microRnas.Add(newMicroRna); // dataStore.MicroRnas[newMicroRna] = newMicroRna; //} } } else { throw new GeneralException( $"Could not transform the AbstractData object into an ObjectValue: [{ad.GetType()}]"); } } return(microRnas.Count == 0 ? null : microRnas.ToArray()); }
/// <summary> /// points to a translation that has already been created /// </summary> public static void ParseReference(ObjectValue objectValue, DataStructures.VEP.Translation translation, ImportDataStore dataStore) { // loop over all of the key/value pairs in the translation object foreach (AbstractData ad in objectValue) { if (!DumperUtilities.IsReference(ad)) { continue; } // handle each key var referenceKeyValue = ad as ReferenceKeyValue; if (referenceKeyValue == null) { continue; } switch (referenceKeyValue.Key) { case AdaptorKey: // skip this key break; case EndExonKey: translation.EndExon = Exon.ParseReference(referenceKeyValue.Value, dataStore); break; case StartExonKey: translation.StartExon = Exon.ParseReference(referenceKeyValue.Value, dataStore); break; case TranscriptKey: translation.Transcript = Transcript.ParseReference(referenceKeyValue.Value, dataStore); break; default: throw new GeneralException( $"Found an unhandled reference in the translation object: {ad.Key}"); } } }
/// <summary> /// parses the relevant data from each mapper pairs object /// </summary> public static void ParseListReference(List <AbstractData> abstractDataList, List <DataStructures.VEP.MapperPair> mapperPairs, ImportDataStore dataStore) { // loop over all of the key/value pairs in the mapper pairs object for (int mapperPairIndex = 0; mapperPairIndex < abstractDataList.Count; mapperPairIndex++) { var mapperNode = abstractDataList[mapperPairIndex]; // skip normal mapper pairs if (!DumperUtilities.IsReference(mapperNode)) { continue; } var referenceStringValue = mapperNode as ReferenceStringValue; if (referenceStringValue != null) { var mapperPair = ParseReference(referenceStringValue.Value, dataStore); mapperPairs[mapperPairIndex] = mapperPair; } } }
/// <summary> /// returns an array of exons given a list of ObjectValues (AbstractData) /// </summary> public static DataStructures.VEP.Exon[] ParseList(List <AbstractData> abstractDataList, ImportDataStore dataStore) { var exons = new DataStructures.VEP.Exon[abstractDataList.Count]; // loop over all of the exons for (int exonIndex = 0; exonIndex < abstractDataList.Count; exonIndex++) { // skip references if (DumperUtilities.IsReference(abstractDataList[exonIndex])) { continue; } var objectValue = abstractDataList[exonIndex] as ObjectValue; if (objectValue != null) { var newExon = Parse(objectValue, dataStore.CurrentReferenceIndex); // DS.VEP.Exon oldExon; // if (dataStore.Exons.TryGetValue(newExon, out oldExon)) //{ // exons[exonIndex] = oldExon; //} // else //{ exons[exonIndex] = newExon; // dataStore.Exons[newExon] = newExon; //} } else { throw new GeneralException( $"Could not transform the AbstractData object into an ObjectValue: [{abstractDataList[exonIndex].GetType()}]"); } } return(exons); }
/// <summary> /// returns a new exon given an ObjectValue /// </summary> private static DataStructures.VEP.Intron Parse(ObjectValue objectValue, ImportDataStore dataStore) { var intron = new DataStructures.VEP.Intron(); // loop over all of the key/value pairs in the intron object foreach (AbstractData ad in objectValue) { // sanity check: make sure we know about the keys are used for if (!KnownKeys.Contains(ad.Key)) { throw new GeneralException($"Encountered an unknown key in the dumper mapper object: {ad.Key}"); } // handle each key switch (ad.Key) { case Transcript.EndKey: intron.End = DumperUtilities.GetInt32(ad); break; case Transcript.SliceKey: var sliceNode = ad as ObjectKeyValue; if (sliceNode != null) { var newSlice = Slice.Parse(sliceNode.Value, dataStore.CurrentReferenceIndex); // DS.VEP.Slice oldSlice; // if (dataStore.Slices.TryGetValue(newSlice, out oldSlice)) //{ // intron.Slice = oldSlice; //} // else //{ intron.Slice = newSlice; // dataStore.Slices[newSlice] = newSlice; //} } else if (DumperUtilities.IsReference(ad)) { // skip references until the second pass } else { throw new GeneralException( $"Could not transform the AbstractData object into an ObjectKeyValue or ReferenceKeyValue: [{ad.GetType()}]"); } break; case Transcript.StartKey: intron.Start = DumperUtilities.GetInt32(ad); break; case Transcript.StrandKey: TranscriptUtilities.GetStrand(ad); break; default: throw new GeneralException($"Unknown key found: {ad.Key}"); } } return(intron); }
/// <summary> /// parses the relevant data from each transcript /// </summary> public static void ParseReferences(ObjectValue objectValue, int transcriptIndex, ImportDataStore dataStore) { // Console.WriteLine("*** ParseReferences {0} / {1} ***", transcriptIndex + 1, _tempTranscripts.Count); var transcript = dataStore.Transcripts[transcriptIndex]; // loop over all of the key/value pairs in the transcript object foreach (AbstractData ad in objectValue) { // skip undefined keys if (DumperUtilities.IsUndefined(ad)) { continue; } // handle each key ReferenceKeyValue referenceKeyValue; // references found in: // 'transcript' -> '_variation_effect_feature_cache' -> 'introns' -> 'slice' has references // 'transcript' -> 'gene' has references // 'transcript' -> 'slice' has references // 'transcript' -> '_trans_exon_array' -> [] has references // 'transcript' -> 'translation'-> 'end_exon' has references // 'transcript' -> 'translation'-> 'start_exon' has references // 'transcript' -> 'translation'-> 'transcript' has references switch (ad.Key) { case GeneKey: // works well if (DumperUtilities.IsReference(ad)) { referenceKeyValue = ad as ReferenceKeyValue; if (referenceKeyValue != null) { transcript.Gene = Gene.ParseReference(referenceKeyValue.Value, dataStore); } } break; case SliceKey: if (DumperUtilities.IsReference(ad)) { referenceKeyValue = ad as ReferenceKeyValue; if (referenceKeyValue != null) { transcript.Slice = Slice.ParseReference(referenceKeyValue.Value, dataStore); } } break; case TransExonArrayKey: var exonsList = ad as ListObjectKeyValue; if (exonsList != null) { Exon.ParseListReference(exonsList.Values, transcript.TransExons, dataStore); } break; case TranslationKey: var translationNode = ad as ObjectKeyValue; if (translationNode != null) { Translation.ParseReference(translationNode.Value, transcript.Translation, dataStore); } break; case VariationEffectFeatureCacheKey: var cacheNode = ad as ObjectKeyValue; if (cacheNode != null) { VariantEffectFeatureCache.ParseReference(cacheNode.Value, transcript.VariantEffectCache, dataStore); } break; } } }
/// <summary> /// parses the relevant data from each translation object /// </summary> public static DataStructures.VEP.Translation Parse(ObjectValue objectValue, ImportDataStore dataStore) { var translation = new DataStructures.VEP.Translation(); // loop over all of the key/value pairs in the translation object foreach (AbstractData ad in objectValue) { // sanity check: make sure we know about the keys are used for if (!KnownKeys.Contains(ad.Key)) { throw new GeneralException($"Encountered an unknown key in the dumper mapper object: {ad.Key}"); } // handle each key ObjectKeyValue exonNode; switch (ad.Key) { case AdaptorKey: case SequenceKey: case Transcript.DbIdKey: case Transcript.StableIdKey: // skip this key break; case EndExonKey: exonNode = ad as ObjectKeyValue; if (exonNode != null) { var newExon = Exon.Parse(exonNode.Value, dataStore.CurrentReferenceIndex); translation.EndExon = newExon; } break; case StartExonKey: exonNode = ad as ObjectKeyValue; if (exonNode != null) { var newExon = Exon.Parse(exonNode.Value, dataStore.CurrentReferenceIndex); translation.StartExon = newExon; } break; case TranscriptKey: // parse this during the references if (!DumperUtilities.IsReference(ad)) { throw new GeneralException("Found a Translation->Transcript entry that wasn't a reference."); } break; case Transcript.EndKey: translation.End = DumperUtilities.GetInt32(ad); break; case Transcript.StartKey: translation.Start = DumperUtilities.GetInt32(ad); break; case Transcript.VersionKey: translation.Version = (byte)DumperUtilities.GetInt32(ad); break; default: throw new GeneralException($"Unknown key found: {ad.Key}"); } } return(translation); }
/// <summary> /// parses the relevant data from each protein function predictions object /// </summary> public static DataStructures.VEP.ProteinFunctionPredictions Parse(ObjectValue objectValue) { var predictions = new DataStructures.VEP.ProteinFunctionPredictions(); // loop over all of the key/value pairs in the protein function predictions object foreach (AbstractData ad in objectValue) { // sanity check: make sure we know about the keys are used for if (!KnownKeys.Contains(ad.Key)) { throw new GeneralException($"Encountered an unknown key in the dumper mapper object: {ad.Key}"); } // handle each key switch (ad.Key) { case PolyPhenHumDivKey: // not used by default break; case PolyPhenKey: if (DumperUtilities.IsUndefined(ad)) { // do nothing } else { throw new GeneralException($"Could not handle the PolyPhen key: [{ad.GetType()}]"); } break; case PolyPhenHumVarKey: // used by default var polyPhenHumVarNode = ad as ObjectKeyValue; if (polyPhenHumVarNode != null) { predictions.PolyPhen = PolyPhen.Parse(polyPhenHumVarNode.Value); } else if (DumperUtilities.IsUndefined(ad)) { predictions.PolyPhen = null; } else if (DumperUtilities.IsReference(ad)) { // skip references for now } else { throw new GeneralException( $"Could not transform the AbstractData object into an ObjectKeyValue: [{ad.GetType()}]"); } break; case SiftKey: var siftNode = ad as ObjectKeyValue; if (siftNode != null) { predictions.Sift = Sift.Parse(siftNode.Value); } else if (DumperUtilities.IsUndefined(ad)) { predictions.Sift = null; } else if (DumperUtilities.IsReference(ad)) { // skip references for now } else { throw new GeneralException( $"Could not transform the AbstractData object into an ObjectKeyValue: [{ad.GetType()}]"); } break; default: throw new GeneralException($"Unknown key found: {ad.Key}"); } } return(predictions); }