/// <summary> /// executes the program /// </summary> protected override void ProgramExecution() { var bundle = GetDataBundle(ConfigurationSettings.InputReferencePath, ConfigurationSettings.InputPrefix); var header = bundle.Cache.Header.Custom as GlobalCustomHeader; if (header == null) { throw new InvalidCastException("Unable to cast the custom header as a GlobalCustomHeader"); } var regulatoryElement = MiniCacheUtilities.GetDesiredRegulatoryElement(bundle, ConfigurationSettings.RegulatoryElementId); if (regulatoryElement == null) { throw new UserErrorException($"Unable to find the desired regulatory element: {ConfigurationSettings.RegulatoryElementId}"); } var updater = new RegulatoryUpdater(ConfigurationSettings.RegulatoryElementId, regulatoryElement.ReferenceIndex, bundle.Cache.Header.TranscriptSource.ToString()); var outputFiles = new List <string>(); var status = updater.Update(bundle, ConfigurationSettings.OutputDirectory, header.VepVersion, outputFiles); UnitTestResourceCrawler.CleanupFiles(status, new List <string>(), outputFiles); if (status != UpdateStatus.Current) { throw new UserErrorException($"Unable to create the mini-cache file. Status: {status}"); } Console.WriteLine(); Console.WriteLine("- created the following files:"); foreach (var path in outputFiles) { Console.WriteLine(Path.GetFileNameWithoutExtension(path)); } }
private static CacheFile TryMatchFilename(string ndbPath, Func <string, Match> matcher, MiniCacheType type, ChromosomeRenamer renamer) { string filename = Path.GetFileName(ndbPath); if (filename == null) { return(null); } var match = matcher(filename); if (!match.Success) { return(null); } IUpdater updater; string id, transcriptDataSource; int position; ushort refIndex; switch (type) { case MiniCacheType.Transcript: var tuple = FormatUtilities.SplitVersion(match.Groups[1].Value); id = tuple.Item1; refIndex = renamer.GetReferenceIndex(match.Groups[2].Value); transcriptDataSource = match.Groups[3].Value; updater = new TranscriptUpdater(id, refIndex, transcriptDataSource); break; case MiniCacheType.Regulatory: id = match.Groups[1].Value; refIndex = renamer.GetReferenceIndex(match.Groups[2].Value); transcriptDataSource = match.Groups[3].Value; updater = new RegulatoryUpdater(id, refIndex, transcriptDataSource); break; case MiniCacheType.Position: refIndex = renamer.GetReferenceIndex(match.Groups[1].Value); position = int.Parse(match.Groups[2].Value); string refAllele = match.Groups[3].Value; string altAllele = match.Groups[4].Value; transcriptDataSource = match.Groups[5].Value; updater = new PositionUpdater(refIndex, position, refAllele, altAllele, transcriptDataSource); break; case MiniCacheType.PositionRange: refIndex = renamer.GetReferenceIndex(match.Groups[1].Value); position = int.Parse(match.Groups[2].Value); int endPosition = int.Parse(match.Groups[3].Value); transcriptDataSource = match.Groups[4].Value; updater = new PositionRangeUpdater(refIndex, position, endPosition, transcriptDataSource); break; default: throw new GeneralException($"Unexpected mini-cache type encountered: {type}"); } return(new CacheFile(ndbPath, updater.RefIndex, ConvertTranscriptDataSource(updater.TranscriptDataSource), type, updater)); }