Skip to content

Commit

Permalink
replacing version constants with function access
Browse files Browse the repository at this point in the history
  • Loading branch information
will-rowe committed Apr 24, 2020
1 parent ece19db commit 15a9998
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cmd/align.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func runSketch() {

// start the sketch sub command
start := time.Now()
log.Printf("i am groot (version %s)", version.VERSION)
log.Printf("i am groot (version %s)", version.GetVersion)
log.Printf("starting the sketch subcommand")

// check the supplied files and then log some stuff
Expand All @@ -91,8 +91,8 @@ func runSketch() {
log.Print("loading the index information...")
info := new(pipeline.Info)
misc.ErrorCheck(info.Load(*indexDir + "/groot.gg"))
if info.Version != version.VERSION {
misc.ErrorCheck(fmt.Errorf("the groot index was created with a different version of groot (you are currently using version %v)", version.VERSION))
if info.Version != version.GetVersion {
misc.ErrorCheck(fmt.Errorf("the groot index was created with a different version of groot (you are currently using version %v)", version.GetVersion))
}
log.Printf("\tk-mer size: %d\n", info.KmerSize)
log.Printf("\tsketch size: %d\n", info.SketchSize)
Expand Down
2 changes: 1 addition & 1 deletion cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var md5sums = map[string]string{
}

// dbUrl to download databases from
var dbURL = fmt.Sprintf("https://github.com/will-rowe/groot/raw/master/db/clustered-ARG-databases/%v/", version.VERSION)
var dbURL = fmt.Sprintf("https://github.com/will-rowe/groot/raw/master/db/clustered-ARG-databases/%v/", version.GetBaseVersion)

// the command line arguments
var (
Expand Down
4 changes: 2 additions & 2 deletions cmd/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func runIndex() {

// start the index sub command
start := time.Now()
log.Printf("i am groot (version %s)", version.VERSION)
log.Printf("i am groot (version %s)", version.GetVersion)
log.Printf("starting the index subcommand")

// check the supplied files and then log some stuff
Expand All @@ -92,7 +92,7 @@ func runIndex() {

// record the runtime information for the index sub command
info := &pipeline.Info{
Version: version.VERSION,
Version: version.GetVersion,
KmerSize: *kmerSize,
SketchSize: *sketchSize,
WindowSize: *windowSize,
Expand Down
2 changes: 1 addition & 1 deletion cmd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func runReport() {
logFH := misc.StartLogging(*logFile)
defer logFH.Close()
log.SetOutput(logFH)
log.Printf("i am groot (version %s)", version.VERSION)
log.Printf("i am groot (version %s)", version.GetVersion)
log.Printf("starting the report subcommand")
// check the supplied files and then log some stuff
log.Printf("checking parameters...")
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var versionCmd = &cobra.Command{
Short: "Prints current version number and exits",
Long: `Prints current version number and exits`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.VERSION)
fmt.Println(version.GetVersion)
},
}

Expand Down
2 changes: 1 addition & 1 deletion src/graph/graphio.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (GrootGraph *GrootGraph) SaveGraphAsGFA(fileName string, totalKmers int) (i
// a flag to prevent dumping graphs which had no reads map
graphUsed := false
t := time.Now()
stamp := fmt.Sprintf("variation graph created by groot (version %v) at: %v", version.VERSION, t.Format("Mon Jan _2 15:04:05 2006"))
stamp := fmt.Sprintf("variation graph created by groot (version %v) at: %v", version.GetVersion, t.Format("Mon Jan _2 15:04:05 2006"))
msg := fmt.Sprintf("this graph is approximately weighted using k-mer frequencies from projected read sketches (total k-mers projected across all graphs: %d)", totalKmers)
// create a GFA instance
newGFA := gfa.NewGFA()
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline/1_pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ TEST PARAMETERS
*/
var testParameters = &Info{
NumProc: 1,
Version: version.VERSION,
Version: version.GetVersion,
KmerSize: 31,
SketchSize: 30,
WindowSize: 100,
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline/boss.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (theBoss *theBoss) mapReads() error {
theBoss.alignments = make(chan *sam.Record, BUFFERSIZE)

// get program info for SAM header (unique ID, name, command, previous program ID, version)
programInfo := sam.NewProgram("1", "groot", "groot align", "", version.VERSION)
programInfo := sam.NewProgram("1", "groot", "groot align", "", version.GetVersion)

// get some readgroup information TODO: set this properly
rg, err := sam.NewReadGroup("readsID", "", "", "", "groot align", "illumina", "", "sampleID", "", "", time.Now(), 1000)
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline/haplotype.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (proc *HaplotypeParser) Run() {
log.Printf("\t- [%v (abundance: %.3f)]", path, abundances[i])
keptPaths = append(keptPaths, path)
}
g.GrootVersion = version.VERSION
g.GrootVersion = version.GetVersion
keptGraphs[g.GraphID] = g
}
proc.info.Store = keptGraphs
Expand Down
22 changes: 20 additions & 2 deletions src/version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
package version

// VERSION is the current GROOT software version
const VERSION = "1.0.1"
import "fmt"

// major is the major version number
const major = 1

// minor is the minor version number
const minor = 0

// patch is the patch version number
const patch = 1

// GetVersion returns the full version string for the current GROOT software
func GetVersion() string {
return fmt.Sprintf("%d.%d.%d", major, minor, patch)
}

// GetBaseVersion returns the major minor version string for the current GROOT software
func GetBaseVersion() string {
return fmt.Sprintf("%d.%d", major, minor)
}

0 comments on commit 15a9998

Please sign in to comment.