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 }
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} }
// StructureBow is a helper function to compute a bag-of-words given a // structure fragment library and a list of alpha-carbon atoms. // // If the lib given is a weighted library, then the Bow returned will also // be weighted. // // Note that this function should only be used when providing your own // implementation of the StructureBower interface. Otherwise, BOWs should // be computed using the StructureBow method of the interface. func StructureBow(lib fragbag.StructureLibrary, atoms []structure.Coords) Bow { var best, uplimit int b := NewBow(lib.Size()) libSize := lib.FragmentSize() uplimit = len(atoms) - libSize for i := 0; i <= uplimit; i++ { best = lib.BestStructureFragment(atoms[i : i+libSize]) if best > -1 { b.Freqs[best] += 1 } } if wlib, ok := lib.(fragbag.WeightedLibrary); ok { b = b.Weighted(wlib) } return b }