Ejemplo n.º 1
0
// 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")...)
}
Ejemplo n.º 2
0
// 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"))
}
Ejemplo n.º 3
0
// FormatSeq wrap seq
func (seq *Seq) FormatSeq(width int) []byte {
	return byteutil.WrapByteSlice(seq.Seq, width)
}