mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Adds some docs
Former-commit-id: 7e96983ed707b2a574425799c32c32243f4876cf
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
// Package obiformats provides functions for formatting and writing biosequences in various formats.
|
||||||
package obiformats
|
package obiformats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -23,6 +24,7 @@ func min(x, y int) int {
|
|||||||
return y
|
return y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FormatFasta formats a BioSequence as a FASTA-formatted string using the provided format header.
|
||||||
func FormatFasta(seq *obiseq.BioSequence, formater FormatHeader) string {
|
func FormatFasta(seq *obiseq.BioSequence, formater FormatHeader) string {
|
||||||
var fragments strings.Builder
|
var fragments strings.Builder
|
||||||
|
|
||||||
@ -55,6 +57,7 @@ func FormatFasta(seq *obiseq.BioSequence, formater FormatHeader) string {
|
|||||||
folded)
|
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 {
|
func FormatFastaBatch(batch obiiter.BioSequenceBatch, formater FormatHeader, skipEmpty bool) []byte {
|
||||||
var bs bytes.Buffer
|
var bs bytes.Buffer
|
||||||
for _, seq := range batch.Slice() {
|
for _, seq := range batch.Slice() {
|
||||||
@ -72,6 +75,7 @@ func FormatFastaBatch(batch obiiter.BioSequenceBatch, formater FormatHeader, ski
|
|||||||
return bs.Bytes()
|
return bs.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The WriteFasta function writes a given iterator of biological sequences to a file in FASTA format.
|
||||||
func WriteFasta(iterator obiiter.IBioSequence,
|
func WriteFasta(iterator obiiter.IBioSequence,
|
||||||
file io.WriteCloser,
|
file io.WriteCloser,
|
||||||
options ...WithOption) (obiiter.IBioSequence, error) {
|
options ...WithOption) (obiiter.IBioSequence, error) {
|
||||||
@ -154,12 +158,15 @@ func WriteFasta(iterator obiiter.IBioSequence,
|
|||||||
return newIter, nil
|
return newIter, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The function WriteFastaToStdout writes a FASTA file to standard output.
|
||||||
func WriteFastaToStdout(iterator obiiter.IBioSequence,
|
func WriteFastaToStdout(iterator obiiter.IBioSequence,
|
||||||
options ...WithOption) (obiiter.IBioSequence, error) {
|
options ...WithOption) (obiiter.IBioSequence, error) {
|
||||||
options = append(options, OptionDontCloseFile())
|
options = append(options, OptionDontCloseFile())
|
||||||
return WriteFasta(iterator, os.Stdout, options...)
|
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,
|
func WriteFastaToFile(iterator obiiter.IBioSequence,
|
||||||
filename string,
|
filename string,
|
||||||
options ...WithOption) (obiiter.IBioSequence, error) {
|
options ...WithOption) (obiiter.IBioSequence, error) {
|
||||||
|
@ -15,6 +15,8 @@ import (
|
|||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
"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 {
|
func FormatFastq(seq *obiseq.BioSequence, quality_shift int, formater FormatHeader) string {
|
||||||
|
|
||||||
l := seq.Len()
|
l := seq.Len()
|
||||||
|
Reference in New Issue
Block a user