Skip to content

Commit

Permalink
[wip] go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleam committed Aug 13, 2024
1 parent 2ab232d commit ece648f
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 36 deletions.
14 changes: 7 additions & 7 deletions cmd/sge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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)

Expand All @@ -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)
//
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions parsers/nmparser/diagonal_elements.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions parsers/nmparser/parse_initial_estimates_test.go
Original file line number Diff line number Diff line change
@@ -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:",
Expand Down
4 changes: 2 additions & 2 deletions parsers/nmparser/read_ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion parsers/nmparser/read_grd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion runner/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion runner/estimate_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion runner/estimate_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion runner/prepare_to_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion runner/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion utils/expand_sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`(.*)?\[(.*)](.*)?`)
Expand Down
11 changes: 5 additions & 6 deletions utils/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit ece648f

Please sign in to comment.