Adds some docs

Former-commit-id: 7e96983ed707b2a574425799c32c32243f4876cf
This commit is contained in:
2023-08-14 00:12:17 +02:00
parent be47ec909c
commit fd4c7c2572
2 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,4 @@
// Package obiformats provides functions for formatting and writing biosequences in various formats.
package obiformats
import (
@ -23,6 +24,7 @@ func min(x, y int) int {
return y
}
// FormatFasta formats a BioSequence as a FASTA-formatted string using the provided format header.
func FormatFasta(seq *obiseq.BioSequence, formater FormatHeader) string {
var fragments strings.Builder
@ -55,6 +57,7 @@ func FormatFasta(seq *obiseq.BioSequence, formater FormatHeader) string {
folded)
}
// FormatFastaBatch formats a batch of BioSequences as a single FASTA-formatted byte slice using the provided format header.
func FormatFastaBatch(batch obiiter.BioSequenceBatch, formater FormatHeader, skipEmpty bool) []byte {
var bs bytes.Buffer
for _, seq := range batch.Slice() {
@ -72,6 +75,7 @@ func FormatFastaBatch(batch obiiter.BioSequenceBatch, formater FormatHeader, ski
return bs.Bytes()
}
// The WriteFasta function writes a given iterator of biological sequences to a file in FASTA format.
func WriteFasta(iterator obiiter.IBioSequence,
file io.WriteCloser,
options ...WithOption) (obiiter.IBioSequence, error) {
@ -154,12 +158,15 @@ func WriteFasta(iterator obiiter.IBioSequence,
return newIter, nil
}
// The function WriteFastaToStdout writes a FASTA file to standard output.
func WriteFastaToStdout(iterator obiiter.IBioSequence,
options ...WithOption) (obiiter.IBioSequence, error) {
options = append(options, OptionDontCloseFile())
return WriteFasta(iterator, os.Stdout, options...)
}
// The function `WriteFastaToFile` writes a given iterator of biosequences to a file in FASTA format,
// with the option to append to an existing file and save paired sequences to a separate file.
func WriteFastaToFile(iterator obiiter.IBioSequence,
filename string,
options ...WithOption) (obiiter.IBioSequence, error) {

View File

@ -15,6 +15,8 @@ import (
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
)
// The function FormatFastq takes a BioSequence object, a quality shift value, and a header formatter
// function as input, and returns a formatted string in FASTQ format.
func FormatFastq(seq *obiseq.BioSequence, quality_shift int, formater FormatHeader) string {
l := seq.Len()