From 39b47a32bfab2413f18d834331b5bc77fc6013f6 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Fri, 27 Jan 2023 10:49:28 +0100 Subject: [PATCH] Complement on the doc --- doc/_book/annexes.html | 2 +- doc/_book/commands.html | 122 +++++++++++++++-- .../figure-html/unnamed-chunk-1-1.png | Bin 0 -> 62529 bytes doc/_book/index.html | 29 +++- doc/_book/intro.html | 4 +- doc/_book/library.html | 76 ++++++++++- doc/_book/references.html | 13 +- doc/book.bib | 70 ++++++++++ doc/commands.qmd | 127 +++++++++++++++++- doc/index.qmd | 4 + doc/library.qmd | 65 ++++++++- pkg/obialign/dnamatrix.go | 2 +- 12 files changed, 485 insertions(+), 29 deletions(-) create mode 100644 doc/_book/commands_files/figure-html/unnamed-chunk-1-1.png diff --git a/doc/_book/annexes.html b/doc/_book/annexes.html index 426c191..8d6e915 100644 --- a/doc/_book/annexes.html +++ b/doc/_book/annexes.html @@ -105,7 +105,7 @@ ul.task-list li input[type="checkbox"] {
  • 3.1.1 Creating new instances
  • 3.1.2 End of life of a BioSequence instance
  • 3.1.3 Accessing to the elements of a sequence
  • +
  • 3.1.4 The annotations of a sequence
  • + +
  • 3.2 The sequence iterator +
  • @@ -261,7 +268,7 @@ sequence

    3.1.2 End of life of a BioSequence instance

    -

    When a BioSequence instance is no more used, it is normally taken in charge by the GO garbage collector. You can if you want call the Recycle method on the instance to store the allocated memory element in a pool to limit allocation effort when many sequences are manipulated.

    +

    When an instance of BioSequence is no longer in use, it is normally taken over by the GO garbage collector. If you know that an instance will never be used again, you can, if you wish, call the Recycle method on it to store the allocated memory elements in a pool to limit the allocation effort when many sequences are being handled. Once the recycle method has been called on an instance, you must ensure that no other method is called on it.

    3.1.3 Accessing to the elements of a sequence

    @@ -330,9 +337,68 @@ sequence
  • WriteByteQualities(data byte) error
  • In a way analogous to the Clear method, ClearQualities() empties the sequence of quality scores.

    - -
    + +
    +

    3.1.4 The annotations of a sequence

    +

    A sequence can be annotated with attributes. Each attribute is associated with a value. An attribute is identified by its name. The name of an attribute consists of a character string containing no spaces or blank characters. Values can be of several types.

    +
      +
    • Scalar types: +
        +
      • integer
      • +
      • numeric
      • +
      • character
      • +
      • boolean
      • +
    • +
    • Container types: +
        +
      • vector
      • +
      • map
      • +
    • +
    +

    Vectors can contain any type of scalar. Maps are compulsorily indexed by strings and can contain any scalar type. It is not possible to have nested container type.

    +

    Annotations are stored in an object of type bioseq.Annotation which is an alias of map[string]interface{}. This map can be retrieved using the Annotations() Annotation method. If no annotation has been defined for this sequence, the method returns an empty map. It is possible to test an instance of BioSequence using its HasAnnotation() bool method to see if it has any annotations associated with it.

    +
      +
    • GetAttribute(key string) (interface{}, bool)
    • +
    +
    + +
    +

    3.2 The sequence iterator

    +

    The pakage obiter provides an iterator mecanism for manipulating sequences. The main class provided by this package is obiiter.IBioSequence. An IBioSequence iterator provides batch of sequences.

    +
    +

    3.2.1 Basic usage of a sequence iterator

    +

    Many functions, among them functions reading sequences from a text file, return a IBioSequence iterator. The iterator class provides two main methods:

    +
      +
    • Next() bool
    • +
    • Get() obiiter.BioSequenceBatch
    • +
    +

    The Next method moves the iterator to the next value, while the Get method returns the currently pointed value. Using them, it is possible to loop over the data as in the following code chunk.

    +
    import (
    +    "git.metabarcoding.org/lecasofts/go/obitools/pkg/obiformats"
    +)
    +
    +func main() {
    +    mydata := obiformats.ReadFastSeqFromFile("myfile.fasta")
    +       
    +    for mydata.Next() {
    +        data := mydata.Get()
    +        //
    +        // Whatever you want to do with the data chunk
    +        //
    +    }
    +}
    +

    An obiseq.BioSequenceBatch instance is a set of sequences stored in an obiseq.BioSequenceSlice and a sequence number. The number of sequences in a batch is not defined. A batch can even contain zero sequences, if for example all sequences initially included in the batch have been filtered out at some stage of their processing.

    +
    +
    +

    3.2.2 The Pipable functions

    +

    A function consuming a obiiter.IBioSequence and returning a obiiter.IBioSequence is of class obiiter.Pipable.

    +
    +
    +

    3.2.3 The Teeable functions

    +

    A function consuming a obiiter.IBioSequence and returning two obiiter.IBioSequence instance is of class obiiter.Teeable.

    + +
    @@ -473,7 +539,7 @@ window.document.addEventListener("DOMContentLoaded", function (event) {