/// <summary> /// writes the prediction cache to disk /// </summary> public void Write(string cachePath) { using (var writer = new PredictionCacheWriter(cachePath, _header)) { writer.Write(_lookupTable, _predictionsPerRef); } }
private void CombinePredictionsCaches() { Console.WriteLine("Writing combined Sift..."); var mergedSift = GetMergedPredictions(CacheConstants.SiftPath(_prefix1), CacheConstants.SiftPath(_prefix2)); using (var writer = new PredictionCacheWriter(CacheConstants.SiftPath(_outPrefix), PredictionCacheHeader.GetHeader(DateTime.Now.Ticks, _genomeAssembly, _numRefSeq))) { var lookupTableList = new List <Prediction.Entry>(); foreach (var predictionCach in mergedSift) { lookupTableList.AddRange(predictionCach.LookupTable); } writer.Write(lookupTableList.ToArray(), mergedSift.Select(cache => cache.Predictions).ToArray()); } Console.WriteLine("Done."); Console.WriteLine("writing combined polyphen"); var mergedPolyphen = GetMergedPredictions(CacheConstants.PolyPhenPath(_prefix1), CacheConstants.PolyPhenPath(_prefix2)); using (var writer = new PredictionCacheWriter(CacheConstants.PolyPhenPath(_outPrefix), PredictionCacheHeader.GetHeader(DateTime.Now.Ticks, _genomeAssembly, _numRefSeq))) { var lookupTableList = new List <Prediction.Entry>(); foreach (var predictionCach in mergedPolyphen) { lookupTableList.AddRange(predictionCach.LookupTable); } writer.Write(lookupTableList.ToArray(), mergedPolyphen.Select(cache => cache.Predictions).ToArray()); } Console.WriteLine("Done"); }
public void Convert(string outputPath, string description, GlobalImportCommon.FileType fileType) { var inputPath = outputPath.Replace(".dat", ".dat.tmp"); using (var reader = new TempPredictionReader(inputPath, description, fileType)) { Console.Write($"- loading {description}... "); var tempPredictions = Load(reader); Console.WriteLine("finished."); Console.Write($"- creating {description} LUT... "); var oldLut = TempPrediction.CreateLookupTable(tempPredictions); var newLut = TempPrediction.ConvertLookupTable(oldLut); Console.WriteLine("finished."); Console.Write($"- converting {description} matrices... "); var predictionsPerRef = TempPrediction.ConvertMatrices(tempPredictions, oldLut, newLut, _numReferenceSeqs); Console.WriteLine("finished."); tempPredictions.Clear(); var header = PredictionCacheHeader.GetHeader(CurrentTimeTicks, reader.Header.GenomeAssembly, _numReferenceSeqs); Console.Write($"- writing to {Path.GetFileName(outputPath)}... "); using (var writer = new PredictionCacheWriter(outputPath, header)) { writer.Write(newLut, predictionsPerRef); } Console.WriteLine("finished."); } }
private static void WritePredictions(ILogger logger, string description, string filePath, PredictionHeader header, Prediction[][] predictionsPerRef) { logger.Write($"- writing {description} predictions... "); using (var stream = new BlockStream(new Zstandard(), FileUtilities.GetCreateStream(filePath), CompressionMode.Compress)) using (var writer = new PredictionCacheWriter(stream, CloneHeader(header))) { writer.Write(header.LookupTable, predictionsPerRef); } logger.WriteLine("finished."); }