Files
obitools4/doc/_book/reference-documentation-for-the-go-obitools-library.html

422 lines
30 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>3 Reference documentation for the GO OBITools library | The GO OBITools</title>
<meta name="description" content="Description of the principles used into the GO implementation of OBITools." />
<meta name="generator" content="bookdown 0.29 and GitBook 2.6.7" />
<meta property="og:title" content="3 Reference documentation for the GO OBITools library | The GO OBITools" />
<meta property="og:type" content="book" />
<meta property="og:description" content="Description of the principles used into the GO implementation of OBITools." />
<meta name="github-repo" content="seankross/bookdown-start" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="3 Reference documentation for the GO OBITools library | The GO OBITools" />
<meta name="twitter:description" content="Description of the principles used into the GO implementation of OBITools." />
<meta name="author" content="SEric Coissac" />
<meta name="date" content="2022-08-25" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="prev" href="the-obitools-commands.html"/>
<link rel="next" href="annexes.html"/>
<script src="book_assets/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6/dist/fuse.min.js"></script>
<link href="book_assets/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="book_assets/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="book_assets/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="book_assets/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="book_assets/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="book_assets/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="book_assets/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />
<link href="book_assets/anchor-sections-1.1.0/anchor-sections.css" rel="stylesheet" />
<link href="book_assets/anchor-sections-1.1.0/anchor-sections-hash.css" rel="stylesheet" />
<script src="book_assets/anchor-sections-1.1.0/anchor-sections.js"></script>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li class="chapter" data-level="1" data-path="the-obitools.html"><a href="the-obitools.html"><i class="fa fa-check"></i><b>1</b> The OBITools</a>
<ul>
<li class="chapter" data-level="1.1" data-path="the-obitools.html"><a href="the-obitools.html#aims-of-obitools"><i class="fa fa-check"></i><b>1.1</b> Aims of <em>OBITools</em></a></li>
<li class="chapter" data-level="1.2" data-path="the-obitools.html"><a href="the-obitools.html#file-formats-usable-with-obitools"><i class="fa fa-check"></i><b>1.2</b> File formats usable with <em>OBITools</em></a>
<ul>
<li class="chapter" data-level="1.2.1" data-path="the-obitools.html"><a href="the-obitools.html#the-sequence-files"><i class="fa fa-check"></i><b>1.2.1</b> The sequence files</a></li>
<li class="chapter" data-level="1.2.2" data-path="the-obitools.html"><a href="the-obitools.html#the-iupac-code"><i class="fa fa-check"></i><b>1.2.2</b> The IUPAC Code</a></li>
<li class="chapter" data-level="1.2.3" data-path="the-obitools.html"><a href="the-obitools.html#classical-fasta"><i class="fa fa-check"></i><b>1.2.3</b> The <em>fasta</em> format</a></li>
<li class="chapter" data-level="1.2.4" data-path="the-obitools.html"><a href="the-obitools.html#classical-fastq"><i class="fa fa-check"></i><b>1.2.4</b> The <em>fastq</em> sequence format</a></li>
</ul></li>
<li class="chapter" data-level="1.3" data-path="the-obitools.html"><a href="the-obitools.html#file-extension"><i class="fa fa-check"></i><b>1.3</b> File extension</a></li>
<li class="chapter" data-level="1.4" data-path="the-obitools.html"><a href="the-obitools.html#see-also"><i class="fa fa-check"></i><b>1.4</b> See also</a></li>
<li class="chapter" data-level="1.5" data-path="the-obitools.html"><a href="the-obitools.html#references"><i class="fa fa-check"></i><b>1.5</b> References</a></li>
</ul></li>
<li class="chapter" data-level="2" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html"><i class="fa fa-check"></i><b>2</b> The <em>OBITools</em> commands</a>
<ul>
<li class="chapter" data-level="2.1" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#specifying-the-input-files-to-obitools-commands"><i class="fa fa-check"></i><b>2.1</b> Specifying the input files to <em>OBITools</em> commands</a></li>
<li class="chapter" data-level="2.2" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#options-common-to-most-of-the-obitools-commands"><i class="fa fa-check"></i><b>2.2</b> Options common to most of the <em>OBITools</em> commands</a>
<ul>
<li class="chapter" data-level="2.2.1" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#specifying-input-format"><i class="fa fa-check"></i><b>2.2.1</b> Specifying input format</a></li>
<li class="chapter" data-level="2.2.2" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#specifying-output-format"><i class="fa fa-check"></i><b>2.2.2</b> Specifying output format</a></li>
<li class="chapter" data-level="2.2.3" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#format-of-the-annotations-in-fasta-and-fastq-files"><i class="fa fa-check"></i><b>2.2.3</b> Format of the annotations in Fasta and Fastq files</a></li>
</ul></li>
<li class="chapter" data-level="2.3" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#metabarcode-design-and-quality-assessment"><i class="fa fa-check"></i><b>2.3</b> Metabarcode design and quality assessment</a></li>
<li class="chapter" data-level="2.4" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#file-format-conversions"><i class="fa fa-check"></i><b>2.4</b> File format conversions</a></li>
<li class="chapter" data-level="2.5" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#sequence-annotations"><i class="fa fa-check"></i><b>2.5</b> Sequence annotations</a></li>
<li class="chapter" data-level="2.6" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#computations-on-sequences"><i class="fa fa-check"></i><b>2.6</b> Computations on sequences</a>
<ul>
<li class="chapter" data-level="2.6.1" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#obipairing"><i class="fa fa-check"></i><b>2.6.1</b> <code>obipairing</code></a></li>
</ul></li>
<li class="chapter" data-level="2.7" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#sequence-sampling-and-filtering"><i class="fa fa-check"></i><b>2.7</b> Sequence sampling and filtering</a>
<ul>
<li class="chapter" data-level="2.7.1" data-path="the-obitools-commands.html"><a href="the-obitools-commands.html#utilities"><i class="fa fa-check"></i><b>2.7.1</b> Utilities</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="3" data-path="reference-documentation-for-the-go-obitools-library.html"><a href="reference-documentation-for-the-go-obitools-library.html"><i class="fa fa-check"></i><b>3</b> Reference documentation for the GO <em>OBITools</em> library</a>
<ul>
<li class="chapter" data-level="3.1" data-path="reference-documentation-for-the-go-obitools-library.html"><a href="reference-documentation-for-the-go-obitools-library.html#biosequence"><i class="fa fa-check"></i><b>3.1</b> BioSequence</a>
<ul>
<li class="chapter" data-level="3.1.1" data-path="reference-documentation-for-the-go-obitools-library.html"><a href="reference-documentation-for-the-go-obitools-library.html#creating-new-instances"><i class="fa fa-check"></i><b>3.1.1</b> Creating new instances</a></li>
<li class="chapter" data-level="3.1.2" data-path="reference-documentation-for-the-go-obitools-library.html"><a href="reference-documentation-for-the-go-obitools-library.html#end-of-life-of-a-biosequence-instance"><i class="fa fa-check"></i><b>3.1.2</b> End of life of a <code>BioSequence</code> instance</a></li>
<li class="chapter" data-level="3.1.3" data-path="reference-documentation-for-the-go-obitools-library.html"><a href="reference-documentation-for-the-go-obitools-library.html#accessing-to-the-elements-of-a-sequence"><i class="fa fa-check"></i><b>3.1.3</b> Accessing to the elements of a sequence</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="4" data-path="annexes.html"><a href="annexes.html"><i class="fa fa-check"></i><b>4</b> Annexes</a>
<ul>
<li class="chapter" data-level="4.0.1" data-path="annexes.html"><a href="annexes.html#sequence-attributes"><i class="fa fa-check"></i><b>4.0.1</b> Sequence attributes</a></li>
</ul></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">The GO <em>OBITools</em></a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="reference-documentation-for-the-go-obitools-library" class="section level1 hasAnchor" number="3">
<h1><span class="header-section-number">3</span> Reference documentation for the GO <em>OBITools</em> library<a href="reference-documentation-for-the-go-obitools-library.html#reference-documentation-for-the-go-obitools-library" class="anchor-section" aria-label="Anchor link to header"></a></h1>
<div id="biosequence" class="section level2 hasAnchor" number="3.1">
<h2><span class="header-section-number">3.1</span> BioSequence<a href="reference-documentation-for-the-go-obitools-library.html#biosequence" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>The <code>BioSequence</code> class is used to represent biological sequences. It
allows for storing : - the sequence itself as a <code>[]byte</code> - the
sequencing quality score as a <code>[]byte</code> if needed - an identifier as a
<code>string</code> - a definition as a <code>string</code> - a set of <em>(key, value)</em> pairs in
a <code>map[sting]interface{}</code></p>
<p>BioSequence is defined in the obiseq module and is included using the
code</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode go"><code class="sourceCode go"><span id="cb7-1"><a href="reference-documentation-for-the-go-obitools-library.html#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="kw">import</span> <span class="op">(</span></span>
<span id="cb7-2"><a href="reference-documentation-for-the-go-obitools-library.html#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq&quot;</span></span>
<span id="cb7-3"><a href="reference-documentation-for-the-go-obitools-library.html#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="op">)</span></span></code></pre></div>
<div id="creating-new-instances" class="section level3 hasAnchor" number="3.1.1">
<h3><span class="header-section-number">3.1.1</span> Creating new instances<a href="reference-documentation-for-the-go-obitools-library.html#creating-new-instances" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>To create new instance, use</p>
<ul>
<li><code>MakeBioSequence(id string, sequence []byte, definition string) obiseq.BioSequence</code></li>
<li><code>NewBioSequence(id string, sequence []byte, definition string) *obiseq.BioSequence</code></li>
</ul>
<p>Both create a <code>BioSequence</code> instance, but when the first one returns the
instance, the second returns a pointer on the new instance. Two other
functions <code>MakeEmptyBioSequence</code>, and <code>NewEmptyBioSequence</code> do the same
job but provide an uninitialized objects.</p>
<ul>
<li><code>id</code> parameters corresponds to the unique identifier of the
sequence. It mist be a string constituted of a single word (not
containing any space).</li>
<li><code>sequence</code> is the DNA sequence itself, provided as a <code>byte</code> array
(<code>[]byte</code>).</li>
<li><code>definition</code> is a <code>string</code>, potentially empty, but usualy containing
a sentence explaining what is that sequence.</li>
</ul>
<div class="sourceCode" id="cb8"><pre class="sourceCode go"><code class="sourceCode go"><span id="cb8-1"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="kw">import</span> <span class="op">(</span></span>
<span id="cb8-2"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq&quot;</span></span>
<span id="cb8-3"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="op">)</span></span>
<span id="cb8-4"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb8-5"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-5" aria-hidden="true" tabindex="-1"></a><span class="kw">func</span> main<span class="op">()</span> <span class="op">{</span></span>
<span id="cb8-6"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-6" aria-hidden="true" tabindex="-1"></a> myseq <span class="op">:=</span> obiseq<span class="op">.</span>NewBiosequence<span class="op">(</span></span>
<span id="cb8-7"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;seq_GH0001&quot;</span><span class="op">,</span></span>
<span id="cb8-8"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-8" aria-hidden="true" tabindex="-1"></a> bytes<span class="op">.</span>FromString<span class="op">(</span><span class="st">&quot;ACGTGTCAGTCG&quot;</span><span class="op">),</span></span>
<span id="cb8-9"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;A short test sequence&quot;</span><span class="op">,</span></span>
<span id="cb8-10"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-10" aria-hidden="true" tabindex="-1"></a> <span class="op">)</span></span>
<span id="cb8-11"><a href="reference-documentation-for-the-go-obitools-library.html#cb8-11" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>When formated as fasta the parameters correspond to the following schema</p>
<pre><code>&gt;id definition containing potentially several words
sequence</code></pre>
</div>
<div id="end-of-life-of-a-biosequence-instance" class="section level3 hasAnchor" number="3.1.2">
<h3><span class="header-section-number">3.1.2</span> End of life of a <code>BioSequence</code> instance<a href="reference-documentation-for-the-go-obitools-library.html#end-of-life-of-a-biosequence-instance" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>When a <code>BioSequence</code> instance is no more used, it is normally taken in
charge by the GO garbage collector. You can if you want call the
<code>Recycle</code> method on the instance to store the allocated memory element
in a <code>pool</code> to limit allocation effort when many sequences are
manipulated.</p>
</div>
<div id="accessing-to-the-elements-of-a-sequence" class="section level3 hasAnchor" number="3.1.3">
<h3><span class="header-section-number">3.1.3</span> Accessing to the elements of a sequence<a href="reference-documentation-for-the-go-obitools-library.html#accessing-to-the-elements-of-a-sequence" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>The different elements of an <code>obiseq.BioSequence</code> must be accessed using
a set of methods. For the three main elements provided during the
creation of a new instance methodes are :</p>
<ul>
<li><code>Id() string</code></li>
<li><code>Sequence() []byte</code></li>
<li><code>Definition() string</code></li>
</ul>
<p>It exists pending method to change the value of these elements</p>
<ul>
<li><code>SetId(id string)</code></li>
<li><code>SetSequence(sequence []byte)</code></li>
<li><code>SetDefinition(definition string)</code></li>
</ul>
<div class="sourceCode" id="cb10"><pre class="sourceCode go"><code class="sourceCode go"><span id="cb10-1"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="kw">import</span> <span class="op">(</span></span>
<span id="cb10-2"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;fmt&quot;</span></span>
<span id="cb10-3"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-3" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq&quot;</span></span>
<span id="cb10-4"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="op">)</span></span>
<span id="cb10-5"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-6"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-6" aria-hidden="true" tabindex="-1"></a><span class="kw">func</span> main<span class="op">()</span> <span class="op">{</span></span>
<span id="cb10-7"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-7" aria-hidden="true" tabindex="-1"></a> myseq <span class="op">:=</span> obiseq<span class="op">.</span>NewBiosequence<span class="op">(</span></span>
<span id="cb10-8"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;seq_GH0001&quot;</span><span class="op">,</span></span>
<span id="cb10-9"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-9" aria-hidden="true" tabindex="-1"></a> bytes<span class="op">.</span>FromString<span class="op">(</span><span class="st">&quot;ACGTGTCAGTCG&quot;</span><span class="op">),</span></span>
<span id="cb10-10"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-10" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;A short test sequence&quot;</span><span class="op">,</span></span>
<span id="cb10-11"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-11" aria-hidden="true" tabindex="-1"></a> <span class="op">)</span></span>
<span id="cb10-12"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-13"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-13" aria-hidden="true" tabindex="-1"></a> fmt<span class="op">.</span>Println<span class="op">(</span>myseq<span class="op">.</span>Id<span class="op">())</span></span>
<span id="cb10-14"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-14" aria-hidden="true" tabindex="-1"></a> myseq<span class="op">.</span>SetId<span class="op">(</span><span class="st">&quot;SPE01_0001&quot;</span><span class="op">)</span></span>
<span id="cb10-15"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-15" aria-hidden="true" tabindex="-1"></a> fmt<span class="op">.</span>Println<span class="op">(</span>myseq<span class="op">.</span>Id<span class="op">())</span></span>
<span id="cb10-16"><a href="reference-documentation-for-the-go-obitools-library.html#cb10-16" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<div id="different-ways-for-accessing-an-editing-the-sequence" class="section level4 hasAnchor" number="3.1.3.1">
<h4><span class="header-section-number">3.1.3.1</span> Different ways for accessing an editing the sequence<a href="reference-documentation-for-the-go-obitools-library.html#different-ways-for-accessing-an-editing-the-sequence" class="anchor-section" aria-label="Anchor link to header"></a></h4>
<p>If <code>Sequence()</code>and <code>SetSequence(sequence []byte)</code> methods are the basic
ones, several other methods exist.</p>
<ul>
<li><code>String() string</code> return the sequence directly converted to a
<code>string</code> instance.</li>
<li>The <code>Write</code> method family allows for extending an existing sequence
following the buffer protocol.
<ul>
<li><code>Write(data []byte) (int, error)</code> allows for appending a byte
array on 3 end of the sequence.</li>
<li><code>WriteString(data string) (int, error)</code> allows for appending a
<code>string</code>.</li>
<li><code>WriteByte(data byte) error</code> allows for appending a single
<code>byte</code>.</li>
</ul></li>
</ul>
<p>The <code>Clear</code> method empties the sequence buffer.</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode go"><code class="sourceCode go"><span id="cb11-1"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="kw">import</span> <span class="op">(</span></span>
<span id="cb11-2"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;fmt&quot;</span></span>
<span id="cb11-3"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq&quot;</span></span>
<span id="cb11-4"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="op">)</span></span>
<span id="cb11-5"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-6"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-6" aria-hidden="true" tabindex="-1"></a><span class="kw">func</span> main<span class="op">()</span> <span class="op">{</span></span>
<span id="cb11-7"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-7" aria-hidden="true" tabindex="-1"></a> myseq <span class="op">:=</span> obiseq<span class="op">.</span>NewEmptyBiosequence<span class="op">()</span></span>
<span id="cb11-8"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-9"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-9" aria-hidden="true" tabindex="-1"></a> myseq<span class="op">.</span>WriteString<span class="op">(</span><span class="st">&quot;accc&quot;</span><span class="op">)</span></span>
<span id="cb11-10"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-10" aria-hidden="true" tabindex="-1"></a> myseq<span class="op">.</span>WriteByte<span class="op">(</span><span class="dt">byte</span><span class="op">(</span><span class="ch">&#39;c&#39;</span><span class="op">))</span></span>
<span id="cb11-11"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-11" aria-hidden="true" tabindex="-1"></a> fmt<span class="op">.</span>Println<span class="op">(</span>myseq<span class="op">.</span>String<span class="op">())</span></span>
<span id="cb11-12"><a href="reference-documentation-for-the-go-obitools-library.html#cb11-12" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
</div>
<div id="sequence-quality-scores" class="section level4 hasAnchor" number="3.1.3.2">
<h4><span class="header-section-number">3.1.3.2</span> Sequence quality scores<a href="reference-documentation-for-the-go-obitools-library.html#sequence-quality-scores" class="anchor-section" aria-label="Anchor link to header"></a></h4>
<p>Sequence quality scores cannot be initialized at the time of instance
creation. You must use dedicated methods to add quality scores to a
sequence.</p>
<p>To be coherent the length of both the DNA sequence and que quality score
sequence must be equal. But assessment of this constraint is realized.
It is of the programmer responsability to check that invariant.</p>
<p>While accessing to the quality scores relies on the method
<code>Quality() []byte</code>, setting the quality need to call one of the
following method. They run similarly to their sequence dedicated
conterpart.</p>
<ul>
<li><code>SetQualities(qualities Quality)</code></li>
<li><code>WriteQualities(data []byte) (int, error)</code></li>
<li><code>WriteByteQualities(data byte) error</code></li>
</ul>
<p>In a way analogous to the <code>Clear</code> method, <code>ClearQualities()</code> empties the
sequence of quality scores.</p>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
<a href="the-obitools-commands.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="annexes.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
</div>
</div>
<script src="book_assets/gitbook-2.6.7/js/app.min.js"></script>
<script src="book_assets/gitbook-2.6.7/js/clipboard.min.js"></script>
<script src="book_assets/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="book_assets/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="book_assets/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="book_assets/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="book_assets/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script src="book_assets/gitbook-2.6.7/js/plugin-clipboard.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"linkedin": false,
"weibo": false,
"instapaper": false,
"vk": false,
"whatsapp": false,
"all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": null,
"text": null
},
"history": {
"link": null,
"text": null
},
"view": {
"link": null,
"text": null
},
"download": ["_main.pdf"],
"search": {
"engine": "fuse",
"options": null
},
"toc": {
"collapse": "subsection"
}
});
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
var src = "true";
if (src === "" || src === "true") src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/latest.js?config=TeX-MML-AM_CHTML";
if (location.protocol !== "file:")
if (/^https?:/.test(src))
src = src.replace(/^https?:/, '');
script.src = src;
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>