Example #1
0
func bmean(row1, row2 []bow.Bow) (bow.Bow, bow.Bow) {
	m1, m2 := bow.NewBow(row1[0].Len()), bow.NewBow(row2[0].Len())
	if m1.Len() != m2.Len() {
		panic("bow lengths don't match")
	}

	for _, b1 := range row1 {
		for c := range b1.Freqs {
			m1.Freqs[c] += b1.Freqs[c]
		}
	}
	for c := range m1.Freqs {
		m1.Freqs[c] /= float32(len(row1))
	}

	for _, b2 := range row2 {
		for c := range b2.Freqs {
			m2.Freqs[c] += b2.Freqs[c]
		}
	}
	for c := range m2.Freqs {
		m2.Freqs[c] /= float32(len(row2))
	}

	return m1, m2
}
Example #2
0
func (fmap *FragmentMap) StructureBow(lib fragbag.StructureLibrary) bow.Bowed {
	bag := bow.NewBow(lib.Size())
	for _, fragGroup := range fmap.Segments {
		for _, frag := range fragGroup.Frags {
			bag = bag.Add(bow.StructureBow(lib, frag.CaAtoms))
		}
	}
	return bow.Bowed{Id: fmap.Name, Bow: bag}
}
Example #3
0
func (e newStyle) StructureBow(lib fragbag.StructureLibrary) bow.Bow {
	bag := bow.NewBow(lib.Size())
	for _, chain := range e.Chains {
		for _, model := range chain.Models {
			bag = bag.Add(bow.StructureBow(lib, model.CaAtoms()))
		}
	}
	return bag
}
Example #4
0
func readVectors(fpath string) map[string]bow.Bow {
	f := util.OpenFile(fpath)
	defer f.Close()

	bows := make(map[string]bow.Bow, 5000)
	for _, line := range util.ReadLines(f) {
		fields := strings.Fields(line)
		b := bow.NewBow(len(fields[1:]))
		for _, sfreq := range fields[1:] {
			freq, err := strconv.ParseFloat(sfreq, 32)
			util.Assert(err)
			b.Freqs = append(b.Freqs, float32(freq))
		}
		bows[fields[0]] = b
	}
	return bows
}