static HlaAssignMain CreateProgramFromArguments(string[] args) { ArgCollection argCollection = ArgCollection.GetInstance(args); if (argCollection.ExtractOptionalFlag("help")) { Console.WriteLine(); Console.WriteLine(UsageMessage); Console.WriteLine(HelpMessage); return(null); } bool bExcel = argCollection.ExtractOptionalFlag("EXCEL"); argCollection.CheckNoMoreOptions(); double?leakProbabilityOrNull = argCollection.ExtractNext <double?>("leakProbabilityOrNull"); double pValue = argCollection.ExtractNext <double>("pValue"); string directoryName = argCollection.ExtractNext <string>("directory"); string caseName = argCollection.ExtractNext <string>("caseName"); string hlaFactoryName = argCollection.ExtractNext <string>("hlaFactory"); RangeCollection pieceIndexRange = argCollection.ExtractNext <RangeCollection>("pieceIndexRange"); int pieceCount = argCollection.ExtractNext <int>("pieceCount"); SpecialFunctions.CheckCondition(0 <= pieceIndexRange.FirstElement && pieceIndexRange.LastElement < pieceCount, "The pieceIndexRange must be a subrange of " + RangeCollection.GetInstance(0, pieceCount - 1).ToString()); RangeCollection nullIndexRange = argCollection.ExtractNext <RangeCollection>("nullIndexRange"); argCollection.CheckThatEmpty(); return(new HlaAssignMain(bExcel, leakProbabilityOrNull, pValue, directoryName, caseName, hlaFactoryName, pieceIndexRange, pieceCount, nullIndexRange)); }
public static void Main(string[] args) { try { // Parse arguments ArgCollection argCollection = ArgCollection.GetInstance(args); if (argCollection.ExtractOptionalFlag("Help")) { Console.WriteLine(HelpString); return; } string modelName = argCollection.ExtractOptional("model", "LANLIEDB03062007"); bool modelOnly = argCollection.ExtractOptionalFlag("modelOnly"); bool inputHasHeader = argCollection.ExtractOptionalFlag("inputHasHeader"); MerLength merLength = argCollection.ExtractOptional <MerLength>("merLength", MerLength.scan); int? dOfCenter = argCollection.ExtractOptional <int?>("withinDOfCenter", null); ShowBy showBy = argCollection.ExtractOptional <ShowBy>("showBy", ShowBy.all); string hlaSetName = argCollection.ExtractOptional <string>("hlaSet", "singleton"); HlaSetSpecification hlaSetSpecification = HlaSetSpecification.GetInstance(hlaSetName); argCollection.CheckNoMoreOptions(); string inputFileName = argCollection.ExtractNext <string>("inputFile"); string outputFileName = argCollection.ExtractNext <string>("outputFile"); argCollection.CheckThatEmpty(); ReadInputCreatingOutput(showBy, modelName, inputHasHeader, merLength, dOfCenter, hlaSetSpecification, modelOnly, inputFileName, outputFileName); } catch (Exception exception) { Console.WriteLine(""); Console.WriteLine(exception.Message); if (exception.InnerException != null) { Console.WriteLine(exception.InnerException.Message); } Console.Error.WriteLine(""); Console.Error.WriteLine(@"For more help: Epipred -help"); System.Environment.Exit(-1); } }
static void Main(string[] args) { try { ArgCollection argCollection = ArgCollection.GetInstance(args); if (argCollection.ExtractOptionalFlag("Help")) { Console.WriteLine(HelpString); return; } int stopLength = argCollection.ExtractOptional <int>("stopLength", 10000); argCollection.CheckNoMoreOptions(2); string inputFileName = argCollection.ExtractNext <string>("inputFile"); string outputFileName = argCollection.ExtractNext <string>("outputFile"); argCollection.CheckThatEmpty(); CreateVaccine.CreateVaccine.MakeGreedyEpitomes(inputFileName, outputFileName, stopLength); } catch (Exception exception) { Console.WriteLine(""); Console.WriteLine(exception.Message); if (exception.InnerException != null) { Console.WriteLine(exception.InnerException.Message); } Console.Error.WriteLine(""); Console.Error.WriteLine(@"For more help: CreateEpitome -help"); System.Environment.Exit(-1); } }
static void Main(string[] args) { //HlaMsr1Factory.UnitTest(); try { ArgCollection argCollection = ArgCollection.GetInstance(args); string ethnicityName = argCollection.ExtractOptional <string>("ethnicity", "").ToLowerInvariant(); SpecialFunctions.CheckCondition(Linkdis.EthnicityNameLowerList().Contains(ethnicityName), string.Format("'-ethnicity ETHNICITY' is required, where ETHNICITY is " + Linkdis.EthnicityNameMixedList().StringJoin(", "))); int outputLineLimit = argCollection.ExtractOptional <int>("outputLineLimit", 100000); int combinationLimit = argCollection.ExtractOptional <int>("combinationLimit", 10000); bool isSparse = argCollection.ExtractOptionalFlag("sparse"); argCollection.CheckNoMoreOptions(3); string inputFileName = argCollection.ExtractNext <string>("inputFile"); string phasedOutputFileName = argCollection.ExtractNext <string>("phasedOutputFile"); string unphasedOutputFileName = argCollection.ExtractNext <string>("unphasedOutputFile"); argCollection.CheckThatEmpty(); Linkdis linkdis = Linkdis.GetInstance(ethnicityName, combinationLimit); string versionName = string.Format("MSCompBio HLA Completion v. {0}", GetVersionString()); CounterWithMessages pidCounter = CounterWithMessages.GetInstance("Pid index = {0}", 1, null); int outputLineIndex = -1; using (TextWriter phasedTextWriter = File.CreateText(phasedOutputFileName), unphasedTextWriter = File.CreateText(unphasedOutputFileName)) { phasedTextWriter.WriteLine(versionName + "\n"); unphasedTextWriter.WriteLine(versionName + "\n"); phasedTextWriter.WriteLine("pid" + "\t" + PhasedExpansion.Header); unphasedTextWriter.WriteLine("pid" + "\t" + UnphasedExpansion.Header); outputLineIndex += 6; HashSet <string> warningSet = new HashSet <string>(); using (TextReader textReader = File.OpenText(inputFileName)) { foreach (PidAndHlaSet pidAndHlaSet in isSparse ? PidAndHlaSet.GetEnumerationSparse(textReader) : PidAndHlaSet.GetEnumerationDense(textReader)) { pidCounter.Increment(); warningSet.UnionWith(pidAndHlaSet.WarningSet); ExpansionCollection expansionCollectionOrNull = linkdis.ExpandOrNullIfTooMany(pidAndHlaSet); if (null == expansionCollectionOrNull) { phasedTextWriter.WriteLine(pidAndHlaSet.Pid + "\t" + PhasedExpansion.TooManyCombinationsMessage()); unphasedTextWriter.WriteLine(pidAndHlaSet.Pid + "\t" + UnphasedExpansion.TooManyCombinationsMessage()); warningSet.Add(string.Format("Error: Too many combinations, case {0} skipped", pidAndHlaSet.Pid)); outputLineIndex += 2; if (outputLineIndex > outputLineLimit) { goto TOOMANYLINES; } } else { foreach (PhasedExpansion phasedExpansion in expansionCollectionOrNull.Phased()) { string phasedLine = pidAndHlaSet.Pid + "\t" + phasedExpansion.ToString(); phasedTextWriter.WriteLine(phasedLine); if (phasedExpansion.BadHlaNameOrNull != null) { warningSet.Add(phasedLine); } ++outputLineIndex; if (outputLineIndex > outputLineLimit) { goto TOOMANYLINES; } } foreach (UnphasedExpansion unphasedExpansion in expansionCollectionOrNull.Unphased()) { string unphasedLine = pidAndHlaSet.Pid + "\t" + unphasedExpansion.ToString(); unphasedTextWriter.WriteLine(unphasedLine); if (unphasedExpansion.BadHlaNameOrNull != null) { warningSet.Add(unphasedLine); } ++outputLineIndex; if (outputLineIndex > outputLineLimit) { goto TOOMANYLINES; } } } } } goto INANYCASE; TOOMANYLINES: string tooManyLinesMessage = string.Format("ERROR: The line limit of {0} was reached and output was ended early", outputLineLimit); phasedTextWriter.WriteLine(tooManyLinesMessage); unphasedTextWriter.WriteLine(tooManyLinesMessage); warningSet.Add(tooManyLinesMessage); INANYCASE: Console.Error.WriteLine(warningSet.StringJoin("\n")); } } catch (Exception exception) { Console.WriteLine(exception.Message); if (exception.InnerException != null) { Console.WriteLine(exception.InnerException.Message); } Console.Error.WriteLine(@" USAGE HlaCompletion -ethnicity ETHNICITY [-outputLineLimit 100000] [-sparse] [-combinationLimit 10000] inputFile phaseFile unphaseFile where ETHNICITY is {0} 'outputLineLimit' limits the total lines of output. If it is reached, a warning message is written as the last line of the output. 'combinationLimit' limits the number of combinations of HLAs consider in one phase for one case. It is is reached, an error message is output for that case in place of results. '-sparse' reads files in sparse format ", Linkdis.EthnicityNameMixedList().StringJoin(", ")); System.Environment.Exit(-1); } }
static void Main(string[] args) { try { ArgCollection argCollection = ArgCollection.GetInstance(args); if (argCollection.ExtractOptionalFlag("help")) { Console.WriteLine(""); Console.WriteLine(UsageMessage); Console.WriteLine(HelpMessage); return; } string keepTestName = argCollection.ExtractOptional <string>("keepTest", "AlwaysKeep"); string skipRowIndexFileNameOrNull = argCollection.ExtractOptional <string>("skipRowIndexFile", null); string optimizerName = argCollection.ExtractOptional <string>("optimizer", "BrentThenGrid"); string clusterName = argCollection.ExtractOptional <string>("cluster", null); string internalRemoteDirectoryName = argCollection.ExtractOptional <string>("internalRemoteDirectory", null); argCollection.CheckNoMoreOptions(); string externalRemoteDirectoryName = argCollection.ExtractNext <string>("externalRemoteDirectory"); if (null == internalRemoteDirectoryName) { internalRemoteDirectoryName = externalRemoteDirectoryName; } int pieceCount = argCollection.ExtractNext <int>("pieceCount"); int taskPerJobCount = argCollection.ExtractNext <int>("taskPerJobCount"); string treeFileName = argCollection.ExtractNext <string>("treeFile"); string predictorFileName = argCollection.ExtractNext <string>("predictorFile"); string targetFileName = argCollection.ExtractNext <string>("targetFile"); string leafDistributionName = argCollection.ExtractNext <string>("leafDistribution"); string nullDataGeneratorName = argCollection.ExtractNext <string>("nullDataGenerator"); string niceName = argCollection.ExtractNext <string>("niceName"); RangeCollection nullIndexRangeCollection = argCollection.ExtractNext <RangeCollection>("nullIndexRange"); argCollection.CheckThatEmpty(); if (null == clusterName) { clusterName = CCSLib.CCSLib.GetMachineNameFromUNCName(externalRemoteDirectoryName); } string exeNewRelativeDirectoryName = CCSLib.CCSLib.CopyExesToCluster(externalRemoteDirectoryName, niceName); string id = null; string password = null; CreateTasks(externalRemoteDirectoryName, internalRemoteDirectoryName, pieceCount, taskPerJobCount, treeFileName, predictorFileName, targetFileName, leafDistributionName, nullDataGeneratorName, keepTestName, skipRowIndexFileNameOrNull, niceName, nullIndexRangeCollection, exeNewRelativeDirectoryName, clusterName, id, password, optimizerName); } catch (Exception exception) { Console.WriteLine(""); Console.WriteLine(exception.Message); if (exception.InnerException != null) { Console.WriteLine(exception.InnerException.Message); } Console.WriteLine(""); Console.WriteLine(UsageMessage); throw; } }
static void Main(string[] args) { try { // before using the ArgCollection class, let the DigipedeClient grab its args. DigipedeClient client = new DigipedeClient(); args = client.ProcessArguments(args, true); ArgCollection argCollection = ArgCollection.GetInstance(args); // show help, if requested if (argCollection.ExtractOptionalFlag("help")) { Console.WriteLine(""); Console.WriteLine(UsageMessage); Console.WriteLine(HelpMessage); return; } // fail if the DigipedeClient doesn't have the args SpecialFunctions.CheckCondition(client.IsInitialized, "Digipede Client didn't initialize."); string keepTestName = argCollection.ExtractOptional("keepTest", "AlwaysKeep"); string skipRowIndexFileNameOrNull = argCollection.ExtractOptional <string>("skipRowIndexFile", null); string optimizerName = argCollection.ExtractOptional("optimizer", "BrentThenGrid"); argCollection.CheckNoMoreOptions(); int pieceCount = argCollection.ExtractNext <int>("pieceCount"); //int taskPerJobCount = argCollection.ExtractNext<int>("taskPerJobCount"); -- we're not using this -- keep it in case we want to put it back string treeFileName = argCollection.ExtractNext <string>("treeFile"); string predictorFileName = argCollection.ExtractNext <string>("predictorFile"); string targetFileName = argCollection.ExtractNext <string>("targetFile"); string leafDistributionName = argCollection.ExtractNext <string>("leafDistribution"); string nullDataGeneratorName = argCollection.ExtractNext <string>("nullDataGenerator"); string niceName = argCollection.ExtractNext <string>("niceName"); string outputDirectoryName = argCollection.ExtractNext <string>("outputDirectory"); RangeCollection nullIndexRangeCollection = argCollection.ExtractNext <RangeCollection>("nullIndexRange"); SpecialFunctions.CheckCondition(nullIndexRangeCollection.IsBetween(-1, int.MaxValue), "nullIndex must be at least -1"); argCollection.CheckThatEmpty(); Directory.CreateDirectory(outputDirectoryName); // Define a JobTemplate for PhyloD. JobTemplate jobTemplate = CreateJobTemplate(); // Require 32 bit (ensures we use WOW64 on 64-bit machines) since SpecialFunctions.dll built for x86. jobTemplate.Control.UseWow64On64Bit = true; // allow task failures (all but one failure will result in job success) jobTemplate.JobDefaults.MaxFailures = pieceCount - 1; // allow multiple concurrent tasks (one for each core); each isolated in its own process. jobTemplate.Control.Concurrency = ApplicationConcurrency.MultiplePerCore; jobTemplate.Control.ProcessHostingOptions = HostingOptions.ManySingleUse; // create a Job based on that JobTemplate Job job = jobTemplate.NewJob(); // add job-specific data / files FileDefCollection fileDefs = job.FileDefs; // files Utility.GetNamedFileDef(fileDefs, Constants.TreeFileDefName).RemoteName = treeFileName; Utility.GetNamedFileDef(fileDefs, Constants.PredictorFileDefName).RemoteName = predictorFileName; Utility.GetNamedFileDef(fileDefs, Constants.TargetFileDefName).RemoteName = targetFileName; // skipRowIndex file is more complicated because it may not exist, but the JobTemplate requires it. FileDef fileDef = Utility.GetNamedFileDef(fileDefs, Constants.SkipRowIndexFileDefName); if (skipRowIndexFileNameOrNull == null || skipRowIndexFileNameOrNull == "null") { // stream an empty file fileDef.Stream = new MemoryStream(0); } else { // stream the actual file fileDef.LocalName = skipRowIndexFileNameOrNull; } // Create the tasks for the template for (int pieceIndex = 0; pieceIndex < pieceCount; pieceIndex++) { // Create a Task for this piece Task task = job.NewTask(); // Create an InputData object to encapsulate all input data in one place InputData inputData = new InputData(optimizerName, keepTestName, leafDistributionName, nullDataGeneratorName, niceName, outputDirectoryName, pieceIndex, pieceCount, nullIndexRangeCollection.ToString()); // create a Worker for this task task.Worker = new PhyloDWorker(inputData); } // Wire events to catch result data. Note that retrieving data isn't necessary here -- // data can be requested in a server call from another process. job.TaskCompleted += job_TaskCompleted; // Write an event to catch any monitoring errors client.MonitoringError += client_MonitoringError; // submit the job SubmissionResult sr = client.SubmitJob(jobTemplate, job); Console.WriteLine("Submitted job {0} with {1} tasks.", sr.JobId, job.Tasks.Count); // wait for the result JobStatusSummary jss = client.WaitForJobWithStatus(sr.JobId); Console.WriteLine("Job finished with status of {0}", jss.Status); } catch (Exception exception) { Console.WriteLine(""); Console.WriteLine(exception.Message); if (exception.InnerException != null) { Console.WriteLine(exception.InnerException.Message); } Console.WriteLine(""); Console.WriteLine(UsageMessage); throw; } }
static void Main(string[] args) { try { ArgCollection argCollection = ArgCollection.GetInstance(args); if (argCollection.ExtractOptionalFlag("help")) { Console.WriteLine(""); Console.WriteLine(UsageMessage); Console.WriteLine(HelpMessage); return; } string clusterName = argCollection.ExtractOptional <string>("cluster", null); string specFileNameOrNull = argCollection.ExtractOptional <string>("specFile", null); string internalRemoteDirectoryName = argCollection.ExtractOptional <string>("internalRemoteDirectory", null); SpecialFunctions.CheckCondition(specFileNameOrNull == null || internalRemoteDirectoryName == null, "specFile and internalRemoteDirectory should not both be given"); argCollection.CheckNoMoreOptions(); string externalRemoteDirectoryName = argCollection.ExtractNext <string>("externalRemoteDirectory"); SpecialFunctions.CheckCondition(specFileNameOrNull == null || externalRemoteDirectoryName == "null", "When the specFile is given externalRemoteDirectory should be 'null'"); if (null == internalRemoteDirectoryName) { internalRemoteDirectoryName = externalRemoteDirectoryName; } int pieceCount = argCollection.ExtractNext <int>("pieceCount"); int taskPerJobCount = argCollection.ExtractNext <int>("taskPerJobCount"); //!!!much like HlaAssign's main double?leakProbabilityOrNull = argCollection.ExtractNext <double?>("leakProbabilityOrNull"); double pValue = argCollection.ExtractNext <double>("pValue"); string inputDirectoryName = argCollection.ExtractNext <string>("inputDirectory"); SpecialFunctions.CheckCondition(specFileNameOrNull == null || inputDirectoryName == "null", "When the specFile is given inputDirectory should be 'null'"); string caseName = argCollection.ExtractNext <string>("caseName"); SpecialFunctions.CheckCondition(specFileNameOrNull == null || caseName == "null", "When the specFile is given caseName should be 'null'"); string hlaFactoryName = argCollection.ExtractNext <string>("hlaFactory"); RangeCollection nullIndexRangeCollection = argCollection.ExtractNext <RangeCollection>("nullIndexRange"); argCollection.CheckThatEmpty(); ICluster cluster = new Cluster(); SpecialFunctions.CheckCondition(specFileNameOrNull == null || clusterName != null, "When the specFile is given, the clusterName must be given explicitly"); if (null == clusterName) { clusterName = CCSLib.CCSLib.GetMachineNameFromUNCName(externalRemoteDirectoryName); } cluster.Connect(clusterName); string id = null; string password = null; Queue <ITask> taskQueue = new Queue <ITask>(); if (null == specFileNameOrNull) { FillQueueBySplitingPeptideList(pieceCount, leakProbabilityOrNull, pValue, caseName, hlaFactoryName, nullIndexRangeCollection, internalRemoteDirectoryName, externalRemoteDirectoryName, inputDirectoryName, taskQueue); } else { FillQueueBySplitingDirNameLists(pieceCount, leakProbabilityOrNull, pValue, hlaFactoryName, nullIndexRangeCollection, specFileNameOrNull, taskQueue, ref caseName); } SubmitQueue(taskPerJobCount, caseName, nullIndexRangeCollection, cluster, id, password, taskQueue); //Console.WriteLine("\nPress enter to exit..."); //Console.ReadLine(); } catch (Exception exception) { Console.WriteLine(""); Console.WriteLine(exception.Message); if (exception.InnerException != null) { Console.WriteLine(exception.InnerException.Message); } Console.WriteLine(""); Console.WriteLine(UsageMessage); throw; } }
static void Main(string[] args) { try { ArgCollection argCollection = ArgCollection.GetInstance(args); if (argCollection.ExtractOptionalFlag("help")) { Console.WriteLine(""); Console.WriteLine(UsageMessage); Console.WriteLine(HelpMessage); return; } string optimizerName = argCollection.ExtractOptional <string>("optimizer", "BrentThenGrid"); string keepTestName = argCollection.ExtractOptional <string>("keepTest", "AlwaysKeep"); string skipRowIndexFileNameOrNull = argCollection.ExtractOptional <string>("skipRowIndexFile", null); argCollection.CheckNoMoreOptions(); string treeFileName = argCollection.ExtractNext <string>("treeFile"); string predictorFileName = argCollection.ExtractNext <string>("predictorFile"); string targetFileName = argCollection.ExtractNext <string>("targetFile"); string leafDistributionName = argCollection.ExtractNext <string>("leafDistribution"); string nullDataGeneratorName = argCollection.ExtractNext <string>("nullDataGenerator"); string niceName = argCollection.ExtractNext <string>("niceName"); string outputDirectory = argCollection.ExtractNext <string>("outputDirectory"); RangeCollection pieceIndexRangeCollection = argCollection.ExtractNext <RangeCollection>("pieceIndexRange"); int pieceCount = argCollection.ExtractNext <int>("pieceCount"); RangeCollection nullIndexRangeCollection = argCollection.ExtractNext <RangeCollection>("nullIndexRange"); argCollection.CheckThatEmpty(); if (!PhyloDDriver.ValidateDistribution(leafDistributionName)) { Console.WriteLine("{0} is not a recognized distribution name. Please choose a name from the following list:", leafDistributionName); foreach (string name in PhyloDDriver.GetDistributionNames()) { Console.WriteLine("\t{0}", name); } throw new ArgumentException("Invalid distribution name."); } RangeCollection skipRowIndexRangeCollectionOrNull = (null == skipRowIndexFileNameOrNull) || skipRowIndexFileNameOrNull == "null" ? null : RangeCollection.Parse(File.ReadAllText(skipRowIndexFileNameOrNull)); KeepTest <Dictionary <string, string> > keepTest = KeepTest <Dictionary <string, string> > .GetInstance(null, keepTestName); SpecialFunctions.CheckCondition(pieceIndexRangeCollection.IsBetween(0, pieceCount - 1), "pieceIndex must be at least 0 and less than pieceCount"); SpecialFunctions.CheckCondition(nullIndexRangeCollection.IsBetween(-1, int.MaxValue), "nullIndex must be at least -1"); PhyloTree aPhyloTree = PhyloTree.GetInstance(treeFileName, null); ModelScorer modelScorer = ModelScorer.GetInstance(aPhyloTree, leafDistributionName, optimizerName); ModelEvaluator modelEvaluator = ModelEvaluator.GetInstance(leafDistributionName, modelScorer); PhyloDDriver driver = PhyloDDriver.GetInstance(); driver.Run( modelEvaluator, predictorFileName, targetFileName, leafDistributionName, nullDataGeneratorName, keepTest, skipRowIndexRangeCollectionOrNull, niceName, outputDirectory, pieceIndexRangeCollection, pieceCount, nullIndexRangeCollection, optimizerName); //Console.Write("Press enter to exist."); //Console.Read(); } catch (Exception exception) { Console.WriteLine(""); Console.WriteLine(exception.Message); if (exception.InnerException != null) { Console.WriteLine(exception.InnerException.Message); } Console.WriteLine(""); Console.WriteLine(UsageMessage); throw; } }