示例#1
0
文件: multi.go 项目: frogs/biogo
func (self *Multi) Flush(where int, fill alphabet.Letter) {
	if self.IsFlush(where) {
		return
	}

	if where&seq.Start != 0 {
		start := self.Start()
		for _, s := range self.S {
			if s.Start()-start < 1 {
				continue
			}
			if m, ok := s.(*Multi); ok {
				m.Flush(where, fill)
				continue
			}
			S := s.Raw()
			switch S.(type) {
			case *[]alphabet.Letter:
				uS := S.(*[]alphabet.Letter)
				*uS = append(fill.Repeat(s.Start()-start), *uS...)
			case *[]alphabet.QLetter:
				uS := S.(*[]alphabet.QLetter)
				*uS = append(alphabet.QLetter{L: fill}.Repeat(s.Start()-start), *uS...)
			case packed.Packing, *[]alphabet.QPack:
				panic("not implemented") // and never will be
				// packed.Seq cannot hold letters beyond the 4 letters in the
				// alphabet so it cannot have gaps.
				// Perhaps a bitmap of valid bases may be considered though
				// I can't see any particularly strong argument for this.
				// packed.QSeq could have gaps, by assigning 0 Qphred, but this
				// opens up possibility for abuse unless a valid bitmap is also
				// inlcuded for this type.
			}
			s.Offset(start)
		}
	}
	if where&seq.End != 0 {
		end := self.End()
		for i := 0; i < self.Count(); i++ {
			s := self.Get(i)
			if end-s.End() < 1 {
				continue
			}
			s.(seq.Appender).AppendQLetters(alphabet.QLetter{L: fill}.Repeat(end - s.End())...)
		}
	}
}
示例#2
0
文件: multi.go 项目: frogs/biogo
func (self *Multi) Flush(where int, fill alphabet.Letter) {
	if self.IsFlush(where) {
		return
	}

	if where&seq.Start != 0 {
		start := self.Start()
		for _, s := range self.S {
			if s.Start()-start < 1 {
				continue
			}
			if m, ok := s.(*Multi); ok {
				m.Flush(where, fill)
				continue
			}
			S := s.Raw()
			switch S.(type) {
			case *[]alphabet.Letter:
				uS := S.(*[]alphabet.Letter)
				*uS = append(fill.Repeat(s.Start()-start), *uS...)
			case *[]alphabet.QLetter:
				uS := S.(*[]alphabet.QLetter)
				*uS = append(alphabet.QLetter{L: fill}.Repeat(s.Start()-start), *uS...)
			}
			s.Offset(start)
		}
	}
	if where&seq.End != 0 {
		end := self.End()
		for i := 0; i < self.Count(); i++ {
			s := self.Get(i)
			if end-s.End() < 1 {
				continue
			}
			s.(seq.Appender).AppendQLetters(alphabet.QLetter{L: fill}.Repeat(end - s.End())...)
		}
	}
}