public PairedEndPeakFinder(string BAMFile, string prefix, string mtDNAName = "MT") { // ReasonForFailure = "NOT SET"; PeakEdgeWindowSize = 3; ScanningWindowSize = 11; if (String.IsNullOrEmpty(BAMFile) || String.IsNullOrEmpty(mtDNAName) || String.IsNullOrEmpty(prefix)) { throw new ArgumentException("Tried to load the paired peak finder without the a BAM file, output file Prefix or mt DNA chromosome name"); } if (!File.Exists(BAMFile)) { throw new IOException("Could not find BAM file: " + BAMFile); } rInt = new RInterface(); FileName = BAMFile; this.mtDNAName = mtDNAName; this.OutputFilePrefix = prefix; bp = new BAMParser(); //create count array countsOfSize = new double[StaticResources.CRS_LENGTH]; }
/// <summary> /// Render a PDF image to the file with the given name /// </summary> /// <param name="rInt"></param> /// <param name="filename"></param> public void Render(RInterface rInt, string filename) { //#if FALSE var e = rInt.CurrentEngine; lock (e) { if (this.slices.Count == 0 || !Assembly.SuccessfulAssembly) { return; } //load the file // string rFile = System.Reflection.Assembly.GetExecutingAssembly().Location; //char splitChar = '\\'; //if (Bio.CrossPlatform.Environment.RunningInMono) { // splitChar = '/'; //} //var tempSplit=rFile.Split(splitChar); //rFile=String.Join("/",tempSplit.Take(tempSplit.Length-1))+"/Visualization/MakeGenomeAssemblyPlot.r"; //rFile=rFile.Replace('\\','/'); //string loadFile="source('"+rFile+"')"; //e.Evaluate(loadFile); try { var fname = System.IO.Path.GetTempFileName(); var sw = new StreamWriter(fname); sw.Write(VisualizationRScript.FILE_AS_STRING); sw.Close(); var rFile = fname.Replace('\\', '/'); string loadFile = "source('" + rFile + "')"; e.Evaluate(loadFile); File.Delete(fname); } catch (Exception thrown) { Console.WriteLine("\n\nCould not render assembly graphic!\n" + thrown.Message); return; } //var strings = VisualizationRScript.FILE_AS_STRING.Split(new char[] {'\n','\r'},StringSplitOptions.RemoveEmptyEntries); //foreach (var str in strings) //{ // e.Evaluate(str); //} //TODO: THIS LOGIC REALLY NEEDS SOME CLEANING var curMax = Math.Max(this.slices.Max(x => x.ActualLeftGraphicalPosition.Value), this.slices.Max(x => x.ActualRightGraphicalPosition.Value)); //e.Evaluate("assemblyLength="+Assembly.AssemblyLength.ToString()); e.Evaluate("assemblyLength=" + curMax.ToString()); double outer = e.GetSymbol("outerRadius").AsNumeric().First(); e.Evaluate("createPlot(\"" + filename + "\")"); double total = Assembly.AssemblyLength; //TODO: Not sure how this ever could have been possible if (Math.Abs(total) < double.Epsilon) { return; } foreach (var slice in this.slices) { Dictionary <string, object> args = new Dictionary <string, object>(); //drawSegment<-function(start,end,low,height) args["start"] = slice.ActualLeftGraphicalPosition; args["end"] = slice.ActualRightGraphicalPosition; args["low"] = slice.MagnitudeLow; args["height"] = slice.Height; RDotNet.SymbolicExpression se; bool worked = e.EvaluateMethodWithNamedArguments("drawSegment", args, out se); if (!worked) { e.Evaluate("traceback()"); throw new RInterfaceException("Could not draw a segment from the assembly"); } } //now the arrows //drawArrow<-function(sMag,sAng,eMag,eAng) foreach (var arrow in this.arrows) { Dictionary <string, object> args = new Dictionary <string, object>(); //drawSegment<-function(start,end,low,height) args["sMag"] = arrow.sMag; args["sAng"] = arrow.sAng; args["eMag"] = arrow.eMag; args["eAng"] = arrow.eAng; RDotNet.SymbolicExpression se; bool worked = e.EvaluateMethodWithNamedArguments("drawArrow", args, out se); if (!worked) { throw new RInterfaceException("Could not draw an arrow from the assembly"); } } e.Evaluate("dev.off()"); } //#endif }
private bool active; //true while game is playing; false when rewinding; basically if objects are active void Start() { active = true; otherScript = (RInterface)gameObject.GetComponent(typeof(RInterface)); }