-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathplot.go
61 lines (52 loc) · 1.14 KB
/
plot.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
/*
* Filename: /Users/bao/code/allhic/plot.go
* Path: /Users/bao/code/allhic
* Created Date: Saturday, July 7th 2018, 1:33:37 pm
* Author: bao
*
* Copyright (c) 2018 Haibao Tang
*/
package allhic
import (
"net/http"
"os"
"strconv"
"github.com/gobuffalo/packr"
)
// Plotter extracts a matrix of link counts and plot a heatmap
type Plotter struct {
Anchor *Anchorer
}
// Run starts the plotting
func (r *Plotter) Run() {
m := r.Anchor
m.ExtractInterContigLinks()
m.parseTourFile(m.Tourfile)
m.printTour(os.Stdout, "PLOTTER")
// 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")
s, _ := box.FindString("index.html")
_, _ = f.WriteString(s)
_ = 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
}
}
_ = f.Close()
}