本文整理汇总了Golang中github.com/TuftsBCB/seq.Sequence.Len方法的典型用法代码示例。如果您正苦于以下问题:Golang Sequence.Len方法的具体用法?Golang Sequence.Len怎么用?Golang Sequence.Len使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/TuftsBCB/seq.Sequence
的用法示例。
在下文中一共展示了Sequence.Len方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AlignmentProb
// AlignmentProb computes the probability of the sequence `s` aligning
// with the HMM in `frag`. The sequence must have length equivalent
// to the fragment size.
func (lib *sequenceHMM) AlignmentProb(fragi int, s seq.Sequence) seq.Prob {
frag := lib.Fragments[fragi]
if s.Len() != len(frag.Nodes) {
panic(fmt.Sprintf("Sequence length %d != fragment size %d",
s.Len(), len(frag.Nodes)))
}
return frag.ViterbiScore(s)
}
示例2: expandCoarseSequence
func expandCoarseSequence(db *mica.DB, seqId int, coarseSequence *seq.Sequence) ([]mica.OriginalSeq, error) {
originalSeqs, err := db.CoarseDB.Expand(db.ComDB, seqId, 0, coarseSequence.Len())
if err != nil {
return nil, err
}
return originalSeqs, nil
}
示例3: Write
// Write writes a single FASTA entry to the underlying io.Writer.
//
// You may need to call Flush in order for the changes to be written.
//
// XXX: Currently, the sequence is not checked. Should it be?
func (w *Writer) Write(s seq.Sequence) error {
var out string
if w.Asterisk {
if w.Columns > 0 && s.Len()%w.Columns == 0 {
out = fmt.Sprintf("%s\n*\n", SequenceFasta(s, w.Columns))
} else {
out = fmt.Sprintf("%s*\n", SequenceFasta(s, w.Columns))
}
} else {
out = fmt.Sprintf("%s\n", SequenceFasta(s, w.Columns))
}
_, err := w.buf.WriteString(out)
return err
}
示例4: SequenceBow
// SequenceBow is a helper function to compute a bag-of-words given a
// sequence fragment library and a query sequence.
//
// 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 SequenceBower interface. Otherwise, BOWs should
// be computed using the SequenceBow method of the interface.
func SequenceBow(lib fragbag.SequenceLibrary, s seq.Sequence) Bow {
var best, uplimit int
b := NewBow(lib.Size())
libSize := lib.FragmentSize()
uplimit = s.Len() - libSize
for i := 0; i <= uplimit; i++ {
best = lib.BestSequenceFragment(s.Slice(i, i+libSize))
if best < 0 {
continue
}
b.Freqs[best] += 1
}
if wlib, ok := lib.(fragbag.WeightedLibrary); ok {
b = b.Weighted(wlib)
}
return b
}
示例5: expandCoarseSequence
func expandCoarseSequence(db *cablastp.DB, seqId int, coarseSequence *seq.Sequence) ([]cablastp.OriginalSeq, error) {
originalSeqs, err := db.CoarseDB.Expand(db.ComDB, seqId, 0, coarseSequence.Len())
if err != nil {
return nil, err
}
// var redSeqs [originalSeqs]cablastp.ReducedSeq
// for _, oSeq := range originalSeqs {
// redSeq := &cablastp.ReducedSeq{
// &cablastp.Sequence{
// Name: readSeq.Seq.Name,
// Residues: readSeq.Seq.Residues,
// Offset: readSeq.Seq.Offset,
// Id: readSeq.Seq.Id,
// },
// }
// }
return originalSeqs, nil
}
示例6: AlignmentProb
// AlignmentProb computes the probability of the sequence `s` aligning
// with the profile in `frag`. The sequence must have length equivalent
// to the fragment size.
func (lib *sequenceProfile) AlignmentProb(fragi int, s seq.Sequence) seq.Prob {
frag := lib.Fragments[fragi]
if s.Len() != frag.Len() {
panic(fmt.Sprintf("Sequence length %d != fragment size %d",
s.Len(), frag.Len()))
}
prob := seq.Prob(0.0)
for c := 0; c < s.Len(); c++ {
prob += frag.Emissions[c].Lookup(s.Residues[c])
}
return prob
}
示例7: BestSequenceFragment
// Best returns the number of the fragment that best corresponds
// to the string of amino acids provided.
// The length of `sequence` must be equivalent to the fragment size.
//
// If no "good" fragments can be found, then `-1` is returned. This
// behavior will almost certainly change in the future.
func (lib *sequenceHMM) BestSequenceFragment(s seq.Sequence) int {
if s.Len() != lib.FragmentSize() {
panic(fmt.Sprintf("Sequence length %d != fragment size %d",
s.Len(), lib.FragmentSize()))
}
var testAlign seq.Prob
dynamicTable := seq.AllocTable(lib.FragmentSize(), s.Len())
bestAlign, bestFragNum := seq.MinProb, -1
for _, frag := range lib.Fragments {
testAlign = frag.ViterbiScoreMem(s, dynamicTable)
if bestAlign.Less(testAlign) {
bestAlign, bestFragNum = testAlign, frag.FragNumber
}
}
return bestFragNum
}
示例8: computeMap
func (m MapConfig) computeMap(
pdbDb PDBDatabase, qseq seq.Sequence, qhhm *hmm.HHM) (*FragmentMap, error) {
type maybeFrag struct {
frags Fragments
err error
}
wg := new(sync.WaitGroup)
jobs := make(chan int, 10)
fragsChan := make(chan maybeFrag, 10)
workers := runtime.GOMAXPROCS(0)
if workers < 1 {
workers = 1
}
for i := 0; i < workers; i++ {
go func() {
wg.Add(1)
defer wg.Done()
min, max := m.WindowMin, m.WindowMax
CHANNEL:
for start := range jobs {
var best *Fragments
for end := min; end <= max && (start+end) <= qseq.Len(); end++ {
frags, err := FindFragments(
pdbDb, m.Blits, qhhm, qseq, start, start+end)
if err != nil {
fragsChan <- maybeFrag{
err: err,
}
continue CHANNEL
}
if best == nil || frags.better(*best) {
best = frags
}
}
fragsChan <- maybeFrag{
frags: *best,
}
}
}()
}
go func() {
for s := 0; s <= qseq.Len()-m.WindowMin; s += m.WindowIncrement {
jobs <- s
}
close(jobs)
wg.Wait()
close(fragsChan)
}()
fmap := &FragmentMap{
Name: qseq.Name,
Segments: make([]Fragments, 0, 50),
}
for maybeFrag := range fragsChan {
if maybeFrag.err != nil {
return nil, maybeFrag.err
}
fmap.Segments = append(fmap.Segments, maybeFrag.frags)
}
sort.Sort(fmap)
return fmap, nil
}