github.com/andrewrech/ih-abstract@v0.0.0-20210322142951-2fec1c8d0f38/cli.go (about) 1 package main 2 3 import ( 4 "flag" 5 "fmt" 6 "os" 7 ) 8 9 // flagVars contains variables set by command line flags. 10 type flags struct { 11 config *string 12 example *bool 13 noFilter *bool 14 old *string 15 sql *bool 16 } 17 18 // flags parses command line flags. 19 func flagParse() (f flags) { 20 config := flag.String("config", "", "Path to ih-abstract.yml SQL connection configuration file") 21 example := flag.Bool("print-config", false, "Print an example configuration file and exit") 22 noFilter := flag.Bool("no-filter", false, "Save input data to .csv and exit without Immune Health filtering") 23 old := flag.String("old", "", "Path to existing results.csv output data from last run (optional)") 24 sql := flag.Bool("sql", false, "Read input from Microsoft SQL database instead of Stdin") 25 26 flag.Parse() 27 28 f.config = config 29 f.example = example 30 f.noFilter = noFilter 31 f.old = old 32 f.sql = sql 33 34 return 35 } 36 37 // usage prints usage. 38 func usage() { 39 flag.Usage = func() { 40 fmt.Fprintf(os.Stderr, "\nSelect raw data for Immune Health report generation.\n") 41 fmt.Fprintf(os.Stderr, "\nUSAGE:\n\n") 42 fmt.Fprintf(os.Stderr, " < results-raw.csv | ih-abstract\n") 43 fmt.Fprintf(os.Stderr, "\nDEFAULTS:\n\n") 44 flag.PrintDefaults() 45 fmt.Fprintf(os.Stderr, ` 46 DETAILS: 47 48 ih-abstract streams input raw pathology results to the immune.health.report R package 49 for report generation and quality assurance. The input is .csv data or direct streaming 50 from a Microsoft SQL driver-compatible database. The output is filtered .csv/.txt files 51 for incremental new report generation and quality assurance. 52 53 Optionally, Immune Health filtering can be turned off to use ih-abstract as a general 54 method to retrieve arbitrary or incremental pathology results. 55 56 Quality assurance output consists of files containing 57 1) unique, and 58 2) new (never-before-seen) 59 Immune Health report results for manual review. 60 61 Dependencies are vendored and consist of the Go standard library and 62 a Go Microsoft SQL driver. 63 64 OUTPUT: 65 66 Output: 67 68 results.csv: all results 69 results-increment.csv: new results since last run 70 new-ids.txt: patient identifiers with new results since last run 71 72 Output for Immune Health report quality assurance: 73 74 pdl1.csv: potential PD-L1 reports 75 msi.csv: potential MSI reports 76 cpd.csv: potential CPD reports 77 wbc.csv: white blood cell counts 78 79 pdl1-unique-strings.txt: unique PD-L1 strings 80 pdl1-unique-strings-new.txt: unique PD-L1 strings, new vs. last run 81 msi-unique-strings.txt: unique MSI strings 82 msi-unique-strings-new.txt: unique MSI strings, new vs. last run 83 84 CONFIGURATION FILE: 85 86 See 'ih-abstract --print-config'. Paths searched by default: 87 88 $XDG_CONFIG_HOME/ih-abstract/ih-abstract.yml 89 $HOME/.ih-abstract.yml 90 ./ih-abstract.yml 91 92 93 TESTING: 94 95 go test 96 NOTE: some integration tests require restricted 97 PHI-containing data. Data is available within our 98 organization upon request. 99 100 NOTE: To test the live database connection, set 101 environment variable IH_ABSTRACT_TEST_CONFIG to 102 a test configuration file path. 103 Live database tests disabled by default. 104 105 BENCHMARKING: 106 107 go test -bench=. 108 NOTE: some benchmarks require restricted 109 organization VPN access. Access is available within our 110 organization upon request. These benchmarks are 111 disabled by default. 112 `) 113 } 114 }