/// <summary> /// Transcript assembly. Note that fragment bias estimation (--frag-bias-correct) and multi-read rescuing (--multi-read-correct) are not used. /// These take a lot of time, and they only provide better abundance estimates, which we use RSEM for. /// </summary> /// <param name="spritzDirectory"></param> /// <param name="threads"></param> /// <param name="bamPath"></param> /// <param name="geneModelGtfOrGffPath"></param> /// <param name="strandSpecific"></param> /// <param name="inferStrandSpecificity"></param> /// <param name="outputTranscriptGtfPath"></param> public static List <string> AssembleTranscripts(string spritzDirectory, int threads, string bamPath, string geneModelGtfOrGffPath, Genome genome, Strandedness strandSpecific, bool inferStrandSpecificity, out string outputTranscriptGtfPath) { Strandedness strandedness = strandSpecific; if (inferStrandSpecificity) { BAMProperties bamProperties = new BAMProperties(bamPath, geneModelGtfOrGffPath, genome, 0.8); strandedness = bamProperties.Strandedness; } string sortedCheckPath = Path.Combine(Path.GetDirectoryName(bamPath), Path.GetFileNameWithoutExtension(bamPath) + ".cufflinksSortCheck"); outputTranscriptGtfPath = Path.Combine(Path.GetDirectoryName(bamPath), Path.GetFileNameWithoutExtension(bamPath) + ".gtf"); return(new List <string> { WrapperUtility.ChangeToToolsDirectoryCommand(spritzDirectory), "samtools view -H " + WrapperUtility.ConvertWindowsPath(bamPath) + " | grep SO:coordinate > " + WrapperUtility.ConvertWindowsPath(sortedCheckPath), "if [ ! -s " + WrapperUtility.ConvertWindowsPath(sortedCheckPath) + " ]; then " + SamtoolsWrapper.SortBam(bamPath, threads) + "; fi", "bam=" + WrapperUtility.ConvertWindowsPath(bamPath), "if [ ! -s " + WrapperUtility.ConvertWindowsPath(sortedCheckPath) + " ]; then bam=" + WrapperUtility.ConvertWindowsPath(Path.Combine(Path.GetDirectoryName(bamPath), Path.GetFileNameWithoutExtension(bamPath) + ".sorted.bam")) + "; fi", "if [[ ! -f " + WrapperUtility.ConvertWindowsPath(outputTranscriptGtfPath) + " || ! -s " + WrapperUtility.ConvertWindowsPath(outputTranscriptGtfPath) + " ]]; then", " echo \"Performing stringtie transcript reconstruction on " + bamPath + "\"", " stringtie $bam " + " -p " + threads.ToString() + " -G " + WrapperUtility.ConvertWindowsPath(geneModelGtfOrGffPath) + " -o " + WrapperUtility.ConvertWindowsPath(outputTranscriptGtfPath) + (strandedness == Strandedness.None ? "" : strandedness == Strandedness.Forward ? "--fr" : "--rf"), "fi", }); }
public override string ToString() { StringBuilder s = new StringBuilder(); s.AppendLine("Protocol: " + Protocol.ToString()); s.AppendLine("Strandedness: " + Strandedness.ToString()); s.AppendLine("Fraction Forward Stranded: " + FractionForwardStranded.ToString()); s.AppendLine("Fraction Reverse Stranded: " + FractionReverseStranded.ToString()); s.AppendLine("Fraction Undetermined: " + FractionUndetermined.ToString()); return(s.ToString()); }
protected override void OnTick() { if (m_Count == 5) { List <Mobile> tomove = new List <Mobile>(); MultiComponentList mcl = m_Boat.Components; IPooledEnumerable eable = m_Boat.Map.GetObjectsInBounds(new Rectangle2D(m_Boat.X + mcl.Min.X, m_Boat.Y + mcl.Min.Y, mcl.Width, mcl.Height)); foreach (object o in eable) { if (o is Mobile && m_Boat.Contains((Mobile)o)) { var mobile = o as Mobile; if (mobile.Alive && !mobile.Blessed) { mobile.SendMessage(61, "You have drowned."); mobile.Kill(); } if (!mobile.Blessed) { tomove.Add(mobile); } } } eable.Free(); foreach (var mobile in tomove) { Strandedness.MoveStrandedMobile(mobile); } m_Boat.Delete(); Stop(); } else { m_Boat.Location = new Point3D(m_Boat.X, m_Boat.Y, m_Boat.Z - 1); if (m_Boat.TillerManMobile != null) { m_Boat.TillerManMobile.TillerManSay(1007168 + m_Count); } if (m_Boat.TillerManItem != null) { m_Boat.TillerManItem.Say(1007168 + m_Count); } ++m_Count; } }
public TranscriptQuantificationParameters(string spritzDirectory, string analysisDirectory, string referenceFastaPath, int threads, string geneModelPath, RSEMAlignerOption aligner, Strandedness strandedness, string[] fastq, bool doOutputBam) { SpritzDirectory = spritzDirectory; AnalysisDirectory = analysisDirectory; ReferenceFastaPath = referenceFastaPath; Threads = threads; GeneModelPath = geneModelPath; Aligner = aligner; Strandedness = strandedness; Fastq = fastq; DoOutputQuantificationBam = doOutputBam; }
public static void Strand(Mobile from) { Strandedness.EventSink_Login(new LoginEventArgs(from)); if (Utility.RandomBool()) { from.Damage(Utility.Random(5 * Utility.Random(1, 3))); from.SendMessage("You took some damage!"); } if (Utility.RandomBool()) { int fame = -400 * Utility.Random(1, 2); Misc.Titles.AwardFame(from, fame, true); } }
public void DoDeckDoor(Mobile m) { string sCabinDoor = ""; string sWorld = ""; string sSerial = ""; string sCode = ""; if (m is PlayerMobile) { CharacterDatabase DB = Server.Items.CharacterDatabase.GetDB(m); sCabinDoor = DB.CharacterBoatDoor; if (sCabinDoor != null) { string[] doors = sCabinDoor.Split('#'); int nEntry = 1; foreach (string doorz in doors) { if (nEntry == 1) { sSerial = doorz; } else if (nEntry == 2) { sCode = doorz; } else if (nEntry == 3) { sWorld = doorz; } nEntry++; } } if (Server.Misc.Worlds.GetRegionName(m.Map, m.Location) == "the Ship's Lower Deck" && sCabinDoor != null) { Point3D loc = m.Location; Map map = m.Map; int nFound = 0; foreach (Item item in World.Items.Values) { if (item is BoatDoor) { BoatDoor hatch = (BoatDoor)item; if (item != null && hatch.BoatCode == sCode && item.Serial.ToString() == sSerial && Worlds.GetMyWorld(item.Map, item.Location, item.X, item.Y) == sWorld ) { loc = item.Location; map = item.Map; nFound = 1; } } } if (nFound > 0) { CabinDoor(m, loc, map); } else { Strandedness.CabinGoneByeBye(m, sWorld); } } else { Strandedness.CabinGoneByeBye(m, sWorld); } DB.CharacterBoatDoor = null; } }
public static void Main(string[] args) { if (!WrapperUtility.CheckBashSetup()) { throw new FileNotFoundException("The Windows Subsystem for Windows has not been enabled. Please see https://smith-chem-wisc.github.io/Spritz/ for more details."); } // main setup involves installing tools if (args.Contains(ManageToolsFlow.Command)) { ManageToolsFlow.Install(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); return; } Parsed <Options> result = Parser.Default.ParseArguments <Options>(args) as Parsed <Options>; if (result == null) { Console.WriteLine("Please use GUI.exe if you are a first time user of Spritz."); Console.WriteLine("It aims to guide you through setting up tools and running a workflow."); Console.WriteLine(); Console.WriteLine("See above for commandline arguments for CMD.exe."); Console.WriteLine(" Required: -c for a command"); Console.WriteLine(" 1) Setting up tools: -c setup"); Console.WriteLine(" 2) Generating a protein database from ensembl: -c proteins"); Console.WriteLine(" 3) Analyzing variants: -c proteins"); Console.WriteLine(" Also required: --fq1 (and --fq2 if paired-end) for FASTQ files that exist or -s to download an SRA (see https://www.ncbi.nlm.nih.gov/sra)."); Console.WriteLine(); Console.WriteLine("Press any key to exit."); Console.ReadKey(); return; } Options options = result.Value; FinishSetup(options); // Download SRAs if they're specified bool useSraMethod = options.SraAccession != null && options.SraAccession.StartsWith("SR"); List <string[]> fastqsSeparated = useSraMethod ? SRAToolkitWrapper.GetFastqsFromSras(options.SpritzDirectory, options.Threads, options.AnalysisDirectory, options.SraAccession) : SeparateFastqs(options.Fastq1, options.Fastq2); if (options.Command.Equals(SampleSpecificProteinDBFlow.Command, StringComparison.InvariantCultureIgnoreCase)) { if (options.ReferenceVcf == null) { options.ReferenceVcf = new GATKWrapper(1).DownloadEnsemblKnownVariantSites(options.SpritzDirectory, true, options.Reference, false); } if (options.UniProtXml == null) { Console.WriteLine("Note: You can specify a UniProt XML file with the -x flag to transfer modificaitons and database references."); } // Parse the experiment type ExperimentType experimentType; if (options.ExperimentType == ExperimentType.RNASequencing.ToString()) { experimentType = ExperimentType.RNASequencing; } else if (options.ExperimentType == ExperimentType.WholeGenomeSequencing.ToString()) { experimentType = ExperimentType.WholeGenomeSequencing; } else if (options.ExperimentType == ExperimentType.ExomeSequencing.ToString()) { experimentType = ExperimentType.ExomeSequencing; } else { throw new ArgumentException("Error: experiment type was not recognized."); } // Check that options make sense with experiment type if (options.DoTranscriptIsoformAnalysis && experimentType != ExperimentType.RNASequencing) { throw new ArgumentException("Error: cannot do isoform analysis without RNA sequencing data."); } SampleSpecificProteinDBFlow flow = new SampleSpecificProteinDBFlow(); flow.Parameters.SpritzDirectory = options.SpritzDirectory; flow.Parameters.AnalysisDirectory = options.AnalysisDirectory; flow.Parameters.Reference = options.Reference; flow.Parameters.Threads = options.Threads; flow.Parameters.Fastqs = fastqsSeparated; flow.Parameters.ExperimentType = experimentType; flow.Parameters.StrandSpecific = options.StrandSpecific; flow.Parameters.InferStrandSpecificity = options.InferStrandSpecificity; flow.Parameters.OverwriteStarAlignment = options.OverwriteStarAlignments; flow.Parameters.GenomeStarIndexDirectory = options.GenomeStarIndexDirectory; flow.Parameters.GenomeFasta = options.GenomeFasta; flow.Parameters.ProteinFastaPath = options.ProteinFastaPath; flow.Parameters.ReferenceGeneModelGtfOrGff = options.GeneModelGtfOrGff; flow.Parameters.NewGeneModelGtfOrGff = options.NewGeneModelGtfOrGff; flow.Parameters.EnsemblKnownSitesPath = options.ReferenceVcf; flow.Parameters.UniProtXmlPath = options.UniProtXml; flow.Parameters.SkipVariantAnalysis = options.SkipVariantAnalysis; flow.Parameters.DoTranscriptIsoformAnalysis = options.DoTranscriptIsoformAnalysis; flow.Parameters.DoFusionAnalysis = options.DoFusionAnalysis; flow.Parameters.IndelFinder = options.IndelFinder; flow.Parameters.VariantCallingWorkers = options.VariantCallingWorkers; flow.GenerateSampleSpecificProteinDatabases(); Console.WriteLine("done"); } else if (options.Command.Equals(LncRNADiscoveryFlow.Command, StringComparison.InvariantCultureIgnoreCase)) { if (options.ExperimentType != null && !options.ExperimentType.Equals(ExperimentType.RNASequencing.ToString())) { throw new ArgumentException("Error: lncRNA discovery requires RNA-Seq reads."); } LncRNADiscoveryFlow lnc = new LncRNADiscoveryFlow(); lnc.Parameters.SpritzDirectory = options.SpritzDirectory; lnc.Parameters.AnalysisDirectory = options.AnalysisDirectory; lnc.Parameters.Reference = options.Reference; lnc.Parameters.Threads = options.Threads; lnc.Parameters.Fastqs = fastqsSeparated; lnc.Parameters.StrandSpecific = options.StrandSpecific; lnc.Parameters.InferStrandSpecificity = options.InferStrandSpecificity; lnc.Parameters.OverwriteStarAlignment = options.OverwriteStarAlignments; lnc.Parameters.GenomeStarIndexDirectory = options.GenomeStarIndexDirectory; lnc.Parameters.GenomeFasta = options.GenomeFasta; lnc.Parameters.ProteinFasta = options.ProteinFastaPath; lnc.Parameters.GeneModelGtfOrGff = options.GeneModelGtfOrGff; lnc.LncRNADiscoveryFromFastqs(); return; } else if (options.Command.Equals(GeneFusionDiscoveryFlow.Command, StringComparison.InvariantCultureIgnoreCase)) { if (options.ExperimentType != null && !options.ExperimentType.Equals(ExperimentType.RNASequencing.ToString())) { throw new ArgumentException("Error: gene fusion discovery with STAR fusion requires RNA-Seq reads."); } GeneFusionDiscoveryFlow flow = new GeneFusionDiscoveryFlow(); flow.Parameters.SpritzDirectory = options.SpritzDirectory; flow.Parameters.AnalysisDirectory = options.AnalysisDirectory; flow.Parameters.Reference = options.Reference; flow.Parameters.Threads = options.Threads; flow.Parameters.Fastqs = fastqsSeparated; flow.DiscoverGeneFusions(); return; } else if (options.Command.Equals(TransferModificationsFlow.Command)) { string[] xmls = options.UniProtXml.Split(','); TransferModificationsFlow transfer = new TransferModificationsFlow(); transfer.TransferModifications(options.SpritzDirectory, xmls[0], xmls[1]); return; } else if (options.Command.Equals(TranscriptQuantificationFlow.Command, StringComparison.InvariantCultureIgnoreCase)) { if (options.ExperimentType != null && !options.ExperimentType.Equals(ExperimentType.RNASequencing.ToString())) { throw new ArgumentException("Error: transcript quantification requires RNA-Seq reads."); } foreach (string[] fastq in fastqsSeparated) { Strandedness strandedness = options.StrandSpecific ? Strandedness.Forward : Strandedness.None; if (options.InferStrandSpecificity) { var bamProps = AlignmentFlow.InferStrandedness(options.SpritzDirectory, options.AnalysisDirectory, options.Threads, fastq, options.GenomeStarIndexDirectory, options.GenomeFasta, options.GeneModelGtfOrGff); strandedness = bamProps.Strandedness; } TranscriptQuantificationFlow quantify = new TranscriptQuantificationFlow(); quantify.Parameters = new TranscriptQuantificationParameters( options.SpritzDirectory, options.AnalysisDirectory, options.GenomeFasta, options.Threads, options.GeneModelGtfOrGff, RSEMAlignerOption.STAR, strandedness, fastq, true); quantify.QuantifyTranscripts(); } return; } else if (options.Command.Equals("strandedness")) { string[] fastqs = options.Fastq2 == null ? new[] { options.Fastq1 } : new[] { options.Fastq1, options.Fastq2 }; BAMProperties b = AlignmentFlow.InferStrandedness(options.SpritzDirectory, options.AnalysisDirectory, options.Threads, fastqs, options.GenomeStarIndexDirectory, options.GenomeFasta, options.GeneModelGtfOrGff); Console.WriteLine(b.ToString()); return; } else { throw new ArgumentException($"Error: command not recognized, {options.Command}"); } }
/// <summary> /// Gets commands to calculate expression an RSEM reference /// </summary> /// <param name="spritzDirectory"></param> /// <returns></returns> public List <string> CalculateExpressionCommands(string spritzDirectory, string referencePrefix, int threads, RSEMAlignerOption aligner, Strandedness strandedness, string[] fastqPaths, bool doOuptutBam) { if (fastqPaths.Length < 1) { throw new ArgumentOutOfRangeException("No fastq files were given for RSEM calculate expression."); } if (fastqPaths.Length > 2) { throw new ArgumentOutOfRangeException("Too many fastq file types given for RSEM calculate expression."); } List <string> scriptCommands = new List <string> { WrapperUtility.ChangeToToolsDirectoryCommand(spritzDirectory), "cd RSEM-1.3.0", }; string[] analysisFastqPaths = fastqPaths; string alignerOption = GetAlignerOption(spritzDirectory, aligner); string threadOption = "--num-threads " + threads.ToString(); string strandOption = "--strandedness " + strandedness.ToString().ToLowerInvariant(); // Decompress files if needed // The '--star-gzipped-read-file' and '--star-bzipped-read-file' options work, but then the rest of RSEM doesn't when using compressed files... bool fastqIsGunzipped = analysisFastqPaths[0].EndsWith("gz"); bool fastqIsBunzipped = analysisFastqPaths[0].EndsWith("bz2") || analysisFastqPaths[0].EndsWith("bz"); if (fastqIsGunzipped || fastqIsBunzipped) { for (int i = 0; i < analysisFastqPaths.Length; i++) { string decompressionCommand = fastqIsGunzipped ? "gunzip" : "bunzip2"; scriptCommands.Add($"{decompressionCommand} --keep {WrapperUtility.ConvertWindowsPath(analysisFastqPaths[i])}"); analysisFastqPaths[i] = Path.ChangeExtension(analysisFastqPaths[i], null); } } string inputOption = analysisFastqPaths.Length == 1 ? string.Join(",", analysisFastqPaths[0].Split(',').Select(f => WrapperUtility.ConvertWindowsPath(f))) : "--paired-end " + string.Join(",", analysisFastqPaths[0].Split(',').Select(f => WrapperUtility.ConvertWindowsPath(f))) + " " + string.Join(",", analysisFastqPaths[1].Split(',').Select(f => WrapperUtility.ConvertWindowsPath(f))); var megabytes = Math.Floor((double)Process.GetCurrentProcess().VirtualMemorySize64 / 1000000); string bamOption = doOuptutBam ? "--output-genome-bam" : "--no-bam-output"; OutputPrefix = Path.Combine(Path.GetDirectoryName(analysisFastqPaths[0].Split(',')[0]), Path.GetFileNameWithoutExtension(analysisFastqPaths[0].Split(',')[0]) + "_" + Path.GetExtension(analysisFastqPaths[0].Split(',')[0]).Substring(1).ToUpperInvariant() + referencePrefix.GetHashCode().ToString()); // RSEM likes to sort the transcript.bam file, which takes forever and isn't very useful, I've found. Just sort the genome.bam file instead string samtoolsCommands = !doOuptutBam ? "" : "if [[ ! -f " + WrapperUtility.ConvertWindowsPath(OutputPrefix + GenomeSortedBamSuffix) + " && ! -s " + WrapperUtility.ConvertWindowsPath(OutputPrefix + GenomeSortedBamSuffix) + " ]]; then\n" + " " + SamtoolsWrapper.SortBam(OutputPrefix + GenomeBamSuffix, threads) + "\n" + " " + SamtoolsWrapper.IndexBamCommand(OutputPrefix + GenomeSortedBamSuffix) + "\n" + "fi"; // construct the commands scriptCommands.AddRange(new List <string> { "if [[ ! -f " + WrapperUtility.ConvertWindowsPath(OutputPrefix + IsoformResultsSuffix) + " && ! -s " + WrapperUtility.ConvertWindowsPath(OutputPrefix + IsoformResultsSuffix) + " ]]; then " + "./rsem-calculate-expression " + "--time " + // include timed results "--calc-ci " + // posterior calculation of 95% confidence intervals alignerOption + " " + threadOption + " " + bamOption + " " + inputOption + " " + WrapperUtility.ConvertWindowsPath(referencePrefix) + " " + WrapperUtility.ConvertWindowsPath(OutputPrefix) + "; fi", samtoolsCommands }); return(scriptCommands); }