-
Notifications
You must be signed in to change notification settings - Fork 3
/
PoaGo.go
79 lines (63 loc) · 1.42 KB
/
PoaGo.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
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"runtime/pprof"
PoaGo "github.com/ArtRand/PoaGo/lib"
)
func check(ok error, msg string) {
if ok != nil {
panic(msg)
} else {
return
}
}
const (
VERSION = "NOTSET"
REVISION = "NOTSET"
)
func main() {
inFile := flag.String("f", "", "file location")
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file")
version := flag.Bool("version", false, "print the version and revision")
flag.Parse()
if *version {
fmt.Printf("Version: %s", VERSION)
fmt.Printf("Revision: %s", REVISION)
os.Exit(0)
}
fH, ok := os.Open(*inFile)
check(ok, fmt.Sprintf("Error opening file %v", *inFile))
defer fH.Close()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
fqr := PoaGo.FqReader{Reader: bufio.NewReader(fH)}
// get the first sequence
r, done := fqr.Iter()
// add it to the graph
g := PoaGo.PoaGraphConstruct()
_, _ = g.AddBaseSequence(r.Seq, r.Name, true)
aln := PoaGo.PairwiseAlignmentParametersConstruct(4.0, -2.0, -4.0, -2.0)
for {
r, done = fqr.Iter()
if done {
break
}
pA := PoaGo.AlignStringToGraph(g, aln, r.Seq, r.Name)
g.AddSequenceAlignment(pA)
}
seqNames, alnStrings := g.GenerateAlignmentStrings()
for i := 0; i < len(seqNames); i++ {
fmt.Printf("%-12s\t%-6s\n", seqNames[i], alnStrings[i])
}
return
}