Esempio n. 1
0
        public string ConvertVCFChromosomesUCSC2Ensembl(string spritzDirectory, string vcfPath, string reference, bool dryRun)
        {
            string convertedEnsemblVcfPath = Path.Combine(Path.GetDirectoryName(vcfPath), Path.GetFileNameWithoutExtension(vcfPath) + ".ensembl.vcf");

            if (File.Exists(convertedEnsemblVcfPath) || dryRun)
            {
                return(convertedEnsemblVcfPath);
            }
            Dictionary <string, string> ucsc2EnsemblChromosomeMappings = EnsemblDownloadsWrapper.UCSC2EnsemblChromosomeMappings(spritzDirectory, reference);

            using (StreamReader reader = new StreamReader(vcfPath))
                using (StreamWriter writer = new StreamWriter(convertedEnsemblVcfPath))
                {
                    while (true)
                    {
                        string line = reader.ReadLine();
                        if (line == null)
                        {
                            break;
                        }
                        if (line.StartsWith("#"))
                        {
                            writer.Write(line + "\n");
                        }
                        string[] splitLine = line.Split('\t');
                        if (splitLine.Length > 1 && ucsc2EnsemblChromosomeMappings.TryGetValue(splitLine[0], out string newChrom))
                        {
                            splitLine[0] = newChrom;
                            writer.Write(string.Join("\t", splitLine) + '\n');
                        }
                    }
                }
            return(convertedEnsemblVcfPath);
        }
Esempio n. 2
0
        /// <summary>
        /// Annotate predicted transcripts
        /// </summary>
        /// <param name="spritzDirectory"></param>
        /// <param name="threads"></param>
        /// <param name="predictedGeneModelUcscBedPath"></param>
        /// <param name="reference"></param>
        /// <param name="slnckyOutPrefix"></param>
        /// <returns></returns>
        public static List <string> Annotate(string spritzDirectory, string analysisDirectory, int threads, string predictedGeneModelGtfPath, string reference, string slnckyOutPrefix)
        {
            string sortedBed12Cuffmerge = BEDOPSWrapper.GffOrGtf2Bed12(spritzDirectory, analysisDirectory, predictedGeneModelGtfPath);
            string ucscCuffmergeBedPath = EnsemblDownloadsWrapper.ConvertFirstColumnEnsembl2UCSC(spritzDirectory, reference, sortedBed12Cuffmerge);

            Directory.CreateDirectory(Path.GetDirectoryName(slnckyOutPrefix));
            string ucscReference = reference.Contains("38") ? "hg38" : "hg19";

            return(new List <string>
            {
                WrapperUtility.ChangeToToolsDirectoryCommand(spritzDirectory),
                "cd slncky",
                "if [[ ! -f " + WrapperUtility.ConvertWindowsPath(slnckyOutPrefix + LncsBedSuffix) + " || ! -s " + WrapperUtility.ConvertWindowsPath(slnckyOutPrefix + LncsBedSuffix) + " ]]; then " +
                "./slncky.v1.0" +
                " --threads " + threads.ToString() +
                " " + WrapperUtility.ConvertWindowsPath(ucscCuffmergeBedPath) +
                " " + ucscReference +
                " " + WrapperUtility.ConvertWindowsPath(slnckyOutPrefix) +
                "; fi"
            });
        }