示例#1
0
        public static int InferInnerDistance(string spritzDirectory, string analysisDirectory, string bamPath, string geneModelPath, out string[] outputFiles)
        {
            if (Path.GetExtension(geneModelPath) != ".bed")
            {
                geneModelPath = BEDOPSWrapper.GffOrGtf2Bed12(spritzDirectory, analysisDirectory, geneModelPath);
            }

            outputFiles = new string[]
            {
                Path.Combine(Path.GetDirectoryName(bamPath), Path.GetFileNameWithoutExtension(bamPath)) + InnerDistanceRPlotSuffix,
                Path.Combine(Path.GetDirectoryName(bamPath), Path.GetFileNameWithoutExtension(bamPath)) + InnerDistanceFrequencyTableSuffix,
                Path.Combine(Path.GetDirectoryName(bamPath), Path.GetFileNameWithoutExtension(bamPath)) + InnerDistanceDistanceTableSuffix
            };

            WrapperUtility.GenerateAndRunScript(WrapperUtility.GetAnalysisScriptPath(analysisDirectory, "InferInnerDistance.bash"), new List <string>
            {
                WrapperUtility.ChangeToToolsDirectoryCommand(spritzDirectory),
                "python RSeQC-2.6.4/scripts/inner_distance.py" +
                " -i " + WrapperUtility.ConvertWindowsPath(bamPath) +                                                                                 // input
                " -o " + WrapperUtility.ConvertWindowsPath(Path.Combine(Path.GetDirectoryName(bamPath), Path.GetFileNameWithoutExtension(bamPath))) + // out prefix
                " -r " + WrapperUtility.ConvertWindowsPath(geneModelPath),                                                                            // gene model in BED format
                WrapperUtility.EnsureClosedFileCommands(outputFiles[0]),
                WrapperUtility.EnsureClosedFileCommands(outputFiles[1]),
                WrapperUtility.EnsureClosedFileCommands(outputFiles[2]),
            }).WaitForExit();

            string[]   distance_lines = File.ReadAllLines(Path.Combine(Path.GetDirectoryName(bamPath), Path.GetFileNameWithoutExtension(bamPath)) + InnerDistanceDistanceTableSuffix);
            List <int> distances      = new List <int>();

            foreach (string dline in distance_lines)
            {
                if (int.TryParse(dline.Split('\t')[1], out int distance) &&
                    distance <250 && distance> -250)      // default settings for infer_distance
                {
                    distances.Add(distance);
                }
            }
            int averageDistance = (int)Math.Round(distances.Average(), 0);

            return(averageDistance);
        }
示例#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"
            });
        }