Skip to content

Commit

Permalink
[plot] Use packr to distribution html
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Jul 19, 2018
1 parent b8e5e26 commit e6c66e9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@

package allhic

import "os"
import (
"net/http"
"os"
"strconv"

"github.com/gobuffalo/packr"
)

// Plotter extracts a matrix of link counts and plot a heatmp
type Plotter struct {
Expand All @@ -25,7 +31,30 @@ func (r *Plotter) Run() {
// Serialize to disk for plotting
m.makeContigStarts()
m.serialize(250000, "genome.json", "data.npy")
r.host()

// printPaths(paths)
log.Notice("Success")
}

// Host plot.html
func (r *Plotter) host() {
box := packr.NewBox("./templates")
port := 3000
f, _ := os.Create("index.html")
defer f.Close()
f.WriteString(box.String("index.html"))
f.Sync()

http.Handle("/", http.FileServer(http.Dir(".")))

for {
log.Noticef("Serving on localhost:%d ...", port)
if err := http.ListenAndServe(":"+strconv.Itoa(port), nil); err != nil {
log.Debug(err)
port++
} else {
break
}
}
}
File renamed without changes.

0 comments on commit e6c66e9

Please sign in to comment.