示例#1
0
文件: memz.go 项目: abeconnelly/memz
func main() {

	g_normalize_flag = true

	if len(os.Args) < 3 {
		fmt.Fprintf(os.Stderr, "provide filenames\n")
		os.Exit(1)
	}

	fn0 := os.Args[1]
	fn1 := os.Args[2]

	s0, e := ioutil.ReadFile(fn0)
	if e != nil {
		panic(e)
	}
	s1, e := ioutil.ReadFile(fn1)
	if e != nil {
		panic(e)
	}

	for i := 0; i < 256; i++ {
		memz.Score['n'][i] = 0
		memz.Score[i]['n'] = 0
	}

	X, Y, sc := memz.Hirschberg(s0, s1)

	if g_normalize_flag {
		memz.SeqPairNormalize(X, Y)
	}

	//memz.Simp_b(s0,s1,0,0)

	fmt.Printf("%d\n%s\n%s\n", sc, X, Y)
}
示例#2
0
func (g *FastJInfo) EmitAlignedInterleave(ref, alt0, alt1 []byte, out *bufio.Writer) {
	length_bound := 10000

	if len(ref) == 0 {
		return
	}

	p0 := make([]byte, 0, len(ref))
	p1 := make([]byte, 0, len(ref))

	// We can bypass doing a string alignment if they're equal, so test
	// for equal (considering 'n' (nocall) entries as wildcards).
	//
	if !_noc_eq(ref, alt0) {

		if (len(ref) > length_bound) || (len(alt0) > length_bound) {
			ref0, algn0 := g.ClumsyAlign(ref, alt0)
			for ii := 0; ii < len(ref0); ii++ {
				p0 = append(p0, pasta.SubMap[ref0[ii]][algn0[ii]])
			}
		} else {
			ref0, algn0, sc0 := memz.Hirschberg(ref, alt0)
			_ = sc0
			for ii := 0; ii < len(ref0); ii++ {
				p0 = append(p0, pasta.SubMap[ref0[ii]][algn0[ii]])
			}
		}

	} else {
		for ii := 0; ii < len(ref); ii++ {
			p0 = append(p0, pasta.SubMap[ref[ii]][alt0[ii]])
		}
	}

	if !_noc_eq(ref, alt1) {

		if (len(ref) > length_bound) || (len(alt1) > length_bound) {
			ref1, algn1 := g.ClumsyAlign(ref, alt1)
			for ii := 0; ii < len(ref1); ii++ {
				p1 = append(p1, pasta.SubMap[ref1[ii]][algn1[ii]])
			}
		} else {
			ref1, algn1, sc1 := memz.Hirschberg(ref, alt1)
			_ = sc1
			for ii := 0; ii < len(ref1); ii++ {
				p1 = append(p1, pasta.SubMap[ref1[ii]][algn1[ii]])
			}
		}

	} else {
		for ii := 0; ii < len(ref); ii++ {
			p1 = append(p1, pasta.SubMap[ref[ii]][alt1[ii]])
		}
	}

	r0 := bytes.NewReader(p0)
	r1 := bytes.NewReader(p1)

	g.Out = out
	pasta.InterleaveStreams(r0, r1, g)
}