Skip to content

Commit

Permalink
adding direct Uniprot Accession search capability
Browse files Browse the repository at this point in the history
For example:

    $ ./lollipops -U Q9D2P8
    Pfam Symbol:  MOBP_MOUSE
    Drawing diagram to MOBP_MOUSE.svg
  • Loading branch information
pbnjay committed Sep 30, 2014
1 parent b40ff8d commit a367c09
Showing 1 changed file with 41 additions and 18 deletions.
59 changes: 41 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
)

var (
output = flag.String("o", "", "output SVG file (default GENE_SYMBOL.svg)")
width = flag.Int("w", 0, "SVG output width (default automatic fit labels)")
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)")
)

func main() {
Expand All @@ -18,36 +19,58 @@ func main() {
flag.PrintDefaults()
}
flag.Parse()
if flag.NArg() == 0 {
flag.Usage()
os.Exit(1)
}
if *output == "" {
*output = flag.Arg(0) + ".svg"

var err error
acc := ""
geneSymbol := ""
if *uniprot == "" && flag.NArg() > 0 {
geneSymbol = flag.Arg(0)

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)
}

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)
if *uniprot != "" {
acc = *uniprot
}
defer f.Close()

fmt.Fprintln(os.Stderr, "HGNC Symbol: ", flag.Arg(0))
varStart := 1
if flag.NArg() == 0 {
varStart = 0
if *uniprot == "" {
flag.Usage()
os.Exit(1)
}
}

acc, err := GetProtID(flag.Arg(0))
data, err := GetPfamGraphicData(acc)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Fprintln(os.Stderr, "Uniprot/SwissProt Accession: ", acc)
if geneSymbol == "" {
geneSymbol = data.Metadata.Identifier
fmt.Fprintln(os.Stderr, "Pfam Symbol: ", geneSymbol)
}

data, err := GetPfamGraphicData(acc)
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()[1:], data)
DrawSVG(f, *width, flag.Args()[varStart:], data)
}

0 comments on commit a367c09

Please sign in to comment.