forked from joiningdata/lollipops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
81 lines (67 loc) · 1.79 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"flag"
"fmt"
"os"
"os/exec"
)
var (
uniprot = flag.String("U", "", "Uniprot accession instead of GENE_SYMBOL")
output = flag.String("o", "", "output SVG file (default GENE_SYMBOL.svg)")
width = flag.Int("w", 0, "SVG output width (default automatic fit labels)")
maf = flag.Int("m", 0, "adds maf frequencies to plot and varies height by rarity if you change it to 1") // new flag for maf
)
func main() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [options] GENE_SYMBOL [PROTEIN CHANGES ...]\n\n", os.Args[0])
fmt.Fprintln(os.Stderr, "Where options are:")
flag.PrintDefaults()
}
flag.Parse()
var err error
varStart := 0
acc := ""
geneSymbol := ""
out := []byte{0}
args := []string{flag.Arg(0)}
if *uniprot == "" && flag.NArg() > 0 {
cmd := "idconv.py"
out, err = exec.Command(cmd, args...).Output()
acc = string(out)
varStart = 1
fmt.Fprintln(os.Stderr, "HGNC Symbol: ", flag.Arg(0))
//acc, err = GetProtID(flag.Arg(0))
//if err != nil {
// fmt.Fprintln(os.Stderr, err)
// os.Exit(1)
//}
fmt.Fprintln(os.Stderr, "Uniprot/SwissProt Accession: ", acc)
}
if *uniprot != "" {
acc = *uniprot
}
if flag.NArg() == 0 && *uniprot == "" {
flag.Usage()
os.Exit(1)
}
data, err := GetPfamGraphicData(acc)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if geneSymbol == "" {
geneSymbol = data.Metadata.Identifier
fmt.Fprintln(os.Stderr, "Pfam Symbol: ", geneSymbol)
}
if *output == "" {
*output = geneSymbol + ".svg"
}
f, err := os.OpenFile(*output, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0644)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer f.Close()
fmt.Fprintln(os.Stderr, "Drawing diagram to", *output)
DrawSVG(f, *width, flag.Args()[varStart:], *maf, data) // added new field for maf
}