public override bool PrepareOptions() { if (!File.Exists(this.AnnovarFile)) { ParsingErrors.Add(string.Format("Annovar file not exists {0}.", this.AnnovarFile)); return(false); } if (!File.Exists(this.BamFile)) { ParsingErrors.Add(string.Format("Bam file not exists {0}.", this.BamFile)); return(false); } if (!Directory.Exists(this.TargetDir)) { ParsingErrors.Add(string.Format("Output directory not exists {0}.", this.TargetDir)); return(false); } if (!string.IsNullOrEmpty(this.AffyAnnotationFile) && !File.Exists(this.AffyAnnotationFile)) { ParsingErrors.Add(string.Format("Affymetrix annotation file not exists {0}.", this.AffyAnnotationFile)); return(false); } return(true); }
public override bool PrepareOptions() { var dirs = this.ComparisonDirs.Where(m => !Directory.Exists(m)).ToList(); if (dirs.Count > 0) { ParsingErrors.Add(string.Format("Directory not exists:\n{0}.", dirs.Merge("\n"))); return(false); } dirs = this.ComparisonDirs.Where(dir => { var summaryfile = dir + "/summary.txt"; var transcriptFile = Directory.GetFiles(dir).Where(m => m.EndsWith("_transcripts.txt")).FirstOrDefault(); var operonFile = Directory.GetFiles(dir).Where(m => m.EndsWith("_operons.txt")).FirstOrDefault(); return(!File.Exists(summaryfile) || transcriptFile == null || operonFile == null); }).ToList(); if (dirs.Count > 0) { ParsingErrors.Add(string.Format("Directory doesn't contain rockhopper result:\n{0}.", dirs.Merge("\n"))); return(false); } if (!File.Exists(this.MapFile)) { ParsingErrors.Add(string.Format("Map file not exists {0}.", this.MapFile)); return(false); } return(true); }
public override bool PrepareOptions() { if (!File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", this.InputFile)); return(false); } if (!File.Exists(this.Samtools)) { ParsingErrors.Add(string.Format("Samtools location is not defined or not exists: {0}", this.Samtools)); return(false); } if (!File.Exists(this.GenomeFastaFile)) { ParsingErrors.Add(string.Format("Genome sequence file not exists {0}.", this.GenomeFastaFile)); return(false); } if (string.IsNullOrEmpty(this.OutputFile)) { this.OutputFile = this.InputFile + ".alleles"; } return(true); }
public override bool PrepareOptions() { if (!File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", this.InputFile)); return(false); } if (!string.IsNullOrEmpty(this.CountFile) && !File.Exists(this.CountFile)) { ParsingErrors.Add(string.Format("Count file not exists {0}.", this.CountFile)); return(false); } if (string.IsNullOrEmpty(this.OutputFile)) { string infile = this.InputFile; if (infile.ToLower().EndsWith(".gz")) { infile = FileUtils.ChangeExtension(infile, ""); } infile = FileUtils.ChangeExtension(infile, ""); Console.WriteLine("infile=" + infile); this.OutputFile = infile + "_mirna.fastq"; } return(true); }
private static void HandleIndexStyles(MethodCall[] methodCalls, Algo algo, ParsingErrors parsingErrors) { var setIndexStyleCalls = methodCalls.Where(call => call.MethodName == "SetIndexStyle"); var indexesStyles = new Dictionary <int, DrawingShapeStyle>(); foreach (var methodCall in setIndexStyleCalls) { int index; if (!int.TryParse(methodCall.Parameters[0], out index)) { parsingErrors.Add(ErrorType.NotSupportedWarning, "SetIndexStyle", "Can't cast to int: " + methodCall.Parameters[0]); continue; } var drawingShapeStyle = methodCall.Parameters[1].ToDrawingShapeStyle(); indexesStyles[index] = drawingShapeStyle; if (methodCall.Parameters.Length >= 4) { int width; if (int.TryParse(methodCall.Parameters[3], out width)) { algo.Widths[index] = width; } } } foreach (var keyValuePair in indexesStyles) { algo.Styles[keyValuePair.Key] = keyValuePair.Value; } }
protected virtual void AddError(ErrorContext errorContext) { string errorKey = GetErrorKey(errorContext.Path); string errorValue = errorContext.Error.Message; ParsingErrors.Add(errorKey, errorValue); }
protected void CheckDirectory(string key, string dirName) { if (!Directory.Exists(dirName)) { ParsingErrors.Add(string.Format("Directory {0} not exists: {1}", key, dirName)); } }
private bool PrepareOutputDirectory() { var outputdir = GetOutputDirectory(); if (!Directory.Exists(outputdir)) { try { Directory.CreateDirectory(outputdir); } catch (Exception ex) { ParsingErrors.Add(string.Format("Cannot create directory {0} : {1}", outputdir, ex.Message)); return(false); } } if (!Directory.Exists(CandidatesDirectory)) { try { Directory.CreateDirectory(CandidatesDirectory); } catch (Exception ex) { ParsingErrors.Add(string.Format("Cannot create directory {0} : {1}", CandidatesDirectory, ex.Message)); return(false); } } return(true); }
protected void CheckFile(string key, string fileName) { if (!File.Exists(fileName)) { ParsingErrors.Add(string.Format("File {0} not exists: {1}", key, fileName)); } }
public override bool PrepareOptions() { if (!string.IsNullOrWhiteSpace(ContaminantFile) && !File.Exists(ContaminantFile)) { ParsingErrors.Add(string.Format("Contaminant file not exists: {0}", ContaminantFile)); } if (!File.Exists(InputFile)) { ParsingErrors.Add(string.Format("Input file not exists: {0}", InputFile)); } if (string.IsNullOrWhiteSpace(this.OutputFile)) { if (ReversedOnly) { OutputFile = FileUtils.ChangeExtension(InputFile, this.DecoyKey + "_ONLY.fasta"); } else { OutputFile = FileUtils.ChangeExtension(InputFile, this.DecoyKey + ".fasta"); } } if (IsPseudoAminoacid) { PseudoAminoacidBuilder = new PseudoSequenceBuilder(PseudoAminoacids, IsPseudoForward); } return(ParsingErrors.Count == 0); }
public override bool PrepareOptions() { if (!File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", this.InputFile)); return(false); } if (!File.Exists(this.DbsnpFile)) { ParsingErrors.Add(string.Format("Dbsnp file not exists {0}.", this.DbsnpFile)); return(false); } if (!File.Exists(this.FastaFile)) { ParsingErrors.Add(string.Format("Genome fasta file not exists {0}.", this.FastaFile)); return(false); } if (!string.IsNullOrEmpty(this.G1000File) && !File.Exists(this.G1000File)) { ParsingErrors.Add(string.Format("1000 genome file not exists {0}.", this.G1000File)); return(false); } return(true); }
public override bool PrepareOptions() { if (!File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file is not exists: {0}.", this.InputFile)); return(false); } foreach (var file in MappedFiles) { if (!File.Exists(file)) { ParsingErrors.Add(string.Format("Mapped file is not exists: {0}.", file)); return(false); } } if (!Unmapped) { if (FileTags == null || FileTags.Count == 0) { FileTags = (from f in MappedFiles select Path.GetFileNameWithoutExtension(f)).ToList(); } if (FileTags.Count != MappedFiles.Count) { ParsingErrors.Add(string.Format("The number of file tag {0} should be equals to number of mapped file {1}.", FileTags.Count, MappedFiles.Count)); return(false); } } return(true); }
public override bool PrepareOptions() { if (!File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", this.InputFile)); return(false); } if (!File.Exists(this.CoordinateFile)) { ParsingErrors.Add(string.Format("Gff file not exists {0}.", this.CoordinateFile)); return(false); } if (!string.IsNullOrEmpty(this.CountFile) && !File.Exists(this.CountFile)) { ParsingErrors.Add(string.Format("Count file not exists {0}.", this.CountFile)); return(false); } if (string.IsNullOrEmpty(this.OutputFile)) { this.OutputFile = this.InputFile + ".vcf"; } return(true); }
public World(string xmlFile, string historyFile, string sitesAndPopulationsFile, string mapFile) { ParsingErrors = new ParsingErrors(); Log = new StringBuilder(); Log.AppendLine("Start: " + DateTime.Now.ToLongTimeString()); CreateUnknowns(); XMLParser xml = new XMLParser(this, xmlFile); xml.Parse(); HistoryParser history = new HistoryParser(this, historyFile); Log.Append(history.Parse()); SitesAndPopulationsParser sitesAndPopulations = new SitesAndPopulationsParser(this, sitesAndPopulationsFile); sitesAndPopulations.Parse(); ProcessHFtoEntityLinks(); HistoricalFigure.Filters = new List<string>(); Site.Filters = new List<string>(); WorldRegion.Filters = new List<string>(); UndergroundRegion.Filters = new List<string>(); Entity.Filters = new List<string>(); War.Filters = new List<string>(); Battle.Filters = new List<string>(); SiteConquered.Filters = new List<string>(); Era.Filters = new List<string>(); BeastAttack.Filters = new List<string>(); Artifact.Filters = new List<string>(); GenerateCivIdenticons(); GenerateMaps(mapFile); Log.AppendLine(ParsingErrors.Print()); Log.AppendLine("Finish: " + DateTime.Now.ToLongTimeString()); }
public override bool PrepareOptions() { foreach (var file in this.InputFiles) { if (!File.Exists(file)) { ParsingErrors.Add(string.Format("Cuffdiff group tracking file not exists {0}.", file)); return(false); } } foreach (var file in this.SignificantFiles) { if (!File.Exists(file)) { ParsingErrors.Add(string.Format("Cuffdiff significant file not exists {0}.", file)); return(false); } } if (!string.IsNullOrEmpty(this.MapFile) && !File.Exists(this.MapFile)) { ParsingErrors.Add(string.Format("Cuffdiff group/sample map file not exists {0}.", this.MapFile)); return(false); } return(true); }
public World(string xmlFile, string historyFile, string sitesAndPopulationsFile, string mapFile) { ParsingErrors = new ParsingErrors(); Log = new StringBuilder(); Log.AppendLine("Start: " + DateTime.Now.ToLongTimeString()); CreateUnknowns(); XMLParser xml = new XMLParser(this, xmlFile); xml.Parse(); HistoryParser history = new HistoryParser(this, historyFile); Log.Append(history.Parse()); SitesAndPopulationsParser sitesAndPopulations = new SitesAndPopulationsParser(this, sitesAndPopulationsFile); sitesAndPopulations.Parse(); HistoricalFigure.Filters = new List<string>(); Site.Filters = new List<string>(); WorldRegion.Filters = new List<string>(); UndergroundRegion.Filters = new List<string>(); Entity.Filters = new List<string>(); War.Filters = new List<string>(); Battle.Filters = new List<string>(); SiteConquered.Filters = new List<string>(); Era.Filters = new List<string>(); BeastAttack.Filters = new List<string>(); Artifact.Filters = new List<string>(); GenerateCivIdenticons(); GenerateMaps(mapFile); //DeathCauses = Events.OfType<LegendsViewer.HFDied>().Select(death => death.Cause).GroupBy(death => death).Select(death => death.Key).OrderBy(death => death.GetDescription()).ToList(); Log.AppendLine(ParsingErrors.Print()); Log.AppendLine("Finish: " + DateTime.Now.ToLongTimeString()); }
protected override void ValidateListFile() { if (!File.Exists(this.ListFile)) { ParsingErrors.Add(string.Format("List file not exists {0}.", this.ListFile)); } else { var files = (from l in File.ReadAllLines(this.ListFile) where l.Trim().Length > 1 select l).ToList(); foreach (var file in files) { var parts = file.Split('\t'); var name = parts[0]; var countFile = parts[1]; if (!File.Exists(countFile)) { ParsingErrors.Add(string.Format("Count file not exists {0}.", countFile)); } if (parts.Length > 2) { var fastqFile = parts[2]; if (!File.Exists(fastqFile)) { ParsingErrors.Add(string.Format("Fastq file not exists {0}.", fastqFile)); } } } } }
public override bool PrepareOptions() { var files = FastqFiles.TakeWhile(m => !File.Exists(m)).ToList(); if (files.Count > 0) { ParsingErrors.Add(string.Format("Thoese files not exists {0}.", files.Merge("\n"))); return(false); } var gzipfile = new GzipTextReader(null); if (FastqFiles.Any(m => gzipfile.NeedProcess(m))) { if (!File.Exists(this.Gzip)) { ParsingErrors.Add(string.Format("Gzip not exists {0}.", this.Gzip)); return(false); } } if (FastqFiles.Count != OutputFiles.Count) { ParsingErrors.Add(string.Format("Count of FastQ not exists {0}.", this.Gzip)); return(false); } return(true); }
public override bool PrepareOptions() { var result = base.PrepareOptions(); if (!File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", this.InputFile)); } if (!File.Exists(this.CoordinateFile)) { ParsingErrors.Add(string.Format("Gff file not exists {0}.", this.CoordinateFile)); } if (!string.IsNullOrEmpty(this.FastaFile) && !File.Exists(this.FastaFile)) { ParsingErrors.Add(string.Format("Fasta file not exists {0}.", this.FastaFile)); } if (!string.IsNullOrEmpty(this.FastqFile) && !File.Exists(this.FastqFile)) { ParsingErrors.Add(string.Format("Fastq file not exists {0}.", this.FastqFile)); } return(result && ParsingErrors.Count == 0); }
public override bool PrepareOptions() { if (!File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", this.InputFile)); return(false); } var lines = GetAnnovarFiles(); if (lines.Count == 0) { ParsingErrors.Add(string.Format("Input file is empty {0}.", this.InputFile)); return(false); } var missed = (from l in lines where !File.Exists(l.Key) select l.Key).Union( from l in lines where !string.IsNullOrEmpty(l.Value) && !File.Exists(l.Value) select l.Value).ToArray(); if (missed.Length > 0) { ParsingErrors.Add(string.Format("One or more file are missing: \n{0}.", missed.Merge("\n"))); return(false); } return(true); }
private void HandleFunctions(string code, Algo algo, ParsingErrors parsingErrors) { var withoutProperties = code.RemoveMq4Properies(); var mq4Functions = FunctionsParser.Parse(withoutProperties).ToArray(); algo.Code.Functions = mq4Functions.ToList(); HandleInit(algo, mq4Functions, parsingErrors); }
public ParsingErrors(ParsingError headError, ParsingErrors tailErrors, TextInput errorLocation, bool isFatal = false) { _headError = headError; _tailErrors = tailErrors; _errorLocation = errorLocation; IsFatal = isFatal; // System.Diagnostics.Trace.WriteLine("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ " + headError + " " + errorLocation); }
public override bool PrepareOptions() { if (!Directory.Exists(RootDirectory)) { ParsingErrors.Add(string.Format("Directory not exist : {0}", RootDirectory)); } return(ParsingErrors.Count == 0); }
public override bool PrepareOptions() { if (!Directory.Exists(this.InputDir)) { ParsingErrors.Add(string.Format("Input directory not exists {0}.", this.InputDir)); } return(ParsingErrors.Count == 0); }
public override bool PrepareOptions() { if (!File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", this.InputFile)); } return(ParsingErrors.Count == 0); }
public override bool PrepareOptions() { if (!"-".Equals(InputFile) && !File.Exists(InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", InputFile)); return(false); } return(true); }
public override bool PrepareOptions() { if (!Directory.Exists(this.InputDir)) { ParsingErrors.Add(string.Format("Root directory not exists {0}.", this.InputDir)); return(false); } return(true); }
public override bool PrepareOptions() { if (!string.IsNullOrEmpty(this.InputFile) && !File.Exists(this.InputFile)) { ParsingErrors.Add(string.Format("Input file not exists {0}.", this.InputFile)); return(false); } return(true); }
protected void CheckProperty(string propertyName) { var properties = this.GetType().GetProperties().ToDictionary(m => m.Name); if (!properties.ContainsKey(propertyName)) { throw new ArgumentException("Property {0} not exist.", propertyName); } var pi = properties[propertyName]; OptionAttribute oa = (OptionAttribute)Attribute.GetCustomAttribute(pi, typeof(OptionAttribute)); if (oa != null) { if (oa.MetaValue.Equals("FILE")) { string filename = pi.GetValue(this, null) as string; if (!string.IsNullOrEmpty(filename) && !File.Exists(filename)) { ParsingErrors.Add(string.Format("File {0} not exists : {1}.", oa.HelpText, filename)); } } else if (oa.MetaValue.Equals("DIRECTORY")) { string dirname = pi.GetValue(this, null) as string; if (!string.IsNullOrEmpty(dirname) && !Directory.Exists(dirname)) { ParsingErrors.Add(string.Format("Directory {0} not exists : {1}.", oa.HelpText, dirname)); } } } else { OptionListAttribute ola = (OptionListAttribute)Attribute.GetCustomAttribute(pi, typeof(OptionListAttribute)); if (ola != null) { IList <string> filenames = pi.GetValue(this) as IList <string>; if (ola.MetaValue.Equals("FILELIST")) { foreach (var filename in filenames) { if (!string.IsNullOrEmpty(filename) && !File.Exists(filename)) { ParsingErrors.Add(string.Format("File {0} not exists : {1}.", ola.HelpText, filename)); } } } } else { throw new ArgumentException("Property {0} doesn't have attribute Option/OptionList.", propertyName); } } }
public override bool PrepareOptions() { var result = base.PrepareOptions(); if (!File.Exists(OtherFile)) { ParsingErrors.Add(string.Format("File not exists : {0}", OtherFile)); } return(result && ParsingErrors.Count == 0); }
public override bool PrepareOptions() { base.PrepareOptions(); if (!string.IsNullOrEmpty(this.CountFile) && !File.Exists(this.CountFile)) { ParsingErrors.Add(string.Format("Count file not exists {0}.", this.CountFile)); } return(ParsingErrors.Count == 0); }
public ParsingResult Parse(string code, AlgoType algotype, File[] includeFiles) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var parsingErrors = new ParsingErrors(); var algo = new Algo { Mq4Code = code, AlgoType = algotype }; string[] customIndicators; code = code .RemoveComments() .IncludeFiles(includeFiles) .HandleParsingErrors(parsingErrors); if (parsingErrors.Errors.Any(error => error.ErrorType >= ErrorType.NotSupportedCriticalError)) { return(new ParsingResult(algo, parsingErrors.Errors)); } code = code .ReplaceDateTimeToInt() .ReplaceDateConstants() .ReplaceDefines() .ReplaceCSharpKeyWords() .RemoveDotsFromNames() .AddZeroToDecimalNumbers() .ReplaceUnknownSymbols() .ReplaceMq4RgbColorsToKnownColors() .ReplaceColorToInt() .ReplaceCAlgoKeyWords() .ReplacePrintToMq4Print() .RenameFunctions() .AddRefModifiers() .AddTypeParameterToICustom(out customIndicators); HandleProperties(code, algo); HandleParameters(code, algo); HandleFunctions(code, algo, parsingErrors); HandleFields(code, algo); algo.Code.ExtractStaticVariablesToFields(); algo.Code.ReplaceSimpleTypesToMq4Types(); algo.Code.RenameStandardFunctions(); algo.Code.AddMq4InitFunctionIfDoesNotExist(); algo.CustomIndicators = customIndicators; return(new ParsingResult(algo, parsingErrors.Errors)); }
public Format ParseFormat(string format) { var result = new Format(format); var current = result; Placeholder currentPlaceholder = null; // Store parsing errors until the end: var parsingErrors = new ParsingErrors(result); int nestedDepth = 0; int lastI = 0; int operatorIndex = 0; int selectorIndex = 0; for (int i = 0, length = format.Length; i < length; i++) { var c = format[i]; if (currentPlaceholder == null) { if (c == '{') { // Finish the last text item: if (i != lastI) current.Items.Add(new LiteralText(current, lastI) { endIndex = i }); lastI = i + 1; // See if this brace should be escaped: if (!this.AlternativeEscaping) { var nextI = lastI; if (nextI < length && format[nextI] == '{') { i++; continue; } } // New placeholder: nestedDepth++; currentPlaceholder = new Placeholder(current, i, nestedDepth); current.Items.Add(currentPlaceholder); current.HasNested = true; operatorIndex = i+1; selectorIndex = 0; } else if (c == '}') { // Finish the last text item: if (i != lastI) current.Items.Add(new LiteralText(current, lastI) { endIndex = i }); lastI = i + 1; // See if this brace should be escaped: if (!this.AlternativeEscaping) { var nextI = lastI; if (nextI < length && format[nextI] == '}') { i++; continue; } } // Make sure that this is a nested placeholder before we un-nest it: if (current.parent == null) { parsingErrors.AddIssue(current, "Format string has too many closing braces", i, i + 1); continue; } // End of the placeholder's Format: nestedDepth--; current.endIndex = i; current.parent.endIndex = i + 1; current = current.parent.parent; } else if (this.AlternativeEscaping && c == this.AlternativeEscapeChar) { // See if the next char is a brace that should be escaped: var nextI = i + 1; if (nextI < length && (format[nextI] == '{' || format[nextI] == '}')) { // Finish the last text item: if (i != lastI) current.Items.Add(new LiteralText(current, lastI) { endIndex = i }); lastI = i + 1; i++; continue; } } } else { // Placeholder is NOT null, so that means we're parsing the selectors: if (Operators.IndexOf(c) != -1) { // Add the selector: if (i != lastI) { currentPlaceholder.Selectors.Add(new Selector(format, lastI, i, operatorIndex, selectorIndex)); selectorIndex++; operatorIndex = i; } lastI = i + 1; } else if (c == ':') { // Add the selector: if (i != lastI) currentPlaceholder.Selectors.Add(new Selector(format, lastI, i, operatorIndex, selectorIndex)); else if (operatorIndex != i) { // There are trailing operators. For now, this is an error. parsingErrors.AddIssue(current, "There are trailing operators in the selector", operatorIndex, i); //var issue = "There are trailing operators in the selector"; //ParserError(format, operatorIndex, issue, result); } lastI = i + 1; // Start the format: currentPlaceholder.Format = new Format(currentPlaceholder, i + 1); current = currentPlaceholder.Format; currentPlaceholder = null; } else if (c == '}') { // Add the selector: if (i != lastI) currentPlaceholder.Selectors.Add(new Selector(format, lastI, i, operatorIndex, selectorIndex)); else if (operatorIndex != i) { // There are trailing operators. For now, this is an error. parsingErrors.AddIssue(current, "There are trailing operators in the selector", operatorIndex, i); //ParserError(format, operatorIndex, "There are trailing operators in the selector", result); } lastI = i + 1; // End the placeholder with no format: nestedDepth--; currentPlaceholder.endIndex = i + 1; current = currentPlaceholder.parent; currentPlaceholder = null; } else { // Let's make sure the selector characters are valid: // Make sure it's alphanumeric: if (('0' <= c && c <= '9') || (AlphanumericSelectors && ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z')) || (AllowedSelectorChars.IndexOf(c) != -1)) { } else { // Invalid character in the selector. parsingErrors.AddIssue(current, "Invalid character in the selector", i, i + 1); //ParserError(format, i, "Invalid character in the selector", result); } } } } // finish the last text item: if (lastI != format.Length) current.Items.Add(new LiteralText(current, lastI) { endIndex = format.Length }); // Check that the format is finished: if (current.parent != null || currentPlaceholder != null) { //ParserError(format, format.Length, "Format string is missing a closing brace", result); parsingErrors.AddIssue(current, "Format string is missing a closing brace", format.Length, format.Length); current.endIndex = format.Length; while (current.parent != null) { current = current.parent.parent; current.endIndex = format.Length; } } // Check if there were any parsing errors: if (parsingErrors.HasIssues && ErrorAction == Core.ErrorAction.ThrowError) throw parsingErrors; return result; }