-
Notifications
You must be signed in to change notification settings - Fork 6
/
sortGraph.go
44 lines (34 loc) · 884 Bytes
/
sortGraph.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Command Group: "Sorting"
// Topologically sorts nodes in a genome graph (.gg) file
package main
import (
"flag"
"fmt"
"log"
"github.com/vertgenlab/gonomics/genomeGraph"
)
func usage() {
fmt.Print(
"sortGraph - Topologically sorts nodes in a genome graph (.gg) file. \n" +
"Usage:\n" +
" sortGraph input.gg output.gg\n")
flag.PrintDefaults()
}
func sortGraph(inFile string, outFile string) {
graph := genomeGraph.Read(inFile)
graph = genomeGraph.SortGraph(graph)
genomeGraph.Write(outFile, graph)
}
func main() {
expectedNumArgs := 2
flag.Usage = usage
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
flag.Parse()
if len(flag.Args()) != expectedNumArgs {
flag.Usage()
log.Fatalf("ERROR: expecting %d arguments, but got %d\n", expectedNumArgs, len(flag.Args()))
}
inFile := flag.Arg(0)
outFile := flag.Arg(1)
sortGraph(inFile, outFile)
}