示例#1
0
文件: records.go 项目: shenwei356/bio
// Format returns formated (wrapped with fixed length of) sequence record
func (record *Record) Format(width int) []byte {
	if len(record.Seq.Qual) > 0 {
		return append(append(append(append([]byte(fmt.Sprintf("@%s\n", record.Name)),
			byteutil.WrapByteSlice(record.Seq.Seq, width)...), []byte("\n+\n")...),
			byteutil.WrapByteSlice(record.Seq.Qual, width)...), []byte("\n")...)
	}
	return append(append([]byte(fmt.Sprintf(">%s\n", record.Name)),
		byteutil.WrapByteSlice(record.Seq.Seq, width)...), []byte("\n")...)
}
示例#2
0
文件: records.go 项目: shenwei356/bio
// FormatToWriter formats and directly writes to writer
func (record *Record) FormatToWriter(outfh *xopen.Writer, width int) {
	if len(record.Seq.Qual) > 0 {
		outfh.Write([]byte(fmt.Sprintf("@%s\n", record.Name)))

		if len(record.Seq.Seq) <= pageSize {
			outfh.Write(byteutil.WrapByteSlice(record.Seq.Seq, width))
		} else {
			text, b := bufferedByteSliceWrapper.Wrap(record.Seq.Seq, width)
			outfh.Write(text)
			outfh.Flush()
			bufferedByteSliceWrapper.Recycle(b)
		}

		outfh.Write([]byte("\n+\n"))

		if len(record.Seq.Qual) <= pageSize {
			outfh.Write(byteutil.WrapByteSlice(record.Seq.Qual, width))
		} else {
			text, b := bufferedByteSliceWrapper.Wrap(record.Seq.Qual, width)
			outfh.Write(text)
			outfh.Flush()
			bufferedByteSliceWrapper.Recycle(b)
		}

		outfh.Write([]byte("\n"))

		return
	}

	outfh.Write([]byte(fmt.Sprintf(">%s\n", record.Name)))

	if len(record.Seq.Seq) <= pageSize {
		outfh.Write(byteutil.WrapByteSlice(record.Seq.Seq, width))
	} else {
		text, b := bufferedByteSliceWrapper.Wrap(record.Seq.Seq, width)
		outfh.Write(text)
		outfh.Flush()
		bufferedByteSliceWrapper.Recycle(b)
	}

	outfh.Write([]byte("\n"))
}
示例#3
0
文件: Seq.go 项目: shenwei356/bio
// FormatSeq wrap seq
func (seq *Seq) FormatSeq(width int) []byte {
	return byteutil.WrapByteSlice(seq.Seq, width)
}