From ece648fc3466ae90327f80b9c414f426e73a2884 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 13 Aug 2024 10:44:41 -0400 Subject: [PATCH] [wip] go fmt --- cmd/sge.go | 14 ++++++------- parsers/nmparser/diagonal_elements.go | 12 ++++++----- .../nmparser/parse_initial_estimates_test.go | 20 ++++++++++--------- parsers/nmparser/read_ext.go | 4 ++-- parsers/nmparser/read_grd.go | 2 +- runner/consts.go | 2 +- runner/estimate_model.go | 3 ++- runner/estimate_model_test.go | 2 +- runner/prepare_to_execute.go | 2 +- runner/structs.go | 2 +- utils/expand_sequence.go | 3 ++- utils/io.go | 11 +++++----- 12 files changed, 41 insertions(+), 36 deletions(-) diff --git a/cmd/sge.go b/cmd/sge.go index 68755b32..9ac1b9af 100644 --- a/cmd/sge.go +++ b/cmd/sge.go @@ -30,7 +30,7 @@ type sgeOperation struct { Models []SGEModel `json:"models"` } -//SGEModel is the struct used for SGE operations containing the NonMemModel. +// SGEModel is the struct used for SGE operations containing the NonMemModel. type SGEModel struct { Nonmem *NonMemModel Cancel chan bool @@ -66,12 +66,12 @@ func (s *SGEModel) GetWorkingPath() string { return s.Nonmem.OutputDir } -//Begin Scalable method definitions. +// Begin Scalable method definitions. func (l SGEModel) CancellationChannel() chan bool { return l.Cancel } -//Prepare is basically the old EstimateModel function. Responsible for creating directories and preparation. +// Prepare is basically the old EstimateModel function. Responsible for creating directories and preparation. func (l SGEModel) Prepare(channels *turnstile.ChannelMap) { log.Debugf("%s Beginning Prepare phase of SGE Work", l.Nonmem.LogIdentifier()) @@ -122,7 +122,7 @@ func (l SGEModel) Prepare(channels *turnstile.ChannelMap) { } } -//Work describes the Turnstile execution phase -> IE What heavy lifting should be done. +// Work describes the Turnstile execution phase -> IE What heavy lifting should be done. func (l SGEModel) Work(channels *turnstile.ChannelMap) { cerr := executeNonMemJob(executeSGEJob, l.Nonmem) @@ -139,12 +139,12 @@ func (l SGEModel) Work(channels *turnstile.ChannelMap) { channels.Completed <- 1 } -//Monitor is the 3rd phase of turnstile (not implemented here). +// Monitor is the 3rd phase of turnstile (not implemented here). func (l SGEModel) Monitor(_ *turnstile.ChannelMap) { //Do nothing for this implementation } -//Cleanup is the last phase of execution, in which computation / hard work is done and we're cleaning up leftover files, copying results around et all. +// Cleanup is the last phase of execution, in which computation / hard work is done and we're cleaning up leftover files, copying results around et all. func (l SGEModel) Cleanup(_ *turnstile.ChannelMap) { //err := configlib.WriteViperConfig(l.Nonmem.OutputDir, true) // @@ -352,7 +352,7 @@ func sgeModelsFromArguments(args []string, config configlib.Config) ([]SGEModel, return output, nil } -//Generate the command line script to execute bbi on the grid. +// Generate the command line script to execute bbi on the grid. func generateBbiScript(fileTemplate string, l NonMemModel) ([]byte, error) { t, err := template.New("file").Parse(fileTemplate) buf := new(bytes.Buffer) diff --git a/parsers/nmparser/diagonal_elements.go b/parsers/nmparser/diagonal_elements.go index c92455d4..b703dd35 100644 --- a/parsers/nmparser/diagonal_elements.go +++ b/parsers/nmparser/diagonal_elements.go @@ -7,18 +7,20 @@ import ( // lowerDiagonalLengthToDimension takes l which is // the number of total elements in the lower diagonal -// matrix, and calculates the dimension (aka number of +// matrix, and calculates the dimension (aka number of // diagonal elements) for the matrix. // Additionally, this function can be used to pass // a specific index from the array of lower diagonal // elements (as l). In that case, it will return one // of the following: // * If the index is a diagonal element: -// * The number of that diagonal element -// * true +// - The number of that diagonal element +// - true +// // * If the index is not a diagonal element: -// * 0 -// * false +// - 0 +// - false +// // For example, there are 6 elements in the lower // diagonal of a 3x3 matrix, the 1st, 3rd, and 6th // being diagonals. Calling this function on 1-6 diff --git a/parsers/nmparser/parse_initial_estimates_test.go b/parsers/nmparser/parse_initial_estimates_test.go index 7f214113..8b6c0507 100644 --- a/parsers/nmparser/parse_initial_estimates_test.go +++ b/parsers/nmparser/parse_initial_estimates_test.go @@ -1,15 +1,17 @@ package parser // example omega initial estimates given complex omega structure -// IOV = EXP(ETA(3)) -// IF(VISI.EQ.6) IOV=EXP(ETA(4)) -// IF(VISI.EQ.8) IOV=EXP(ETA(5)) -// $OMEGA 0.14 ; 1 IIV BASE -// $OMEGA 0.8 ; 2 IIV EC50 -// $OMEGA BLOCK(1) -// 0.03 ; 1 IOV BASE -// $OMEGA BLOCK(1) SAME -// $OMEGA BLOCK(1) SAME. +// +// IOV = EXP(ETA(3)) +// IF(VISI.EQ.6) IOV=EXP(ETA(4)) +// IF(VISI.EQ.8) IOV=EXP(ETA(5)) +// $OMEGA 0.14 ; 1 IIV BASE +// $OMEGA 0.8 ; 2 IIV EC50 +// $OMEGA BLOCK(1) +// 0.03 ; 1 IOV BASE +// $OMEGA BLOCK(1) SAME +// $OMEGA BLOCK(1) SAME +// // TODO: remove omegaBlock01 if we find no use. var _ = /*omegaBlock01*/ []string{ "0INITIAL ESTIMATE OF OMEGA:", diff --git a/parsers/nmparser/read_ext.go b/parsers/nmparser/read_ext.go index ff0e5812..310a1e28 100644 --- a/parsers/nmparser/read_ext.go +++ b/parsers/nmparser/read_ext.go @@ -40,7 +40,7 @@ func ParseExtLines(lines []string) ExtData { } } -//ParseParamsExt returns the ExtData in the structure of final parameter estimates +// ParseParamsExt returns the ExtData in the structure of final parameter estimates // the parameter names correspond to the names per the ext file (THETA1, THETA2, etc) // per nonmem 7.4 the following information will be grabbed // 1) Theburn-in iterations of the MCMCBayesian analysis are given negative values,starting at –NBURN, the number of burn-in iterations requested by the user. These are followed by positive iterations of the stationary phase. @@ -149,7 +149,7 @@ func ParseParamsExt(ed ExtData) ([]ParametersData, ParameterNames) { } } -//ParseConditionNumberExt returns the condition number for each estimation method from ExtData +// ParseConditionNumberExt returns the condition number for each estimation method from ExtData // per nonmem 7.4 the following information will be grabbed // Iteration -1000000003 indicates that this line contains the condition number , lowest, highest, Eigenvalues of the correlation matrix of the variances of the final parameters. // NONMEM Users Guide: Introduction to NONMEM 7.4.1. diff --git a/parsers/nmparser/read_grd.go b/parsers/nmparser/read_grd.go index 14efdc1c..db8174aa 100644 --- a/parsers/nmparser/read_grd.go +++ b/parsers/nmparser/read_grd.go @@ -39,7 +39,7 @@ func ParseGrdLines(lines []string) ExtData { } } -//ParseGrdData returns the ExtData in the structure of final parameter estimates. +// ParseGrdData returns the ExtData in the structure of final parameter estimates. func ParseGrdData(ed ExtData) ([]ParametersData, ParameterNames) { var allParametersData []ParametersData var thetas []string diff --git a/runner/consts.go b/runner/consts.go index 166690bc..a1c0271d 100644 --- a/runner/consts.go +++ b/runner/consts.go @@ -82,7 +82,7 @@ func EstOutputFileCleanLevels(r string) map[string]int { return EstOutputFiles } -//CleanFilesByRun sets clean levels for files by run. +// CleanFilesByRun sets clean levels for files by run. func CleanFilesByRun(r string) map[string]int { var EstOutputFiles = make(map[string]int) // fileExtLvls are based on 1 = lowest priority -> n = highest priority diff --git a/runner/estimate_model.go b/runner/estimate_model.go index 34bbf518..1c99844a 100644 --- a/runner/estimate_model.go +++ b/runner/estimate_model.go @@ -17,7 +17,8 @@ import ( // EstimateModel prepares, runs and cleans up a model estimation run // modelPath is the relative path of the model from where Estimate model is called from // cacheDir is the location of the cache dir, relative to the baseDir, -// for nonmem executable for version 7.4 for use in precompilation +// for nonmem executable for version 7.4 for use in precompilation +// // exeNameInCache is the name of the nonmem executable in the cache dir. func EstimateModel( fs afero.Fs, diff --git a/runner/estimate_model_test.go b/runner/estimate_model_test.go index 36d6ab2c..ea912e6e 100644 --- a/runner/estimate_model_test.go +++ b/runner/estimate_model_test.go @@ -40,7 +40,7 @@ func TestCustomEstimateModel(tt *testing.T) { }) } -//Should just get back the provided output dir. +// Should just get back the provided output dir. func TestLogiclessTemplateForEstimateModel(tt *testing.T) { testId := "UNIT-RUN-005" tt.Run(utils.AddTestId("", testId), func(tt *testing.T) { diff --git a/runner/prepare_to_execute.go b/runner/prepare_to_execute.go index 127e3fb2..e5141f1d 100644 --- a/runner/prepare_to_execute.go +++ b/runner/prepare_to_execute.go @@ -6,7 +6,7 @@ import ( parser "github.com/metrumresearchgroup/bbi/parsers/nmparser" ) -//PrepareForExecution parses and prepares strings from a file for execution in a different context +// PrepareForExecution parses and prepares strings from a file for execution in a different context // for example, replacing the $DATA path. func PrepareForExecution(s []string) []string { for i, line := range s { diff --git a/runner/structs.go b/runner/structs.go index e76229ed..794ab47d 100644 --- a/runner/structs.go +++ b/runner/structs.go @@ -24,7 +24,7 @@ type ReturnStatus struct { Error error `json:"error,omitempty"` } -//NextDirSuggestion provides a struct for the recommended next +// NextDirSuggestion provides a struct for the recommended next // directory name, and whether there should be a project reorganization // based on directory modifications, and whether this will be the first dir in the sequence. type NextDirSuggestion struct { diff --git a/utils/expand_sequence.go b/utils/expand_sequence.go index 1c2fce4f..f11d6529 100644 --- a/utils/expand_sequence.go +++ b/utils/expand_sequence.go @@ -8,7 +8,8 @@ import ( ) // ExpandNameSequence takes a full name pattern with a sequence and returns all values -// run[001:004].mod --> run001.mod run002.mod run003.mod run004.mod +// +// run[001:004].mod --> run001.mod run002.mod run003.mod run004.mod func ExpandNameSequence(fnp string) ([]string, error) { var output []string r := regexp.MustCompile(`(.*)?\[(.*)](.*)?`) diff --git a/utils/io.go b/utils/io.go index da8e2e17..619e193b 100644 --- a/utils/io.go +++ b/utils/io.go @@ -11,9 +11,8 @@ import ( "github.com/spf13/afero" ) -//ReadParamsAndOutputFromExt returns the lines associated +// ReadParamsAndOutputFromExt returns the lines associated // with either parameter table outputs or output lines (-100xxx lines). -// func ReadParamsAndOutputFromExt(path string) ([]string, error) { inFile, err := os.Open(path) if err != nil { @@ -61,7 +60,7 @@ func ReadParamsAndOutputFromExt(path string) ([]string, error) { return lines, nil } -//ReadLines reads lines for a file at a given path. +// ReadLines reads lines for a file at a given path. func ReadLines(path string) ([]string, error) { inFile, err := os.Open(path) if err != nil { @@ -78,7 +77,7 @@ func ReadLines(path string) ([]string, error) { return lines, nil } -//ReadLinesFS reads lines for a file at a given path. +// ReadLinesFS reads lines for a file at a given path. func ReadLinesFS(fs afero.Fs, path string) ([]string, error) { inFile, err := fs.Open(path) if err != nil { @@ -95,7 +94,7 @@ func ReadLinesFS(fs afero.Fs, path string) ([]string, error) { return lines, nil } -//WriteLines writes lines to a file at a given path given a filesystem. +// WriteLines writes lines to a file at a given path given a filesystem. func WriteLines(lines []string, path string) error { file, err := os.Create(path) if err != nil { @@ -111,7 +110,7 @@ func WriteLines(lines []string, path string) error { return w.Flush() } -//WriteLinesFS writes lines to a file at a given path given a filesystem. +// WriteLinesFS writes lines to a file at a given path given a filesystem. func WriteLinesFS(fs afero.Fs, lines []string, path string) error { file, err := fs.Create(path) if err != nil {