/// <summary> /// executes the program /// </summary> protected override void ProgramExecution() { var renamer = ChromosomeRenamer.GetChromosomeRenamer(FileUtilities.GetReadStream(ConfigurationSettings.CompressedReference)); var customIntervalDbCreator = new CustomIntervalDbCreator(ConfigurationSettings.BedFile, ConfigurationSettings.OutputDirectory, renamer); customIntervalDbCreator.Create(); }
/// <summary> /// executes the program /// </summary> protected override void ProgramExecution() { var transcriptPath = ConfigurationSettings.InputPrefix + ".transcripts.gz"; var regulatoryPath = ConfigurationSettings.InputPrefix + ".regulatory.gz"; var genePath = ConfigurationSettings.InputPrefix + ".genes.gz"; var intronPath = ConfigurationSettings.InputPrefix + ".introns.gz"; var mirnaPath = ConfigurationSettings.InputPrefix + ".mirnas.gz"; var siftPath = ConfigurationSettings.InputPrefix + ".sift.dat"; var polyphenPath = ConfigurationSettings.InputPrefix + ".polyphen.dat"; var peptidePath = ConfigurationSettings.InputPrefix + ".peptides.gz"; var renamer = ChromosomeRenamer.GetChromosomeRenamer(FileUtilities.GetReadStream(ConfigurationSettings.InputReferencePath)); using (var transcriptReader = new VepTranscriptReader(transcriptPath)) using (var regulatoryReader = new VepRegulatoryReader(regulatoryPath)) using (var geneReader = new VepGeneReader(genePath)) using (var mergedGeneReader = new VepCombinedGeneReader(ConfigurationSettings.InputMergedGenesPath)) using (var intronReader = new VepSimpleIntervalReader(intronPath, "intron", GlobalImportCommon.FileType.Intron)) using (var mirnaReader = new VepSimpleIntervalReader(mirnaPath, "miRNA", GlobalImportCommon.FileType.MicroRna)) using (var peptideReader = new VepSequenceReader(peptidePath, "peptide", GlobalImportCommon.FileType.Peptide)) { var converter = new NirvanaDatabaseCreator(transcriptReader, regulatoryReader, geneReader, mergedGeneReader, intronReader, mirnaReader, peptideReader, renamer); converter.LoadData(); converter.MarkCanonicalTranscripts(ConfigurationSettings.InputLrgPath); converter.CreateTranscriptCacheFile(ConfigurationSettings.OutputCacheFilePrefix); converter.CopyPredictionCacheFile("SIFT", siftPath, CacheConstants.SiftPath(ConfigurationSettings.OutputCacheFilePrefix)); converter.CopyPredictionCacheFile("PolyPhen", polyphenPath, CacheConstants.PolyPhenPath(ConfigurationSettings.OutputCacheFilePrefix)); } }
/// <summary> /// creates a new annotation source with data from the micro-cache file /// </summary> internal static IAnnotationSource GetAnnotationSource(string cachePath, ISupplementaryAnnotationReader saReader, IConservationScoreReader conservationScoreReader = null, ISupplementaryAnnotationProvider customAnnotationProvider = null, ISupplementaryAnnotationProvider customIntervalProvider = null) { var streams = GetAnnotationSourceStreams(cachePath); var renamer = ChromosomeRenamer.GetChromosomeRenamer(GetReadStream($"{cachePath}.bases")); var saProvider = new MockSupplementaryAnnotationProvider(saReader, renamer); PerformanceMetrics.DisableOutput = true; return(new NirvanaAnnotationSource(streams, saProvider, conservationScoreReader, customAnnotationProvider, customIntervalProvider, null)); }
private void ProcessGenomeAssemblyDir(string gaDir) { var genomeAssembly = Path.GetFileName(gaDir); var compressedSequencePath = GetCompressedSequencePath(_referenceDir, genomeAssembly); var renamer = ChromosomeRenamer.GetChromosomeRenamer(FileUtilities.GetReadStream(compressedSequencePath)); var cacheFiles = GetCacheFiles(gaDir, renamer); var transcriptDataSources = GetTranscriptDataSources(cacheFiles); Console.WriteLine("GenomeAssembly dir: {0}", gaDir); foreach (var ds in transcriptDataSources) { ProcessTranscriptDataSource(cacheFiles, genomeAssembly, ds); Console.WriteLine(); } }
public SuppAnnotExtractor(string compressedRefFile, string inputSuppAnnotFile, int begin, int end, string datasourceName = null, string outDirectory = null) { _renamer = ChromosomeRenamer.GetChromosomeRenamer(FileUtilities.GetReadStream(compressedRefFile)); long intervalsPosition; var saHeader = SupplementaryAnnotationReader.GetHeader(inputSuppAnnotFile, out intervalsPosition); _begin = begin; _end = end; string miniSuppAnnotFile; if (datasourceName == null) { miniSuppAnnotFile = _renamer.GetUcscReferenceName(saHeader.ReferenceSequenceName) + '_' + begin.ToString(CultureInfo.InvariantCulture) + '_' + end.ToString(CultureInfo.InvariantCulture) + ".nsa"; if (outDirectory != null) { miniSuppAnnotFile = Path.Combine(outDirectory, miniSuppAnnotFile); } } else { miniSuppAnnotFile = _renamer.GetUcscReferenceName(saHeader.ReferenceSequenceName) + '_' + begin.ToString(CultureInfo.InvariantCulture) + '_' + end.ToString(CultureInfo.InvariantCulture) + '_' + datasourceName + ".nsa"; if (outDirectory != null) { miniSuppAnnotFile = Path.Combine(outDirectory, miniSuppAnnotFile); } } _writer = new SupplementaryAnnotationWriter(miniSuppAnnotFile, saHeader.ReferenceSequenceName, saHeader.DataSourceVersions); Console.WriteLine("MiniSA output to: " + miniSuppAnnotFile); }
static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("USAGE: {0} <reference path> <input vcf file>", Path.GetFileName(Environment.GetCommandLineArgs()[0])); Environment.Exit(1); } var referencePath = args[0]; var vcfPath = args[1]; if (!File.Exists(vcfPath)) { Console.WriteLine($"ERROR: {vcfPath} does not exist."); Environment.Exit(1); } if (!File.Exists(referencePath)) { Console.WriteLine($"ERROR: {referencePath} does not exist."); Environment.Exit(1); } var renamer = ChromosomeRenamer.GetChromosomeRenamer(FileUtilities.GetReadStream(referencePath)); var vid = new VID(); var counts = new Dictionary <VariantType, int>(); using (var reader = new LiteVcfReader(vcfPath)) { while (true) { var vcfLine = reader.ReadLine(); if (vcfLine == null) { break; } if (vcfLine.StartsWith("#")) { continue; } VcfVariant vcfVariant = null; try { vcfVariant = CreateVcfVariant(vcfLine); } catch (Exception e) { Console.WriteLine($"ERROR: Could not parse the VCF line:\n{vcfLine}"); Console.WriteLine(e.Message); Environment.Exit(1); } if (vcfVariant == null) { continue; } var variant = new VariantFeature(vcfVariant, renamer, vid); if (variant.IsReference) { continue; } variant.AssignAlternateAlleles(); bool hasMnv = false; foreach (var altAllele in variant.AlternateAlleles) { AddVariantType(altAllele.NirvanaVariantType, counts); if (altAllele.NirvanaVariantType == VariantType.MNV) { hasMnv = true; } } if (hasMnv) { Console.WriteLine(vcfLine); } } } const int keyFieldLength = 15; const int valueFieldLength = 9; Console.WriteLine("VariantType counts:"); Console.WriteLine($"{new string('-', keyFieldLength)} {new string('-', valueFieldLength)}"); foreach (var kvp in counts.OrderBy(x => x.Key.ToString())) { var spaceLeft = keyFieldLength - kvp.Key.ToString().Length - 1; var filler = new string(' ', spaceLeft); Console.WriteLine($"{kvp.Key}:{filler} {kvp.Value,9:N0}"); } }