<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Leo Martins</title>
<link>https://leomrtns.github.io/blog/</link>
<atom:link href="https://leomrtns.github.io/blog/index.xml" rel="self" type="application/rss+xml"/>
<description>Notes from the workbench — mathematics, algorithms, and computational biology.</description>
<generator>quarto-1.10.18</generator>
<lastBuildDate>Mon, 05 Jan 2026 00:00:00 GMT</lastBuildDate>
<item>
  <title>Back to blogging</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/back-to-blogging/</link>
  <description><![CDATA[ 




<p>I decided to get back into blogging, since perhaps it’s the only semi-permanent documentation of what we have been socially discussing, academically and otherwise.</p>
<p>I was thinking about what went wrong with blogging, and there are several reasons. The mostly cited ones are a lack of support for RSS and its more widespread usage (after the end of Google Reader), and the rise of social media platforms like Twitter, which are quicker to digest than whole paragraphs. <a href="https://matsen.fredhutch.org/general/2025/04/03/blog-return.html">Erick articulates it better than I can</a>, but there are two other personal reasons why I believe I stopped blogging. The first was the volatility of references, and the second was a perceived lack of civility in the comment sections.</p>
<p>I guess we got used to the first one, where links from one year ago are no longer valid, although at that time me, as an academic, assumed that all sentences should be supported by a link (<em>reference needed</em>). Going forward I’ll relax this requirement. A side-effect is that unlike before, we can update blog posts instead of creating a new post just with an addendum. As for the lack of civility, it moved from blog comments to social media. Which on the upside is not a resposibility of the hosting blog to moderate anymore. For personal blogs it does not change much, but now we are more comfortable with blocking, deleting comments, or ignoring trolls even when disguised as <a href="https://web.archive.org/web/20230309165713/http://wondermark.com/1k62/">sea lions</a>.</p>
<p>I still have some stuff to do, like deciding if I should invest in a blog with jupyter-notebook capabilities (I still have some <a href="https://leomrtns.github.io/jupyterblog/">technical blog posts</a> using <a href="https://github.com/fastai/fastpages">the unmaintained fastpages</a> ). Or checking if the RSS gives us the full post —at some point article feeds started forcing you to click back to the original site to read the full content, I guess fitting into my first complaint of volatile content.</p>



 ]]></description>
  <category>Personal</category>
  <guid>https://leomrtns.github.io/posts/back-to-blogging/</guid>
  <pubDate>Mon, 05 Jan 2026 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/images/logo_biomcmc_blog.png" medium="image" type="image/png" height="58" width="144"/>
</item>
<item>
  <title>Welcome</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/welcome/</link>
  <description><![CDATA[ 




<p>I am <a href="https://www.liverpool.ac.uk/people/leonardo-de-oliveira-martins">Leonardo de Oliveira Martins</a>, a Bayesian computational biologist specialised in Evolutionary Genomics. I am a Tenure Track Fellow at the <a href="https://www.liverpool.ac.uk/electrical-engineering-and-electronics/research/data-science-signal-processing/signalprocessing/">Signal Processing Group</a> of the Department of Electrical and Electronic Engineering, <a href="https://www.liverpool.ac.uk/">University of Liverpool</a>.</p>
<p>I used to be a senior researcher at the <a href="http://wwww.quadram.ac.uk">Quadram Institute Biosciences</a>, where I developed, implemented, and streamlined hig-performing computational methods for the evolutionary analysis of microbial data sets.</p>



 ]]></description>
  <category>Misc</category>
  <guid>https://leomrtns.github.io/posts/welcome/</guid>
  <pubDate>Sun, 04 Jan 2026 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/images/bio-photo.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Not all invariant sites are created the same</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/invariant-sites/</link>
  <description><![CDATA[ 




<p>A while back we had an <a href="https://bitsandbugs.org/2019/11/06/two-easy-ways-to-run-iq-tree-with-the-correct-number-of-constant-sites/">interesting discussion regarding the exclusion of invariant sites in maximum likelihood phylogenetic inference</a>. Since this discussion usually comes up again and again, I would like to add a bit of context.</p>
<p>First, I understand that there are situations where it is unavoidable to exclude “uninteresting” sites to speed up calculations, and in many practical situations we expect the results to be unchanged. In these cases, and listening to the justification for it, I wonder why using a slower likelihood method instead of a much faster distance-based method. But that’s a different story.</p>
<p>So, in a nutshell, the problem lies when we have a large alignment where most of the sites (columns in the alignment) are constant, i.e.&nbsp;there is no polymorphism (SNPs) and thus we assume they do not affect the tree estimation. Their removal should not affect the topology, but the branch lengths are indeed affected by the number of constant sites.</p>
<p>Removing constant sites biases your data set towards fast-evolving sites, thus the name ASC (“ascertainment bias” is a type of selection bias). The obvious effect is that all estimated branch lengths will be very large, since they are given in substitutions per site and at least one of the sequences has a SNP at a given position. For instance, if you have two genomes of 1000bp but only 10 sites are polymorphic (i.e.&nbsp;SNPs, the other 900 are identical on both sequences), then their distance is 1/100 substitutions per site; however if you only look at the 10 SNPs then their distance is 1 substitution per site!</p>
<p>When you have several sequences and a tree it gets more complicated since maximum likelihood methods like IQTREE2 estimate the instantaneous rate matrix — from the HKY model, for instance. Which describes the probability of A becoming a C etc. and it must take into account the many constant sites in order to have a good estimate of the Prob(A-&gt;A) and so forth. If there are no constant sites the rate matrix will inflate Prob(A-&gt;C) and collapse Prob(A-&gt;A) and thus branch lengths will be inflated in a non-linear way for most models (otherwise we could just correct by dividing branch lengths by an amount, like 100 in example above). The topology may also be affected. The bias correction is done by replacing the unconditional probabilities Prob(A-&gt;C) by conditional ones Prob(A-&gt;C “given that” all constant sites were removed).</p>
<section id="removing-invariant-sites-and-telling-the-tree-inference-program-about-it" class="level2">
<h2 class="anchored" data-anchor-id="removing-invariant-sites-and-telling-the-tree-inference-program-about-it">Removing invariant sites and telling the tree inference program about it</h2>
<p>One solution for this problem is to calculate how many (constant) sites you are excluding and then adding this information to the phylogenetic inference software (the link above contains instructions on how to to this with IQTREE2; the same can be done for BEAST or RaxML).</p>
<p>We may be tempted to use an explicit “ascertainment bias correction” model, but we have to be careful since the ASC method implemented in iqtree2 assumes that we do not know how many constant sites we are excluding (see <a href="https://www.biorxiv.org/content/10.1101/186478v1">https://www.biorxiv.org/content/10.1101/186478v1</a>, and <a href="http://dx.doi.org/10.1093/sysbio/syv053">http://dx.doi.org/10.1093/sysbio/syv053</a> for details). Which is true for morphological data, but not in general for genomes, since we can count (<code>snp-sites -C</code>) the constant sites we are excluding. Therefore we have more precise estimation by informing iqtree2 the number of excluded sites (the option “-fconst”) as discussed in the link above <a href="https://bitsandbugs.org/2019/11/06/two-easy-ways-to-run-iq-tree-with-the-correct-number-of-constant-sites/">https://bitsandbugs.org/2019/11/06/two-easy-ways-to-run-iq-tree-with-the-correct-number-of-constant-sites/</a>. Notice that <code>-fconst</code> creates artificial columns in the alignment with the constant sites, and therefore is not compatible with <code>+ASC</code>. That is, if you call iqtree with both <code>+ASC</code> and <code>-fconst</code> then ASC will complain that there are constant sites in the alignment (which were added by <code>-fconst</code>!)</p>
<p>RaxML handles more ASC models: <a href="https://github.com/amkozlov/raxml-ng/wiki/Input-data#evolutionary-model">https://github.com/amkozlov/raxml-ng/wiki/Input-data#evolutionary-model</a>, where the <code>STAM</code> model is equivalent to <code>-fconst</code> and the <code>LEWIS</code> model is equiv to <code>+ASC</code> in IQTREE2.</p>
</section>
<section id="sometimes-its-better-not-to-do-anything" class="level2">
<h2 class="anchored" data-anchor-id="sometimes-its-better-not-to-do-anything">Sometimes it’s better not to do anything</h2>
<p>My suggestion in the discussion linked above and in general, is to leave the original data as is without trying to remove sites and correcting later. This is because if the sites are “truly” invariant then they won’t add to the computational time (as explained by Alexis Stamatakis in <a href="https://groups.google.com/g/raxml/c/JuwXlf576Sw">https://groups.google.com/g/raxml/c/JuwXlf576Sw</a> for instance). This is also what IQTREE2 does, as mentioned above: it adds four artificial columns to the alignment weighted by their counts. This is because most likelihood algorithms compress the alignments into distinct “patterns”, weighted by how many times we see them in the alignment.</p>
<p>There is an important difference, however, which is the inclusion of gaps and Ns in the “invariant” sites. For instance, take the following alignments (one line per sequence, spaces to ease visualisation):</p>
<pre class="config"><code>alignment 1
&gt;seq1 NNNNCCTCCC CGGTTCCAAC CTTCCAAAAA
&gt;seq2 NNNNCCTCCC CGGTTCCAAC CCCTTATAAA
&gt;seq3 ----CCTCCC CGGTTCCTTG GCCTTAACAA
&gt;seq4 ----CCTCCC CGGAAGGTTG GCCTTAAAGA
&gt;seq5 ----CCTCCT TTTAAGGTTG GCCTTAAAAT

alignment 2
&gt;seq1 AAAACCTCCC CGGTTCCAAC CTTCCAAAAA
&gt;seq2 NNNNCCTCCC CGGTTCCAAC CCCTTATAAA
&gt;seq3 ----CCTCCC CGGTTCCTTG GCCTTAACAA
&gt;seq4 ----CCTCCC CGGAAGGTTG GCCTTAAAGA
&gt;seq5 ----CCTCCT TTTAAGGTTG GCCTTAAAAT

alignment 3
&gt;seq1 NNNNCCTCCC CGGTTCCAAC CTTCCAAAAA
&gt;seq2 AAAACCTCCC CGGTTCCAAC CCCTTATAAA
&gt;seq3 AAAACCTCCC CGGTTCCTTG GCCTTAACAA
&gt;seq4 ----CCTCCC CGGAAGGTTG GCCTTAAAGA
&gt;seq5 ----CCTCCT TTTAAGGTTG GCCTTAAAAT</code></pre>
<p>The only difference between the alignments are the first four sites: in alignment 1 we only have gaps and Ns. In alignments 2 and 3 we have <code>AAAA</code> in a few samples, instead. <strong>All 3 alignments are identical after removal of constant sites</strong> with <code>snp-sites</code>, since the first four sites do not have SNPs! Which is what I meant in the discussion linked above when I said</p>
<blockquote class="blockquote">
<p>One thing to consider is that a column composed of “AAAA” is distinct from one composed of “AANN” or “AA-A”, although all 3 of them will be removed by snp-sites -c.</p>
</blockquote>
<p>If we fix the topology and the branch lengths (<code>iqtree2 -s ${file}.aln -te fixed.tre -blfix -m JC</code>) then the log-likelihood of the three alignments will be -115.559 for alignment 1, -121.104 for alignment 2, and -122.123 for alignment 3. So the likelihood is different for the three alignments (I’m using the Jukes-Cantor model to avoid handling extra parameters). Using <code>snp-sites</code> to remove the invariant sites and to count the frequencies would not fix the problem since alignments 2 and 3 have the same number of “invariant sites”: <code>5,4,0,1</code>. To make a long story short, I ran the 3 alignments under a fixed tree (topology and branch lengths) as above and asking IQTREE2 to optimise the branch lengths (<code>iqtree2 -s ${i} -te fixed.tre --prefix ${i%aln}best_length -m JC</code>). I also used only the constant sites with the <code>snp-sites</code> correction, as in</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">snp-sites</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-c</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$i</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${i</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>aln<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span>snpsites</span>
<span id="cb2-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">iqtree2</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-fconst</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">snp-sites</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-C</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${i})</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-s</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${i</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>aln<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span>snpsites <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-m</span> JC <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--prefix</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${i</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span>aln<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span>const</span></code></pre></div></div>
<p>We have the results as below, where we can see that not only the likelihoods, but the tree branch lengths are different:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>iqtree file</th>
<th>log-likelihood</th>
<th>ML tree</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>alignment1.aln</td>
<td>-115.559</td>
<td>(seq1:0.1886473604,seq2:0.0303274053,(seq3:0.0284331913,(seq4:0.0258689619,seq5:0.2463693196):0.2138883204):0.2087029810);</td>
</tr>
<tr class="even">
<td>alignment1.best_length</td>
<td>-115.559</td>
<td>(seq1:0.1886473604,seq2:0.0303274053,(seq3:0.0284331913,(seq4:0.0258689619,seq5:0.2463693196):0.2138883204):0.2087029810);</td>
</tr>
<tr class="odd">
<td>alignment1.const</td>
<td>-115.559</td>
<td>(seq1:0.1886475517,seq2:0.0303274177,(seq3:0.0284339867,(seq4:0.0258696236,seq5:0.2463695763):0.2138875505):0.2087022795);</td>
</tr>
<tr class="even">
<td>alignment2.aln</td>
<td>-121.104</td>
<td>(seq1:0.1886473604,seq2:0.0303274053,(seq3:0.0284331913,(seq4:0.0258689619,seq5:0.2463693196):0.2138883204):0.2087029810);</td>
</tr>
<tr class="odd">
<td>alignment2.best_length</td>
<td>-121.104</td>
<td>(seq1:0.1886473604,seq2:0.0303274053,(seq3:0.0284331913,(seq4:0.0258689619,seq5:0.2463693196):0.2138883204):0.2087029810);</td>
</tr>
<tr class="even">
<td>alignment2.const</td>
<td>-124.433</td>
<td>(seq1:0.1577276882,seq2:0.0281664193,(seq3:0.0272139809,(seq4:0.0254304079,seq5:0.2041776675):0.1736347105):0.1705027642);</td>
</tr>
<tr class="odd">
<td>alignment3.aln</td>
<td>-122.123</td>
<td>(seq1:0.1886473604,seq2:0.0303274053,(seq3:0.0284331913,(seq4:0.0258689619,seq5:0.2463693196):0.2138883204):0.2087029810);</td>
</tr>
<tr class="even">
<td>alignment3.best_length</td>
<td>-122.045</td>
<td>(seq1:0.1888748916,seq2:0.0261918048,(seq3:0.0246320132,(seq4:0.0257728057,seq5:0.2464608488):0.2140593199):0.1757918053);</td>
</tr>
<tr class="odd">
<td>alignment3.const</td>
<td>-124.433</td>
<td>(seq1:0.1577274163,seq2:0.0281664193,(seq3:0.0272140466,(seq4:0.0254297568,seq5:0.2041783024):0.1736349260):0.1705029865);</td>
</tr>
</tbody>
</table>
<p>Notice that all trees are identical for <code>alignment*.aln</code> since we fix the tree and branch lengths. Also, alignments 2 and 3 have practically identical trees after the SNP-sites correction (<code>const</code> trees), the difference in branch lengths is negligible due to stochastic effects. However the optimal branch lengths are quite distinct under a full optimisation (<code>best_length</code> trees). This is because the Prob(A-&gt;N) and Prob(A-&gt;A) are not the same, which will affect the estimation of model parameters and branch lengths.</p>
<p>So it boils down to the amount of gaps and uncertainty in our data set: on one extreme, we can assume that all constant sites which were removed were <em>bona fide</em> ACGT only; on the other hand, removal of “constant” sites may lump into the same category truly invariant sites with regions of high uncertainty. In the former case, we don’t need to remove them since most software (BEAST, IQTREE, RaxML) can easily merge constant sites into a few patterns with no detriment of speed. In the latter case, the patterns of gaps and ambiguous bases within an alignment column can inform the model and branch lengths and thus should not be removed. (Notice that in this case the speed will suffer more since every pattern of Ns and indels must be calculated separately).</p>
<p>Thus if you use <code>snp-sites</code> to remove constant sites and you observe a fantastic speedup, you should worry that it removed more than truly constant sites. Because, as we saw above, it does not consider gaps and Ns. To recap:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Alignment</span> A with truly, bona fide constant sites:</span>
<span id="cb3-2"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq1 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">N-AC</span></span>
<span id="cb3-3"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq2 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">N-AC</span></span>
<span id="cb3-4"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq3 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">--AC</span></span>
<span id="cb3-5"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq4 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">--AC</span></span>
<span id="cb3-6"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq5 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">--AC</span></span>
<span id="cb3-7"></span>
<span id="cb3-8"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Alignment</span> B with no true constant sites: they look constant <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">no</span> SNPs!<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">but</span> have distinct phylogenetic signal:</span>
<span id="cb3-9"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq1 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AAAA----</span></span>
<span id="cb3-10"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq2 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">N-A---AA</span></span>
<span id="cb3-11"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq3 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">--AA---A</span></span>
<span id="cb3-12"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq4 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">--A-A---</span></span>
<span id="cb3-13"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>seq5 <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">----AA--</span></span></code></pre></div></div>
<p>The sites from alignment B represent each a distinct pattern, and are not merged by the phylogenetic software. They contain unique phylogenetic information. However they would all be excluded from a SNPs-only alignment, leading to a speed up.</p>
</section>
<section id="what-to-do-then" class="level2">
<h2 class="anchored" data-anchor-id="what-to-do-then">What to do then?</h2>
<p>So maybe your data set has more gaps and uncertainty than you would hope. Most real data sets look much more like alignment B than alignment A. What I usually do is to first estimate the tree with SNPs only, and then use this tree as an initial (or fixed) topology for the whole data set, where branch lengths and model parameters can be optimised. This is because the SNPs are good enough for estimating the topology —tree branching, without branch lengths— , which is the most time-consuming part.</p>
<p>I also avoid at all costs using the standard generation of parsimony trees in IQTREE, since it does not use the site patterns (<a href="https://groups.google.com/g/iqtree/c/vjyLDpc1e1Q/m/68svHwSMAQAJ">https://groups.google.com/g/iqtree/c/vjyLDpc1e1Q/m/68svHwSMAQAJ</a>) and can be extremely slow. Another approach might be to remove sites which look constant (i.e.&nbsp;no SNPs) and with high levels of uncertainty/gaps. This could help cases where the tree inference is slow even under a fixed topology.</p>
<p>All files and script used are available <a href="20220816.blogentry.txz">as an XZ compressed tar file</a>.</p>


</section>

 ]]></description>
  <category>phylogenetics</category>
  <guid>https://leomrtns.github.io/posts/invariant-sites/</guid>
  <pubDate>Tue, 16 Aug 2022 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/design/posts/invariant-sites.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>Hash functions and pseudo-random number generation</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/random-hash/</link>
  <description><![CDATA[ 




<section id="hash-functions-and-pseudo-random-number-generation" class="level1">
<h1>005 Hash functions and pseudo-random number generation</h1>
<p>This notebook uses the low-level phylogenetic library <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib">biomcmc-lib</a> (commit <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib/commit/da29c5c9f76b5ee8d66f489fb7800abccf486ec2">da29c5c</a>).</p>
<p>Here I show two small tests, one with generation of an initial set of random numbers, and another on <code>popcount()</code> speeds.</p>
<section id="testing-the-generation-of-a-deterministic-array-of-random-numbers" class="level2">
<h2 class="anchored" data-anchor-id="testing-the-generation-of-a-deterministic-array-of-random-numbers">testing the generation of a deterministic array of random numbers</h2>
<p>In <code>biomcmc-lib</code> there are a few vectors with “random numbers” (some actually from <a href="https://www.random.org/">random.org</a>, some random prime numbers used in hash functions, etc.). The function <code>biomcmc_salt_vector32_from_spice_table()</code> will populate a vector with these number in an order specified by the particular <code>seed[4]</code> values.</p>
<div id="random-hash-3" class="cell" data-execution_count="2">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/biomcmc-lib/lib</span></span>
<span id="cb1-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build.191216/biomcmc-lib/lib</span></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build.191216/biomcmc-lib/lib/.libs/libbiomcmc.a</span></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags:-lm</span></span>
<span id="cb1-5"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;biomcmc.h&gt;</span></span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span></span>
<span id="cb1-8">main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> argc<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span>argv<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-9"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-10">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-11">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> seeds<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]={</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> vec<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> nvec<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">34</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-12">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-13">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">size_t</span> size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sizeof</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>vec<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-14">    </span>
<span id="cb1-15">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-16">        seeds<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-17">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%8x</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>seeds<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb1-18">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"original seeds</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-19">        biomcmc_salt_vector32_from_spice_table <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>vec<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> nvec<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> seeds<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-20">        printf<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">seed: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%u\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-21">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//for (j=0; j&lt;nvec;j++) {printf("%12u ", vec[j]); if (!((j+1)%8)) printf ("\n"); }</span></span>
<span id="cb1-22">        c <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> vec<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-23">        size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sizeof</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>vec<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-24">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++,</span> size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">--)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%4x</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>c<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(!((</span>size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)%</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-25">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-26">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-27">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%8x</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>biomcmc_hashint_salted <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">));</span></span>
<span id="cb1-28">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;&lt; for hash </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%u\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-29">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-30">        </span>
<span id="cb1-31">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> EXIT_SUCCESS<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-32"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>       0        1        2        3 original seeds

seed: 0
  15   da   f0   20   87   60   7f   24   ff   f0   9c   e2   87   7e    1    0 
  ff   ff   4f   46   ff   ff   27   23   d8   9a   b1   55   99    2   99   d7 
  85    5    c   d0   a6    f   a6   c4   9a   99   99   99   52   5a    7   8c 
  ae   11   92   3d   8f   e7    2    0   1d   60    0    0   1d   60    0    0 
  ed   6e   1c    1   fb   a5   71    7    9   f8   e6   5e   7b    a   9f    7 
  ff   ff   4b   59   ff   ff   f3   32   d7    5   f2   28   b7   27   3d   c8 
  fa   9e   6e   d6   4f   64   3f   6e   5c   52   ba   39   34   f8   d7   3a 
  2c   fc   1f   a0   46   7e    9    0   71   f7    2    0   1d   60    0    0 
       1 b621b33c 9cc8151d 5ab560c5 original seeds

seed: 1
  55   93   67   35   87   60   7f   24   2e   d1   9d   e2   7b   b3   31   35 
  ff   ff   7f   4c   ff   ff   da   33   fa   2f   b9   34   4d   26   48   46 
  fa   9e   6e   d6    e   8d   25   79   9f   da   f7   50   ee   a6   50   e1 
  e1   36   ce   6d   68   19   10    0    2   90   fd   2d   55   bd    4    0 
  89    a   50   1a    5   9e   41   2e   63   d1   e7   5e   eb   25   d4   19 
  ff   ff   92   6c   ff   ff   b9   30   c2   98   28   91   66   a9   5a   6f 
  fa   9e   6e   d6   30   6c   db   ea   99   3d   cc   5a   cf   a6   fc   ed 
  c0   13   ac   84   6a    0    9    0   a2   47   42   1a   f8   2b    1    0 
c0a9496a 27922c9d c6793575 87d06fbe &lt;&lt; for hash 0
6b4ed927 b48681b6 e267b84c 4f6e0e9c &lt;&lt; for hash 1
caa3caa3 12d60bf6 25ac1fe5 3882835c &lt;&lt; for hash 2
    d0dc   2a6ee1   55234f   7f181c &lt;&lt; for hash 3
deb66b58 deb66ab9 deb66a9a deb66afb &lt;&lt; for hash 4
2ba588a6 2ba58337 2ba51840 2ba510d1 &lt;&lt; for hash 5
acefdd39 ec26e4d2 75fe3d8c ce4259f1 &lt;&lt; for hash 6
4636b9c9 62baf5a0 ff4d1170 2bf062cf &lt;&lt; for hash 7
b7255c83 a63ec54b 2a674713 c0186ef5 &lt;&lt; for hash 8
ad92d5f0 8e953d2f 8f005635 cb773d1b &lt;&lt; for hash 9
e6546b64 e6546b64 e6546b64 e6546b64 &lt;&lt; for hash 10
c0a9496a 27922c9d c6793575 87d06fbe &lt;&lt; for hash 11
c0a9496a 27922c9d c6793575 87d06fbe &lt;&lt; for hash 12
c0a9496a 27922c9d c6793575 87d06fbe &lt;&lt; for hash 13
c0a9496a 27922c9d c6793575 87d06fbe &lt;&lt; for hash 14</code></pre>
</div>
</div>
</section>
<section id="counting-the-number-of-active-bits-pop_count" class="level2">
<h2 class="anchored" data-anchor-id="counting-the-number-of-active-bits-pop_count">Counting the number of active bits (<code>pop_count()</code>)</h2>
<p>I have recently implemented a few faster versions of 64 bits <em>popcounts</em>, and below I compare them with my first implementation — in the context of “bipartitions”, which are vectors of bitstrings.</p>
<p>First I check if they are calculating the right thing (number of “ones” in a vector of 64 bit integers). And then I see which is faster. I expected <code>pop0()</code> to be slowest (it is linear on the number of active bits), and the others to be similar. Which is what we observe. The one I’ve chosen to be the new “default” on <code>biomcmc-lib</code> is <code>pop1()</code>, which I’ve seen in <a href="https://github.com/ruanjue/wtdbg">Jue Ruan’s RedBean</a> and also in <a href="https://github.com/KChen-lab/novoBreak">novoBreak</a>. The previous default was the <code>i &amp;= i -1</code> trick described in K &amp; R. The other two are from <a href="http://www.dalkescientific.com/writings/diary/archive/2008/07/03/hakmem_and_other_popcounts.html">Andrew Dalke</a>.</p>
<div id="random-hash-5" class="cell" data-execution_count="25">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/biomcmc-lib/lib</span></span>
<span id="cb3-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build.191216/biomcmc-lib/lib</span></span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build.191216/biomcmc-lib/lib/.libs/libbiomcmc.a</span></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags:-lm</span></span>
<span id="cb3-5"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;biomcmc.h&gt;</span></span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span></span>
<span id="cb3-8">main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> argc<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span>argv<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-9"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-10">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> n_iter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10000</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-11">    clock_t time0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-12">    bipartition bp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> new_bipartition <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">70</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-13">    biomcmc_random_number_init <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">ULL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-14">    printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"STEP 1 : check that all pop counts are correct</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-15">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-16">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>ints<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-17">            bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>bs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> biomcmc_rng_get <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb3-18">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-19">        bipartition_print_to_stdout <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-20">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t%4d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%4d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%4d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%4d\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb3-21">                bipartition_count_n_ones_pop0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">),</span></span>
<span id="cb3-22">                bipartition_count_n_ones_pop1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">),</span></span>
<span id="cb3-23">                bipartition_count_n_ones_pop2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">),</span></span>
<span id="cb3-24">                bipartition_count_n_ones_pop3<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">));</span></span>
<span id="cb3-25">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-26">    del_bipartition <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> bp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> new_bipartition <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">50000</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// bigger bipartition</span></span>
<span id="cb3-27">    printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"STEP 2: time pop counts (pop1 is default, and we call through a wrapper to discount this overhead)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-28">    time0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> clock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb3-29">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> n_iter<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-30">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>ints<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>bs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> biomcmc_rng_get <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb3-31">        bipartition_count_n_ones <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-32">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-33">    time1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> clock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span> fprintf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>stderr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pop1: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%.8f</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> secs</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)(</span>time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>time0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)/(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>CLOCKS_PER_SEC<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-34">    time0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-35">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> n_iter<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-36">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>ints<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>bs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> biomcmc_rng_get <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb3-37">        bipartition_count_n_ones_pop0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-38">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-39">    time1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> clock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span> fprintf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>stderr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pop0: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%.8f</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> secs</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)(</span>time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>time0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)/(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>CLOCKS_PER_SEC<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-40">    time0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-41">    </span>
<span id="cb3-42">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> n_iter<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-43">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>ints<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>bs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> biomcmc_rng_get <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb3-44">        bipartition_count_n_ones_pop2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-45">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-46">    time1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> clock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span> fprintf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>stderr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pop2: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%.8f</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> secs</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)(</span>time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>time0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)/(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>CLOCKS_PER_SEC<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-47">    time0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-48">    </span>
<span id="cb3-49">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> n_iter<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-50">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>ints<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>bs<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> biomcmc_rng_get <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb3-51">        bipartition_count_n_ones_pop3 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-52">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-53">    time1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> clock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span> fprintf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>stderr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pop3: </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%.8f</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> secs</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)(</span>time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>time0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)/(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span>CLOCKS_PER_SEC<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-54">    time0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-55">    </span>
<span id="cb3-56">    del_bipartition <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>bp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-57">    biomcmc_random_number_finalize <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb3-58">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> EXIT_SUCCESS<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-59"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>STEP 1 : check that all pop counts are correct
1111101010010110110000001011111000010001001000010111110100110101.001010[0]    34   34   34   34
1011001001011101101010010000011101001100100001111101011110110010.011010[34]       36   36   36   36
0000101001000100011000111111100000011010001001000110110100001110.011010[36]       29   29   29   29
1010001100100100100001000000010101111111101000011110111110001100.100100[29]       32   32   32   32
STEP 2: time pop counts (pop1 is default, and we call through a wrapper to discount this overhead)</code></pre>
</div>
<div class="cell-output cell-output-stderr">
<pre><code>pop1: 0.19077800 secs
pop0: 0.37243400 secs
pop2: 0.20049800 secs
pop3: 0.19488300 secs</code></pre>
</div>
</div>


</section>
</section>

 ]]></description>
  <category>C</category>
  <guid>https://leomrtns.github.io/posts/random-hash/</guid>
  <pubDate>Fri, 01 Apr 2022 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/design/posts/random-hash.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>kalign3 as a library and colour printing</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/kalign3/</link>
  <description><![CDATA[ 




<section id="kalign-and-colour-printing" class="level1">
<h1>004 kalign and colour printing</h1>
<section id="incorporating-kalign3-as-a-library" class="level2">
<h2 class="anchored" data-anchor-id="incorporating-kalign3-as-a-library">incorporating kalign3 as a library</h2>
<p>This notebook uses the low-level phylogenetic library <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib">biomcmc-lib</a> (commit <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib/commit/5975331ef88d1c4ec9aef9599fb6348905d289c7">5975331</a>).</p>
<p>Recently I (re-)discovered the <a href="https://github.com/TimoLassmann/kalign">kalign</a> software for multiple sequence alignment by Timo Lassmann, and was happily surprised with the code simplicity and a liberal license (GPL-3.0-or-later).</p>
<p>Therefore I decided to incorporate its code into a library, that I can access using a <code>char_vector::</code> from the <code>biomcmc-lib</code> library. Currently I am working on a derived library/software called “cumaru” (still private), with a modified version of <code>kalign</code> algorithms.</p>
<section id="autotools" class="level3">
<h3 class="anchored" data-anchor-id="autotools">Autotools</h3>
<p>First, a digresssion on the configuration aspects of <code>cumaru</code> (or another software importing these libraries).</p>
<p>This is needed by <code>configure.ac</code> as well as the described files, in order for <code>kalign3</code> to use the AVX extensions.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># M4 macros for checking of CPU features from kalign3</span></span>
<span id="cb1-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">m4_include</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[m4/ax_gcc_x86_avx_xgetbv.m4]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb1-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">m4_include</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[m4/ax_gcc_x86_cpuid.m4]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb1-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">m4_include</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[m4/ax_check_compile_flag.m4]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb1-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">m4_include</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[m4/ax_ext.m4]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb1-6"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">m4_include</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[m4/ax_openmp.m4]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb1-7"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AX_EXT</span></span></code></pre></div></div>
<p>For importing <code>biomcmc-lib</code>, you have two options: 1. downloading the (upstream) software through github, with option <code>--recursive</code> (default for final users of software). This will download <code>biomcmc-lib</code> into <code>${srcdir}/submodules/biomcmc-lib</code>. 2. download <code>biomcmc-lib</code> independently into <code>${srcdir}/biomcmc-lib</code> or somewhere else and then link it to there. This is how I do it, since I use the same directory for several projects that rely on it.</p>
<p>If you opted for (1) above (i.e.&nbsp;you just cloned the repository recursively), then the configuration option below will create a link as in option (2).</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AC_CHECK_FILE</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${srcdir}</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">/biomcmc-lib],[],[ln</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-s</span> submodules/biomcmc-lib <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${srcdir}</span>/biomcmc-lib]<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb2-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AC_CHECK_FILE</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${srcdir}</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">/biomcmc-lib/configure.ac],[],</span> [AC_MSG_ERROR<span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"biomcmc-lib submodule missing, please git clone --recursive or link by hand to location of source code"</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb2-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">dnl</span> Call biomcmc-lib ./configure script recursively.</span>
<span id="cb2-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AC_CONFIG_SUBDIRS</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[biomcmc-lib]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb2-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AC_SUBST</span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[BIOMCMCLIB],</span> <span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">[</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">biomcmc</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">-</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">lib</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span></code></pre></div></div>
<p>Then the file <code>kalign/Makefile.am</code> has the following information, to create a static local library. This library will encapsulate <code>biomcmc-lib</code> and will be available to the main software as <code>libalign.la</code>:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AM_CPPFLAGS</span> = <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">GTKDEPS_CFLAGS</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span>  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-I</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">srcdir</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span>/../@BIOMCMCLIB@/lib  @OPENMP_CPPFLAGS@ @ZLIB_LIBS@</span>
<span id="cb3-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AM_CFLAGS</span> = @SIMD_FLAGS@ @AM_CFLAGS@  @OPENMP_CFLAGS@</span>
<span id="cb3-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">LDADD</span> = <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">GTKDEPS_LIBS</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span> @ZLIB_LIBS@ ../biomcmc-lib/lib/libbiomcmc.la  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AM_LDFLAGS</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-4"></span>
<span id="cb3-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">common_headers</span> = kalign.h <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-6">tldevel.h rng.h global.h <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-7">alignment_parameters.h <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-8">bisectingKmeans.h <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-9">sequence_distance.h <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-10">alignment.h bpm.h</span>
<span id="cb3-11"></span>
<span id="cb3-12"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">common_src</span> = run_kalign.c <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-13">tldevel.c rng.c <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-14">alignment_parameters.c <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-15">bisectingKmeans.c <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-16">sequence_distance.c <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-17">alignment.c bpm.c</span>
<span id="cb3-18"></span>
<span id="cb3-19"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">noinst_LTLIBRARIES</span> = libkalign.la   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">## noinst_LT: linked statically (not installed globally)</span></span>
<span id="cb3-20"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">libkalign_la_SOURCES</span> = config.h <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">common_headers</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">common_src</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span> </span></code></pre></div></div>
<p>And the <code>src/Makefile.am</code> (with the final software) can be something like:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AM_CPPFLAGS</span> = <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">GTKDEPS_CFLAGS</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-I</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">srcdir</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span>/../kalign <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-I</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">srcdir</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span>/../@BIOMCMCLIB@/lib @OPENMP_CPPFLAGS@  @ZLIB_LIBS@ </span>
<span id="cb4-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AM_CFLAGS</span> = @AM_CFLAGS@ @OPENMP_CFLAGS@ @CHECK_CFLAGS@</span>
<span id="cb4-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">LDADD</span> = <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">GTKDEPS_LIBS</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span> @CHECK_LIBS@  ../kalign/libkalign.la ../biomcmc-lib/lib/libbiomcmc.la @ZLIB_LIBS@  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">AM_LDFLAGS</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb4-4"></span>
<span id="cb4-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">bin_PROGRAMS</span> = cumaru </span>
<span id="cb4-6"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">cumaru_SOURCES</span> = main.c kseq.h</span>
<span id="cb4-7"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">cumaru_LDADD</span> = <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">LDADD</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span></code></pre></div></div>
<p>Notice that we need to include the path to the local <code>biomcmc-lib</code> as well, since it is also statically linked.</p>
<p>The code below performs multiple sequence alignment from hand-fed sequences (in practice, fasta reading usually come from <code>kseq.h</code>).</p>
<div id="kalign3-2" class="cell" data-execution_count="18">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/biomcmc-lib/lib</span></span>
<span id="cb5-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build.191216/biomcmc-lib/lib</span></span>
<span id="cb5-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/leomrtns.cumaru/kalign</span></span>
<span id="cb5-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build.191216/kalign</span></span>
<span id="cb5-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build.191216/kalign/.libs/libkalign.a</span></span>
<span id="cb5-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build.191216/biomcmc-lib/lib/.libs/libbiomcmc.a</span></span>
<span id="cb5-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags:-lm</span></span>
<span id="cb5-8"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;kalign.h&gt;</span></span>
<span id="cb5-9"></span>
<span id="cb5-10"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span></span>
<span id="cb5-11">main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> argc<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span>argv<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb5-12"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb5-13">  <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-14">  clock_t time0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-15">  char_vector seqname <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> new_char_vector <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-16">  char_vector dna <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> new_char_vector <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-17">  char_vector align <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> NULL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-18"></span>
<span id="cb5-19">  time0 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> clock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span></span>
<span id="cb5-20"></span>
<span id="cb5-21">  char_vector_add_string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dna<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ATCGAAAGAATTAGGCTTAAGCTAAAAGCTTATGACCACAGAGTTCTAGACCGTACAGAT"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-22">  char_vector_add_string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>seqname<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Campy"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-23">  char_vector_add_string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dna<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AGAAAGAATTAGGCTTAAGCTAAGCTTATGACCACAGAGTTCTAGACCGTACAGTT"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-24">  char_vector_add_string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>seqname<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Vibrio"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-25">  char_vector_add_string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dna<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ATGGAAAGAATTAGGCTTAAGCCGGAGCTTATGACCACAGAGTTCTAGAGCGTACAGTT"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-26">  char_vector_add_string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>seqname<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Strepto"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-27">  char_vector_add_string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dna<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ATGGAAAGAATTAGGCTTAAGCTAAAAGCTTATGACTTCATTCTGTACAGTT"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-28">  char_vector_add_string <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>seqname<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Staph"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-29"></span>
<span id="cb5-30">  align <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> kalign3_from_char_vector <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dna<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-31">  time1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> clock <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span> </span>
<span id="cb5-32">  fprintf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>stderr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"finished in  </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%lf</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> secs</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)(</span>time1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>time0<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)/(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)(</span>CLOCKS_PER_SEC<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">));</span> </span>
<span id="cb5-33">  fflush<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>stderr<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-34"></span>
<span id="cb5-35">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> align<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>nstrings<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&gt;</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%s\n%s\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> seqname<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>string<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> align<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>string<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb5-36"></span>
<span id="cb5-37">  del_char_vector <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dna<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-38">  del_char_vector <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>align<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-39">  del_char_vector <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>seqname<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-40">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> EXIT_SUCCESS<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-41"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stderr">
<pre><code>finished in  0.000583 secs</code></pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>&gt;Campy
ATCGAAAGAATTAGGCTTAAGCTAAAAGCTTATGACCACAGAGTTCTAGACCGTACAGAT
&gt;Vibrio
AG--AAAGAATTAGGCTTAAGCTAA--GCTTATGACCACAGAGTTCTAGACCGTACAGTT
&gt;Strepto
ATGGAAAGAATTAGGCTTAAGCCGG-AGCTTATGACCACAGAGTTCTAGAGCGTACAGTT
&gt;Staph
ATGGAAAGAATTAGGCTTAAGCTAAAAGCTTATGACTTCA---TTCT-----GTACAGTT</code></pre>
</div>
</div>
</section>
</section>
<section id="printing-colours" class="level2">
<h2 class="anchored" data-anchor-id="printing-colours">Printing colours</h2>
<p>This week I’ve been refactoring the random and hash modules of <code>biomcmc-lib</code>. I am also adding user-friendly functionality — linux fortunes and coloured printing. Here we can see my test with colours in <code>printf()</code>.</p>
<div id="kalign3-4" class="cell" data-execution_count="26">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb8-1"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;stdio.h&gt;</span></span>
<span id="cb8-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>mytext<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"this has ` , $ percent </span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">\%</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> and ' while"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"so  </span><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">\%</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">d ____^H^H^H^Hmany"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb8-3"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> col_reset<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-4"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>rownames<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"regular"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"underline"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"highbckgrnd"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"hightext"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"boldhightxt"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb8-5"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>prt_col<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]={</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 0-black   1-red   2-grn   3-yel   4-blu   5-mag   6-cyn   7-white</span></span>
<span id="cb8-6">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;30m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;31m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;32m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;33m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;34m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;35m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;36m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;37m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 0 regular text</span></span>
<span id="cb8-7">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;30m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;31m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;32m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;33m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;34m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;35m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;36m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;37m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 1 regular bold text</span></span>
<span id="cb8-8">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[4;30m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[4;31m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[4;32m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[4;33m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[4;34m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[4;35m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[4;36m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[4;37m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 2 regular underline text</span></span>
<span id="cb8-9">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[40m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[41m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[42m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[43m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[44m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[45m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[46m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[47m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span>    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 3 regular background</span></span>
<span id="cb8-10">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;100m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;101m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;102m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;103m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;104m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;105m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;106m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;107m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 4 high intensity underground</span></span>
<span id="cb8-11">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;90m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;91m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;92m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;93m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;94m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;95m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;96m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[0;97m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 5 high intensity text </span></span>
<span id="cb8-12">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;90m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;91m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;92m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;93m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;94m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;95m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;96m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\e</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">[1;97m"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span>   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 6 bold high intensity text</span></span>
<span id="cb8-13"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb8-14"></span>
<span id="cb8-15"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> main<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">()</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-16">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-17">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-18">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n%d\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-19">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%15s</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> : </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%s</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">&gt;</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%s</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">&lt;&gt;</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%s</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">&lt;</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%s\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>rownames<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span>prt_col<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span>mytext<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> mytext<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> col_reset<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-20">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb8-21">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// test with marsaglia constants (should print prime numbers)</span></span>
<span id="cb8-22">    printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%5d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%5d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%5d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18000</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18000</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18030</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-23"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<div class="ansi-escaped-output">
<pre>0

        regular : <span class="ansi-black-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

           bold : <span class="ansi-black-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

      underline : <span style="text-decoration:underline" class="ansi-black-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

     background : <span class="ansi-black-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    highbckgrnd : <span class="ansi-bright-black-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

       hightext : <span class="ansi-bright-black-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    boldhightxt : <span class="ansi-bright-black-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>



1

        regular : <span class="ansi-red-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

           bold : <span class="ansi-red-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

      underline : <span style="text-decoration:underline" class="ansi-red-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

     background : <span class="ansi-red-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    highbckgrnd : <span class="ansi-bright-red-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

       hightext : <span class="ansi-bright-red-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    boldhightxt : <span class="ansi-bright-red-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>



2

        regular : <span class="ansi-green-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

           bold : <span class="ansi-green-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

      underline : <span style="text-decoration:underline" class="ansi-green-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

     background : <span class="ansi-green-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    highbckgrnd : <span class="ansi-bright-green-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

       hightext : <span class="ansi-bright-green-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    boldhightxt : <span class="ansi-bright-green-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>



3

        regular : <span class="ansi-yellow-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

           bold : <span class="ansi-yellow-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

      underline : <span style="text-decoration:underline" class="ansi-yellow-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

     background : <span class="ansi-yellow-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    highbckgrnd : <span class="ansi-bright-yellow-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

       hightext : <span class="ansi-bright-yellow-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    boldhightxt : <span class="ansi-bright-yellow-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>



4

        regular : <span class="ansi-blue-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

           bold : <span class="ansi-blue-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

      underline : <span style="text-decoration:underline" class="ansi-blue-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

     background : <span class="ansi-blue-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    highbckgrnd : <span class="ansi-bright-blue-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

       hightext : <span class="ansi-bright-blue-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    boldhightxt : <span class="ansi-bright-blue-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>



5

        regular : <span class="ansi-magenta-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

           bold : <span class="ansi-magenta-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

      underline : <span style="text-decoration:underline" class="ansi-magenta-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

     background : <span class="ansi-magenta-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    highbckgrnd : <span class="ansi-bright-magenta-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

       hightext : <span class="ansi-bright-magenta-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    boldhightxt : <span class="ansi-bright-magenta-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>



6

        regular : <span class="ansi-cyan-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

           bold : <span class="ansi-cyan-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

      underline : <span style="text-decoration:underline" class="ansi-cyan-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

     background : <span class="ansi-cyan-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    highbckgrnd : <span class="ansi-bright-cyan-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

       hightext : <span class="ansi-bright-cyan-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    boldhightxt : <span class="ansi-bright-cyan-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>



7

        regular : <span class="ansi-white-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

           bold : <span class="ansi-white-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

      underline : <span style="text-decoration:underline" class="ansi-white-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

     background : <span class="ansi-white-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    highbckgrnd : <span class="ansi-bright-white-bg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

       hightext : <span class="ansi-bright-white-fg">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

    boldhightxt : <span class="ansi-bright-white-fg ansi-bold">&gt;this has ` , $ percent % and ' while&lt;&gt;so  %d ____^H^H^H^Hmany&lt;</span>

1179647999 589823999 1181614079</pre>
</div>
</div>
</div>
<p>And this is the same output in my terminal (black background): <img src="https://leomrtns.github.io/posts/kalign3/note_images/191213.colourprint.png" align="center" width="500"></p>


</section>
</section>

 ]]></description>
  <category>C</category>
  <guid>https://leomrtns.github.io/posts/kalign3/</guid>
  <pubDate>Tue, 01 Mar 2022 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/design/posts/kalign3.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>Minimal example of a rolling hash</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/rolling-hash/</link>
  <description><![CDATA[ 




<section id="minimal-example-of-a-rolling-hash" class="level1">
<h1>003 Minimal example of a rolling hash</h1>
<p>This notebook uses the low-level phylogenetic library <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib">biomcmc-lib</a> (commit <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib/commit/5975331ef88d1c4ec9aef9599fb6348905d289c7">5975331</a>).</p>
<p>The rolling hash (or expoential hash) is a technique to slide through a sequence while updating its hash value using only information from the current hash and the next value. One of the most popular algorithms is the Rabin-Karp algorithm. Below I start with the imnplementation in <a href="http://dx.doi.org/10.1038/s41467-018-04964-5">linclust/MMseqs2</a></p>
<p>In DNA context, each base is represented by a random number. In MMseqs they work with a reduced amino acid alphabet of 13 groups</p>
<section id="prototype" class="level2">
<h2 class="anchored" data-anchor-id="prototype">Prototype</h2>
<p>Here I describe a prototype (future capability of the library), not implemented yet. I am testing the rolling hash function but also shorter types <code>uint8_t</code> etc. The idea is that each of the testing functionalities will be incorporated into <code>biomcmc-lib</code>.</p>
<p>Below is a working version that follows closely <code>minclust</code>.</p>
<div id="rolling-hash-2" class="cell" data-execution_count="16">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags:-lm</span></span>
<span id="cb1-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/biomcmc-lib/lib</span></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib</span></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib/.libs/libbiomcmc.a</span></span>
<span id="cb1-5"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;biomcmc.h&gt;</span></span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint16_t</span> RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x4567</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x23c6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x9869</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x4873</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xdc51</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5cff</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x944a</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x58ec</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-8">                           <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1f29</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x7ccd</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x58ba</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xd7ab</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x41f2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1efb</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xa9e3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xe146</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb1-9">                           <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x007c</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x62c2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x0854</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x27f8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x231b</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// 16 bit random numbers</span></span>
<span id="cb1-10"></span>
<span id="cb1-11"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#define RoL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span></span>
<span id="cb1-12"></span>
<span id="cb1-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Transform each letter x[i] to a fixed random number RAND[x[i]] to ensure instantaneous mixing into the 16 bits</span></span>
<span id="cb1-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Do XOR with RAND[x[i]] and 5-bit rotate left for each i from 1 to k</span></span>
<span id="cb1-15"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> circ_hash <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">){</span></span>
<span id="cb1-16">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint16_t</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-17">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span>                  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// XOR h and ki</span></span>
<span id="cb1-18">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">){</span></span>
<span id="cb1-19">        h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-20">        h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span>                   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// XOR h and ki</span></span>
<span id="cb1-21">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-22">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-23"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-24"></span>
<span id="cb1-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Rolling hash for CRC hash variant: Computes hash value for next key x[0:length-1] from previous value</span></span>
<span id="cb1-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// hash( x[-1:length-2] ) and x_first = x[-1]</span></span>
<span id="cb1-27"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> circ_hash_next <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> x_first<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint16_t</span> h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">){</span></span>
<span id="cb1-28">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// undo INITIAL_VALUE and first letter x[0] of old key</span></span>
<span id="cb1-29">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>x_first<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*(</span>length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// circularly permute all letters x[1:length-1] to 5 positions to left</span></span>
<span id="cb1-30">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// h ^= RoL(RAND[x_first], (5*(length-1)) &amp; 15); // since x%y = x &amp; (y-1)</span></span>
<span id="cb1-31">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>  RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// add new, last letter of new key x[1:length]</span></span>
<span id="cb1-32">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span></span>
<span id="cb1-33">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-34"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-35"></span>
<span id="cb1-36"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(){</span></span>
<span id="cb1-37">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-38">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> my_seq1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// n=28</span></span>
<span id="cb1-39">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> my_seq2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span> </span>
<span id="cb1-40">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint16_t</span> my_h1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circ_hash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> my_seq1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-41">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint16_t</span> my_h2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circ_hash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> my_seq2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-42">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-43">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &gt;&gt;  "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-44">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_seq1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb1-45">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%8u</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &gt;&gt;  "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>my_h1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// show current kmer and hash</span></span>
<span id="cb1-46">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_seq2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb1-47">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%8u\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>my_h2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// show current kmer and hash</span></span>
<span id="cb1-48">        my_h1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circ_hash_next <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> my_seq1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_seq1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> my_h1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-49">        my_h2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circ_hash_next <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> my_seq2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_seq2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> my_h2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-50">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-51"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>  0 &gt;&gt;  1 2 3       23891    &gt;&gt;  1 2 3          64755
  1 &gt;&gt;  2 3 1       35238    &gt;&gt;  2 3 4          42449
  2 &gt;&gt;  3 1 2       11433    &gt;&gt;  3 4 5          46207
  3 &gt;&gt;  1 2 3       23891    &gt;&gt;  4 5 2          42985
  4 &gt;&gt;  2 3 1       35238    &gt;&gt;  5 2 3          48371
  5 &gt;&gt;  3 1 2       11433    &gt;&gt;  2 3 4          42449
  6 &gt;&gt;  1 2 3       23891    &gt;&gt;  3 4 5          46207
  7 &gt;&gt;  2 3 1       35238    &gt;&gt;  4 5 2          42985
  8 &gt;&gt;  3 1 1       38662    &gt;&gt;  5 2 3          48371
  9 &gt;&gt;  1 1 1       17158    &gt;&gt;  2 3 4          42449
 10 &gt;&gt;  1 1 1       17158    &gt;&gt;  3 4 5          46207
 11 &gt;&gt;  1 1 1       17158    &gt;&gt;  4 5 1           7238
 12 &gt;&gt;  1 1 1       17158    &gt;&gt;  5 1 1            198
 13 &gt;&gt;  1 1 1       17158    &gt;&gt;  1 1 4          48977
 14 &gt;&gt;  1 1 2       63657    &gt;&gt;  1 4 5          62591
 15 &gt;&gt;  1 2 1       14054    &gt;&gt;  4 5 2          42985
 16 &gt;&gt;  2 1 2       17577    &gt;&gt;  5 2 5          43135
 17 &gt;&gt;  1 2 3       23891    &gt;&gt;  2 5 2          42985
 18 &gt;&gt;  2 3 1       35238    &gt;&gt;  5 2 3          48371
 19 &gt;&gt;  3 1 2       11433    &gt;&gt;  2 3 4          42449
 20 &gt;&gt;  1 2 1       14054    &gt;&gt;  3 4 3          41203
 21 &gt;&gt;  2 1 2       17577    &gt;&gt;  4 3 2          57833
 22 &gt;&gt;  1 2 1       14054    &gt;&gt;  3 2 3          48371
 23 &gt;&gt;  2 1 2       17577    &gt;&gt;  2 3 2          57833
 24 &gt;&gt;  1 2 1       14054    &gt;&gt;  3 2 3          48371</code></pre>
</div>
</div>
<p>The code above assumes a 16-bits hash, cast to 32 bits (due to the <code>RoL</code> macro). Below we use all 32 bits of hash, and also use the fact that for non-negative values, <code>x % y == x &amp; (y-1)</code> which may be faster.</p>
<div id="rolling-hash-4" class="cell" data-execution_count="15">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags:-lm</span></span>
<span id="cb3-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/biomcmc-lib/lib</span></span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib</span></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib/.libs/libbiomcmc.a</span></span>
<span id="cb3-5"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;biomcmc.h&gt;</span></span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x4567</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x23c6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x9869</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x4873</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xdc51</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5cff</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x944a</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x58ec</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb3-8">                           <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1f29</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x7ccd</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x58ba</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xd7ab</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x41f2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1efb</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xa9e3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xe146</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span></span>
<span id="cb3-9">                           <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x007c</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x62c2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x0854</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x27f8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x231b</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb3-10"></span>
<span id="cb3-11"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#define RoL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span></span>
<span id="cb3-12"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> circ_hash <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">){</span></span>
<span id="cb3-13">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-14">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span> RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span>                  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// XOR h and ki</span></span>
<span id="cb3-15">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">){</span></span>
<span id="cb3-16">        h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-17">        h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span>                 <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// XOR h and ki</span></span>
<span id="cb3-18">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-19">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-20"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-21"></span>
<span id="cb3-22"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> circ_hash_next <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> x_first<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">){</span></span>
<span id="cb3-23">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> remain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>rol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">31</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">U</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// since x % y = x &amp; (y-1)</span></span>
<span id="cb3-24">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// undo INITIAL_VALUE and first letter x[0] of old key</span></span>
<span id="cb3-25">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//h ^= RoL(RAND[x_first], (rol * (length-1)) % 32);// circularly permute all letters x[1:length-1] to 5 positions to left</span></span>
<span id="cb3-26">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>x_first<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> remain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-27">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>  RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// add new, last letter of new key x[1:length]</span></span>
<span id="cb3-28">    h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> RAND<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>x<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>length<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span></span>
<span id="cb3-29">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-30"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-31"></span>
<span id="cb3-32"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(){</span></span>
<span id="cb3-33">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb3-34">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> my_seq1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// n=28</span></span>
<span id="cb3-35">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> my_seq2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span> </span>
<span id="cb3-36">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> my_h1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circ_hash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> my_seq1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-37">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> my_h2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circ_hash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> my_seq2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-38">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">25</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb3-39">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &gt;&gt;  "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-40">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_seq1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb3-41">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%8u</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &gt;&gt;  "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>my_h1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// show current kmer and hash</span></span>
<span id="cb3-42">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_seq2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb3-43">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t%8u\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>my_h2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// show current kmer and hash</span></span>
<span id="cb3-44">        my_h1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circ_hash_next <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> my_seq1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_seq1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> my_h1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-45">        my_h2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> circ_hash_next <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> my_seq2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_seq2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> my_h2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb3-46">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb3-47"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>  0 &gt;&gt;  1 2 3 1  327911846       &gt;&gt;  1 2 3 4    1593746901
  1 &gt;&gt;  2 3 1 2  1293003945      &gt;&gt;  2 3 4 5    525513836
  2 &gt;&gt;  3 1 2 3  614849875       &gt;&gt;  3 4 5 2    962242528
  3 &gt;&gt;  1 2 3 1  327911846       &gt;&gt;  4 5 2 3    2639510760
  4 &gt;&gt;  2 3 1 2  1293003945      &gt;&gt;  5 2 3 4    3118376410
  5 &gt;&gt;  3 1 2 3  614849875       &gt;&gt;  2 3 4 5    525513836
  6 &gt;&gt;  1 2 3 1  327911846       &gt;&gt;  3 4 5 2    962242528
  7 &gt;&gt;  2 3 1 1  1292965638      &gt;&gt;  4 5 2 3    2639510760
  8 &gt;&gt;  3 1 1 1  615695110       &gt;&gt;  5 2 3 4    3118376410
  9 &gt;&gt;  1 1 1 1  292045574       &gt;&gt;  2 3 4 5    525513836
 10 &gt;&gt;  1 1 1 1  292045574       &gt;&gt;  3 4 5 1    962206799
 11 &gt;&gt;  1 1 1 1  292045574       &gt;&gt;  4 5 1 1    2634940637
 12 &gt;&gt;  1 1 1 1  292045574       &gt;&gt;  5 1 1 4    2533408602
 13 &gt;&gt;  1 1 1 2  292092073       &gt;&gt;  1 1 4 5    1885336699
 14 &gt;&gt;  1 1 2 1  293549798       &gt;&gt;  1 4 5 2    1341827053
 15 &gt;&gt;  1 2 1 2  327566505       &gt;&gt;  4 5 2 5    2639505508
 16 &gt;&gt;  2 1 2 3  1286135123      &gt;&gt;  5 2 5 2    3117721570
 17 &gt;&gt;  1 2 3 1  327911846       &gt;&gt;  2 5 2 3    441695456
 18 &gt;&gt;  2 3 1 2  1293003945      &gt;&gt;  5 2 3 4    3118376410
 19 &gt;&gt;  3 1 2 1  614840038       &gt;&gt;  2 3 4 3    525508832
 20 &gt;&gt;  1 2 1 2  327566505       &gt;&gt;  3 4 3 2    961602016
 21 &gt;&gt;  2 1 2 1  1286125286      &gt;&gt;  4 3 2 3    2557525224
 22 &gt;&gt;  1 2 1 2  327566505       &gt;&gt;  3 2 3 2    677306848
 23 &gt;&gt;  2 1 2 1  1286125286      &gt;&gt;  2 3 2 3    527482080
 24 &gt;&gt;  1 2 1 2  327566505       &gt;&gt;  3 2 3 2    677306848</code></pre>
</div>
</div>
<div id="rolling-hash-5" class="cell" data-execution_count="117">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* Short interlude to play with table indices :D */</span></span>
<span id="cb5-2"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;stdio.h&gt;</span></span>
<span id="cb5-3"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> main<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">()</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb5-4">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> t1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> t2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> salt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> </span>
<span id="cb5-5">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>salt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> salt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">72</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> salt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb5-6">        i1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>salt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span>t1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-7">        i2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)(</span>salt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>t1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))%</span>t2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb5-8">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">| "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> salt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> i2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-9">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(((</span>salt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)%</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)==</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb5-10">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb5-11"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>  0   0   0|   1   4   0|   2   8   0|   3  12   0|   4   0   1|   5   4   1|   6   8   1|   7  12   1| 
  8   0   2|   9   4   2|  10   8   2|  11  12   2|  12   0   3|  13   4   3|  14   8   3|  15  12   3| 
 16   0   0|  17   4   0|  18   8   0|  19  12   0|  20   0   1|  21   4   1|  22   8   1|  23  12   1| 
 24   0   2|  25   4   2|  26   8   2|  27  12   2|  28   0   3|  29   4   3|  30   8   3|  31  12   3| 
 32   0   0|  33   4   0|  34   8   0|  35  12   0|  36   0   1|  37   4   1|  38   8   1|  39  12   1| 
 40   0   2|  41   4   2|  42   8   2|  43  12   2|  44   0   3|  45   4   3|  46   8   3|  47  12   3| 
 48   0   0|  49   4   0|  50   8   0|  51  12   0|  52   0   1|  53   4   1|  54   8   1|  55  12   1| 
 56   0   2|  57   4   2|  58   8   2|  59  12   2|  60   0   3|  61   4   3|  62   8   3|  63  12   3| 
 64   0   0|  65   4   0|  66   8   0|  67  12   0|  68   0   1|  69   4   1|  70   8   1|  71  12   1| </code></pre>
</div>
</div>
</section>
<section id="transforming-dna-bases-into-hash-values" class="level2">
<h2 class="anchored" data-anchor-id="transforming-dna-bases-into-hash-values">transforming DNA bases into hash values</h2>
<p>Above, we have a single hash value <code>RAND[]</code> for each base, but we can create a stream of values.</p>
<ol type="1">
<li>we define a translation table from DNA to <img src="https://latex.codecogs.com/png.latex?0...3"> for non-ambiguous data (or some other encoding). Notice that we must know its reverse complement.</li>
<li>hash values inspired by <code>RAND[]</code> are then created. They are “salted” with large primes.</li>
</ol>
<p>The version currently implemented in <code>biomcmc-lib</code> is, for non-ambiguous DNA:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb7-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">256</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{{</span><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xff</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}};</span></span>
<span id="cb7-2"></span>
<span id="cb7-3"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span></span>
<span id="cb7-4">initialize_dna_to_bit_tables <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb7-5">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb7-6">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">256</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// calling function must check if &lt; 4</span></span>
<span id="cb7-7">    dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'A'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>   dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'A'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  A  &lt;-&gt; T  */</span></span>
<span id="cb7-8">    dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'C'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>   dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'C'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  C  &lt;-&gt; G  */</span></span>
<span id="cb7-9">    dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'G'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>   dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'G'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  G  &lt;-&gt; C  */</span></span>
<span id="cb7-10">    dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'T'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>   dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'T'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  T  &lt;-&gt; A  */</span></span>
<span id="cb7-11">    dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'U'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>   dna_in_2_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'U'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  U  &lt;-&gt; A  */</span></span>
<span id="cb7-12"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
<p>It just returns a small number, that is concatenated to form the k-mer. I.e. a sequence <code>ACGGT</code> becomes an integer with binary <code>00 01 10 10 01</code>.</p>
<p>Below is the tentative code, closer to my final implementation (notice that it doesn’t compress homopolymers). I also implemented the reverse-complement rolling hash (implemented using a different algorithm in <a href="https://github.com/bcgsc/ntHash">ntHash</a>).</p>
<div id="rolling-hash-7" class="cell" data-scrolled="false" data-execution_count="103">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags:-lm</span></span>
<span id="cb8-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/biomcmc-lib/lib</span></span>
<span id="cb8-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib</span></span>
<span id="cb8-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib/.libs/libbiomcmc.a</span></span>
<span id="cb8-5"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;biomcmc.h&gt;</span></span>
<span id="cb8-6"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> </span>
<span id="cb8-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AAACCACCTCCCGGTGGTTT"</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// first 8 and last 8 are revcompl (AAACC&lt;-&gt;GGTTT)</span></span>
<span id="cb8-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AAACCACCTCCCGGTGGTTT"</span></span>
<span id="cb8-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GTTCTTAACATTTCTCGTAC"</span></span>
<span id="cb8-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GTTCTTAACATTTCTCGTAC"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-11"></span>
<span id="cb8-12"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> rand_hash_list<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x4567</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x23c6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x9869</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x4873</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xdc51</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// size = 5</span></span>
<span id="cb8-13"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> prime_salt_list<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// size = 64 </span></span>
<span id="cb8-14">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EAF9F</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x75BD32B</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5E1C5A87</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EFDAF</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCDBEF</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x6389CB</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>   <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCE507</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCE3C7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-15">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCE15F</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x75BD431</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x34C8B0F</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5397FEF</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x87413</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x6389C9</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>   <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x34C8B23</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EFDB5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-16">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x75BD479</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5398013</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5397FCD</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x87407</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x75BD413</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EAF4B</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EB047</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x6389CF</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-17">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5E1C5A2F</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EFD31</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x34C8B59</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EFD57</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCDC19</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5E1C5B0D</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x34C8B5D</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EB035</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-18">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x75BD307</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EAF7B</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EAEF5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x75BD433</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCDBD5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCE3B7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EFD19</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5398057</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-19">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x34C8B51</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x638971</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>   <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCE16F</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x63896F</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>   <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EB04D</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x873FD</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x63896B</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>   <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCDC9B</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-20">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5E1C5B1F</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x343EFCEB</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5398007</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCE51F</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x63897B</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>   <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5E1C5B17</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5E1C5ABD</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xFF85</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-21">  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCDC25</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x873EB</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>    <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5E1C5AB1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x75BD30D</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x1FDCDCC1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xFF8B</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>     <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5397FC1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>  <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x5398001</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb8-22"></span>
<span id="cb8-23"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span></span>
<span id="cb8-24">new_dna_salted_hash_encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> salt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-25">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">255</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-26">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span>shash <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**)</span> biomcmc_malloc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sizeof</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*));</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// opposite order as dna_in_2_bits[]</span></span>
<span id="cb8-27">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*)</span> biomcmc_malloc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">256</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sizeof</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">));</span></span>
<span id="cb8-28">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* notice do{}while() instead of for() since i is always &lt; 256 */</span></span>
<span id="cb8-29">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;}</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">--);</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// anything else is fifth state</span></span>
<span id="cb8-30">    </span>
<span id="cb8-31">    shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'A'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'a'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'A'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'a'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  A  &lt;-&gt; T  */</span></span>
<span id="cb8-32">    shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'C'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'c'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'C'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'c'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  C  &lt;-&gt; G  */</span></span>
<span id="cb8-33">    shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'G'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'g'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'G'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'g'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  G  &lt;-&gt; C  */</span></span>
<span id="cb8-34">    shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'T'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'t'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'T'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'t'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  T  &lt;-&gt; A  */</span></span>
<span id="cb8-35">    shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'U'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'u'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'U'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="ch" style="color: #20794D;
background-color: null;
font-style: inherit;">'u'</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/*  U  &lt;-&gt; A  */</span></span>
<span id="cb8-36">    </span>
<span id="cb8-37">    salt <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">63</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// modulus, we only have 64 salts</span></span>
<span id="cb8-38">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/** now we transform the indexes for their equiv. hash values; all have same salt */</span></span>
<span id="cb8-39">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-40">        i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">255</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> rand_hash_list<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> prime_salt_list<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>salt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">--);</span></span>
<span id="cb8-41">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-42">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-43"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-44"></span>
<span id="cb8-45"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span></span>
<span id="cb8-46">del_dna_salted_hash_encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span> shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-47">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(!</span>shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-48">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">])</span> free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb8-49">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">])</span> free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb8-50">    free <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shash<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-51"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-52"></span>
<span id="cb8-53"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#define RoL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)))</span></span>
<span id="cb8-54"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#define RoR</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">val</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;&lt;</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;"> </span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">numbits</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)))</span></span>
<span id="cb8-55"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span></span>
<span id="cb8-56">roll_hash_add <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> dna_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> shashcode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb8-57"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-58">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(*</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-59">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> shashcode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> dna_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// XOR h and ki</span></span>
<span id="cb8-60"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-61"></span>
<span id="cb8-62"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// kmer_size can't be 0 or 32 </span></span>
<span id="cb8-63">roll_hash_replace_f <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> old_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> new_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-64">                   <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> shashcode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb8-65"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-66">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> remain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>rol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">31</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">U</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// since x % y = x &amp; (y-1) // this can be calculated outside</span></span>
<span id="cb8-67">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shashcode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> old_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> remain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// remove "leftmost" base </span></span>
<span id="cb8-68">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(*</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-69">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> shashcode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> new_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb8-70"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-71"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// kmer_size can't be 0 or 32 </span></span>
<span id="cb8-72">roll_hash_replace_r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> old_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">char</span> new_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> </span>
<span id="cb8-73">                   <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">const</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> shashcode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb8-74"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-75">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> remain <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>rol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">))</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">31</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">U</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// since x % y = x &amp; (y-1) // this can be calculated outside </span></span>
<span id="cb8-76">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> shashcode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> old_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb8-77">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> RoR<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(*</span>h<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-78">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>h <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^=</span> RoL<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shashcode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> new_base<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> remain<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span>  </span>
<span id="cb8-79"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-80"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#undef RoL</span></span>
<span id="cb8-81"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#undef RoR</span></span>
<span id="cb8-82"></span>
<span id="cb8-83"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(){</span></span>
<span id="cb8-84">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> kmer_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-85">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> h1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> h2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> h1R<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> h2R<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-86">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">size_t</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> seqlen <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> strlen <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-87">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span>shcode1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">**</span>shcode2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb8-88">    shcode1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> new_dna_salted_hash_encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-89">    shcode2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> new_dna_salted_hash_encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-90">    h1  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shcode1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span></span>
<span id="cb8-91">    h2  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shcode2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span></span>
<span id="cb8-92">    h1R <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shcode1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span></span>
<span id="cb8-93">    h2R <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> shcode2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]];</span></span>
<span id="cb8-94">    </span>
<span id="cb8-95">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-96">        roll_hash_add <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(&amp;</span>h1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> shcode1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb8-97">        roll_hash_add <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(&amp;</span>h2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> shcode2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb8-98">        roll_hash_add <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(&amp;</span>h1R<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> shcode1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb8-99">        roll_hash_add <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(&amp;</span>h2R<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> shcode2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb8-100">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-101"></span>
<span id="cb8-102">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">size_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> seqlen<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-103">       <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">((</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)%</span>kmer_size <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb8-104">            printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3lu</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &gt;&gt;  "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-105">            <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">size_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%c</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb8-106">            printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" &gt;&gt; </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%12u</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &gt;&gt; </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%12u</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> || </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%12u</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &lt;&lt; </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%12u\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>h1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> h1R<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> h2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> h2R<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> </span>
<span id="cb8-107">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-108">        roll_hash_replace_f <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(&amp;</span>h1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> shcode1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb8-109">        roll_hash_replace_f <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(&amp;</span>h2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> shcode2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span> </span>
<span id="cb8-110">        roll_hash_replace_r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(&amp;</span>h1R<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> shcode1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb8-111">        roll_hash_replace_r <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(&amp;</span>h2R<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> my_dna_seq<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> kmer_size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> rol<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> shcode2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb8-112">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb8-113">    del_dna_salted_hash_encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shcode1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-114">    del_dna_salted_hash_encoding <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>shcode2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb8-115"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>  0 &gt;&gt;  A A A C C  &gt;&gt;   3728674536 &gt;&gt;   3829420882 ||   2734906157 &lt;&lt;   4185167999
  5 &gt;&gt;  A C C T C  &gt;&gt;   4002146312 &gt;&gt;   2375924754 ||   3000820173 &lt;&lt;   3551637823
 10 &gt;&gt;  C C G G T  &gt;&gt;   3397139481 &gt;&gt;   4002502693 ||   2570072376 &lt;&lt;   3000407344
 15 &gt;&gt;  G G T T T  &gt;&gt;   3829420882 &gt;&gt;   3728674536 ||   4185167999 &lt;&lt;   2734906157
 20 &gt;&gt;  A A A C C  &gt;&gt;   3728674536 &gt;&gt;   3829420882 ||   2734906157 &lt;&lt;   4185167999
 25 &gt;&gt;  A C C T C  &gt;&gt;   4002146312 &gt;&gt;   2375924754 ||   3000820173 &lt;&lt;   3551637823
 30 &gt;&gt;  C C G G T  &gt;&gt;   3397139481 &gt;&gt;   4002502693 ||   2570072376 &lt;&lt;   3000407344
 35 &gt;&gt;  G G T T T  &gt;&gt;   3829420882 &gt;&gt;   3728674536 ||   4185167999 &lt;&lt;   2734906157
 40 &gt;&gt;  G T T C T  &gt;&gt;   2354166194 &gt;&gt;   3031712392 ||   3514117791 &lt;&lt;   2290618189
 45 &gt;&gt;  T A A C A  &gt;&gt;   2373938315 &gt;&gt;   3890239083 ||   3527637390 &lt;&lt;   4191461230
 50 &gt;&gt;  T T T C T  &gt;&gt;   2414983615 &gt;&gt;   3031703787 ||   3520409242 &lt;&lt;   2290626030
 55 &gt;&gt;  C G T A C  &gt;&gt;   2458948238 &gt;&gt;   2353379720 ||   2728681295 &lt;&lt;   3513331349
 60 &gt;&gt;  G T T C T  &gt;&gt;   2354166194 &gt;&gt;   3031712392 ||   3514117791 &lt;&lt;   2290618189
 65 &gt;&gt;  T A A C A  &gt;&gt;   2373938315 &gt;&gt;   3890239083 ||   3527637390 &lt;&lt;   4191461230
 70 &gt;&gt;  T T T C T  &gt;&gt;   2414983615 &gt;&gt;   3031703787 ||   3520409242 &lt;&lt;   2290626030</code></pre>
</div>
</div>
</section>
<section id="conclusions" class="level2">
<h2 class="anchored" data-anchor-id="conclusions">conclusions</h2>
<p>I’ve <a href="https://github.com/soedinglab/MMseqs2/issues/252">found a bug</a> in <code>linclust</code> that does not affect MMseqs2, as we see from the above.</p>


</section>
</section>

 ]]></description>
  <category>C</category>
  <guid>https://leomrtns.github.io/posts/rolling-hash/</guid>
  <pubDate>Tue, 01 Feb 2022 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/design/posts/rolling-hash.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>Quantile functions implemented in biomcmc-lib</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/quantiles/</link>
  <description><![CDATA[ 




<section id="quantile-functions-implemented-in-biomcmc-lib" class="level1">
<h1>002 Quantile functions implemented in biomcmc-lib</h1>
<p>There are (as of 2019.11.29) two functions implementing the quantile finding in <code>biomcmc-lib</code>: the <a href="https://en.wikipedia.org/wiki/Quickselect">quickselect</a> and the <a href="http://ndevilla.free.fr/median/median/">Wirth algorithm</a>. By “quantile finding” I mean returning the k-smallest element from a vector (e.g.&nbsp;the median). Both algorithms work by modifying the original vector, but in some cases <code>biomcmc-lib</code> works on a copy of it:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// quickselect, copies the vector (quantile specified as fraction over n)</span></span>
<span id="cb1-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> biomcmc_quantile_double <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>original_vector<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> quantile<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// Wirth algorithm, modifies the vector (quantile specified as an integer k &lt; n )</span></span>
<span id="cb1-5"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> biomcmc_wirth_algorithm <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>a<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> k<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span> </span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// copies the vector and returns several quantile values at once using the Wirth algorithm</span></span>
<span id="cb1-8"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">void</span>   biomcmc_quantile_vector_double <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>original_vector<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> n<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>quantile<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> n_quantile<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span>result<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span></code></pre></div></div>
<p>The algorithms do not interpolate, as in some median-finding algorithms — it finds the k-smallest element, therefore if there is a tie it chooses the … smallest!</p>
<div id="quantiles-2" class="cell" data-execution_count="12">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags:-lm</span></span>
<span id="cb2-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/biomcmc-lib/lib</span></span>
<span id="cb2-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib</span></span>
<span id="cb2-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib/.libs/libbiomcmc.a</span></span>
<span id="cb2-5"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;biomcmc.h&gt;</span></span>
<span id="cb2-6"></span>
<span id="cb2-7"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(){</span></span>
<span id="cb2-8">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">double</span> this<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> unsorted<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">6.6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">8.8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">7.7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">9.1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">9.9</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb2-9">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb2-10">    printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"before:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-11">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3.2lf</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> unsorted<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb2-12">    this <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> biomcmc_wirth_algorithm <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>unsorted<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-13">    printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">after finding </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3.2lf</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> (Wirth):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> this<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-14">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3.2lf</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> unsorted<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb2-15">    this <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> biomcmc_quantile_double <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>unsorted<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-16">    printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">after finding </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3.2lf</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> (quickselect):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> this<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-17">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3.2lf</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> "</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> unsorted<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb2-18">    printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-19"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>before:
1.10 6.60 3.30 8.80 7.70 4.40 4.30 9.10 5.50 9.90 
after finding 3.30 (Wirth):
1.10 3.30 4.30 4.40 5.50 7.70 </code></pre>
</div>
</div>
<p>biomcmc-lib commit: <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib/commit/5975331ef88d1c4ec9aef9599fb6348905d289c7">5975331</a></p>


</section>

 ]]></description>
  <category>C</category>
  <guid>https://leomrtns.github.io/posts/quantiles/</guid>
  <pubDate>Sat, 01 Jan 2022 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/design/posts/quantiles.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>K-mer in biomcmc-lib</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/kmers/</link>
  <description><![CDATA[ 




<section id="k-mer-in-biomcmc-lib-2019.11.29" class="level1">
<h1>K-mer in biomcmc-lib (2019.11.29)</h1>
<p>This notebook contains a few details of how kmers are implemented in the low-level phylogenetic library <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib">biomcmc-lib</a>. This library is opaque to the user, and contains functions that are common to several projects. The functions discussed here relate to the creation of the k-mers (and their hash values) for a given DNA sequence.</p>
<p>Please have in mind that these functions are likely to change or at least change names soon — they are general enough to have allowed me to play with kmers, but are too complex for production-level software. Two missing functionalities are:</p>
<ol type="1">
<li>inexact (masked) k-mers.</li>
<li>rolling hashes</li>
<li>using 32 bits per hash value (64 bits may be overkill)</li>
<li>homopolymer compression</li>
<li>fine-grained control over k-mer sizes</li>
</ol>
<p>Some code shown here depends on local libraries, which must be linked at compilation time (<code>//%cflags:-lm</code> etc.)</p>
<section id="parameters-of-a-kmer-set" class="level2">
<h2 class="anchored" data-anchor-id="parameters-of-a-kmer-set">1.1 Parameters of a kmer set</h2>
<p>Since it may be onerous to scan through the DNA sequence several times, I decided to generate kmers for several choices of <code>k</code> in one pass. The library uses 128 bits to store each kmer, and immediately transforms it into its 64 bits hash value.</p>
<p>Furthermore there are 3 possible encodings for each base: 1, 2, and 4 bits per base. The standard used by most kmer algorithms is equivalent to 2 bits per base (<code>A-&gt;00</code>, <code>C-&gt;01</code>, <code>G-&gt;10</code>, <code>T-&gt;11</code>). The other two are a compact, GC-content-like one bit per base(<code>A,T-&gt;0</code>, and <code>C,G-&gt;1</code>), and one common in the phylogenetic likelihood structure, that can accommodate ambiguous characters. For instance, since <code>M</code> represents an amino group (<code>C</code> or <code>A</code>), then we can have <code>A-&gt;0001</code>, <code>C-&gt;0010</code>, <code>M-&gt;0011</code>, and <code>N-&gt;1111</code>.</p>
<p>The code below is implemented in biomcmc-lib (2019.11.29), and is responsible for selecting the sets of k-mer sizes depending on an integer <code>mode</code> given by the user. This code is subject to change.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb1-1"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint64_t</span> _tbl_mask<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xffff</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">UL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xffffff</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">UL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xffffffff</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">UL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xffffffffff</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">UL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xffffffffffff</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">UL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xffffffffffff</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">UL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xffffffffffffffff</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">UL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb1-2"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> _tbl_shift<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>      <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">48</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>         <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>           <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">32</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>             <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">24</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>               <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>                <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>                    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb1-3"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> _tbl_nbyte<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>       <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>          <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>            <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>              <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>                <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>                <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>                    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb1-4"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint32_t</span> _tbl_seed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x9040a6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x10bea992</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>   <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x50edd67d</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>     <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xb05a4f09</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>       <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xf07046c5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>       <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x9c9445ab</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span>           <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xb2500f29</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb1-5"></span>
<span id="cb1-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/* i1[] and i2[] (i.e. elements above to be used on first and second 64bits, respectively */</span></span>
<span id="cb1-7"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> _idx_mode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// contains list of elements from _tbl above to be used, from 1st and 2nd 64bit blocks</span></span>
<span id="cb1-8">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span>  </span>
<span id="cb1-9">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span>  </span>
<span id="cb1-10">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> </span>
<span id="cb1-11">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span></span>
<span id="cb1-12">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span></span>
<span id="cb1-13">   <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-14"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span>   </span>
<span id="cb1-15"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">static</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> _n_idx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">},</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// how many elems from _idx_mode[] are used</span></span>
<span id="cb1-16">   </span>
<span id="cb1-17"></span>
<span id="cb1-18">kmer_params</span>
<span id="cb1-19">new_kmer_params <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> mode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb1-20"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-21">  <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span>  i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> row<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> bases_per_byte<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> _ba_pe_by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// bases_per_byte is 4 if dense</span></span>
<span id="cb1-22">  kmer_params p <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>kmer_params<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> biomcmc_malloc <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">sizeof</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">struct</span> kmer_params_struct<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">));</span></span>
<span id="cb1-23">  p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>ref_counter <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-24">  p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>hashfunction <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span>biomcmc_xxh64<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-25">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>dna_in_4_bits<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0xff</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> initialize_dna_to_bit_tables <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">();</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// run once per program</span></span>
<span id="cb1-26">  p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>kmer_class_mode <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> mode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-27">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">switch</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>mode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// map each choice to a set of kmers and bitstring encoding (row relates to _idx_mode[] above)</span></span>
<span id="cb1-28">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">case</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>  row <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>dense <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-29">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">case</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>  row <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>dense <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-30">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">case</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>  row <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>dense <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-31">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">case</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span></span>
<span id="cb1-32">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">default</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span> row <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>dense <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-33">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">case</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>  row <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>dense <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-34">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">case</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>  row <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>dense <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-35">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">};</span></span>
<span id="cb1-36">  bases_per_byte <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _ba_pe_by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>dense<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-37"></span>
<span id="cb1-38">  p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> _n_idx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>row<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> _n_idx<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>row<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-39">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-40">    i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _idx_mode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>row<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-41">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>mask1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _tbl_mask<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-42">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>shift1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _tbl_shift<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-43">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>seed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _tbl_seed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-44">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>nbytes<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _tbl_nbyte<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-45">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _tbl_nbyte<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> bases_per_byte<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-46">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-47">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb1-48">    i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _idx_mode<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>row<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">][</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-49">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>mask2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _tbl_mask<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-50">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>shift2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _tbl_shift<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">];</span></span>
<span id="cb1-51">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>seed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>_tbl_seed<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="bn" style="color: #AD0000;
background-color: null;
font-style: inherit;">0x420314a1d</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">// very noise, much random</span></span>
<span id="cb1-52">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>nbytes<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> _tbl_nbyte<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-53">    p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>_tbl_nbyte<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> bases_per_byte<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-54">  <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb1-55">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> p<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb1-56"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
<p>(out of curiosity, Liquid cannot handle the consecutive curly braces (https://github.com/Shopify/liquid/issues/927) thus I need to separate as in <code>{ {</code>)</p>
<p>The small program below prints the resulting set of parameters for each choice of <code>mode</code>. Notice that the code must be linked to the <code>libbiomcmc.a</code> local library (some programs, like <a href="https://bitbucket.org/leomrtns/guenomu/">guenomu</a> still install a global version of this library, but newer programs should use it locally, to avoid version conflicts and since it’s smaller than one MB…)</p>
<div id="kmers-2" class="cell" data-execution_count="1">
<details class="code-fold">
<summary>Code</summary>
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode c code-with-copy"><code class="sourceCode c"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags:-lm</span></span>
<span id="cb2-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/biomcmc-lib/lib</span></span>
<span id="cb2-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: -I/usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib</span></span>
<span id="cb2-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">//%cflags: /usr/users/QIB_fr005/deolivl/Academic/Quadram/009.supersptree/build/biomcmc-lib/lib/.libs/libbiomcmc.a</span></span>
<span id="cb2-5"><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">#include </span><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">&lt;biomcmc.h&gt;</span></span>
<span id="cb2-6"></span>
<span id="cb2-7"><span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">int</span> main <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(){</span></span>
<span id="cb2-8">    <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">uint8_t</span> i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span></span>
<span id="cb2-9">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span></span>
<span id="cb2-10">        kmer_params kp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> new_kmer_params <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-11">        printf <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;&lt;</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">&gt;&gt;</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> j<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-12">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &lt; 1 &gt;</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>nbytes<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb2-13">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span>kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n2<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">;</span>i<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">++)</span> printf<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%3d</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> &lt; 2 &gt;</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">,</span> kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>nbytes<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">],</span> kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>size<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>i <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-&gt;</span>n1<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]);</span></span>
<span id="cb2-14">        del_kmer_params <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">(</span>kp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">);</span></span>
<span id="cb2-15">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb2-16"><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span></span></code></pre></div></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>&lt;&lt;0&gt;&gt;
       4  16 &lt; 1 &gt;
       8  32 &lt; 1 &gt;
&lt;&lt;1&gt;&gt;
       2   8 &lt; 1 &gt;
       4  16 &lt; 1 &gt;
       6  24 &lt; 1 &gt;
       8  32 &lt; 1 &gt;
      12  48 &lt; 2 &gt;
      16  64 &lt; 2 &gt;
&lt;&lt;2&gt;&gt;
       2   4 &lt; 1 &gt;
       3   6 &lt; 1 &gt;
       4   8 &lt; 1 &gt;
       6  12 &lt; 1 &gt;
       8  16 &lt; 1 &gt;
      10  20 &lt; 2 &gt;
      12  24 &lt; 2 &gt;
      16  32 &lt; 2 &gt;
&lt;&lt;3&gt;&gt;
       2   8 &lt; 1 &gt;
       3  12 &lt; 1 &gt;
       4  16 &lt; 1 &gt;
       5  20 &lt; 1 &gt;
       6  24 &lt; 1 &gt;
       7  28 &lt; 1 &gt;
       8  32 &lt; 1 &gt;
&lt;&lt;4&gt;&gt;
       2   4 &lt; 1 &gt;
       3   6 &lt; 1 &gt;
       4   8 &lt; 1 &gt;
       5  10 &lt; 1 &gt;
       6  12 &lt; 1 &gt;
       7  14 &lt; 1 &gt;
       8  16 &lt; 1 &gt;
      10  20 &lt; 2 &gt;
      11  22 &lt; 2 &gt;
      12  24 &lt; 2 &gt;
      16  32 &lt; 2 &gt;
&lt;&lt;5&gt;&gt;
       4  32 &lt; 1 &gt;
       8  64 &lt; 1 &gt;
      12  96 &lt; 2 &gt;
      16 128 &lt; 2 &gt;</code></pre>
</div>
</div>
<p>biomcmc-lib commit: <a href="https://github.com/quadram-institute-bioscience/biomcmc-lib/commit/5975331ef88d1c4ec9aef9599fb6348905d289c7">5975331</a></p>


</section>
</section>

 ]]></description>
  <category>C</category>
  <guid>https://leomrtns.github.io/posts/kmers/</guid>
  <pubDate>Wed, 01 Dec 2021 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/design/posts/kmers.svg" medium="image" type="image/svg+xml"/>
</item>
<item>
  <title>Welcome to the blog</title>
  <dc:creator>Leo Martins</dc:creator>
  <link>https://leomrtns.github.io/posts/welcome-binfie-notes/</link>
  <description><![CDATA[ 




<p>You can find more information about me on the parent site (<a href="https://leomrtns.github.io/about/">https://leomrtns.github.io/about/</a>).</p>
<p>This blog will consist mostly of technical notes, but I don’t preclude an occasional rant. Hopefully I’ll move some old posts from other, defunct blogs. You can also find me on a mastodon server <a href="https://scicomm.xyz/web/@leomrtns">https://scicomm.xyz/web/<span class="citation" data-cites="leomrtns">@leomrtns</span></a>.</p>
<p>Update: in 2025, I moved to Liverpool and started a new job at the University of Liverpool as a Tenure Track Fellow in Health at the Department of Electrical Engineering and Electronics. I am no longer at the Quadram Institute Biosciences (and emails to my old address will bounce).</p>



 ]]></description>
  <category>random</category>
  <guid>https://leomrtns.github.io/posts/welcome-binfie-notes/</guid>
  <pubDate>Mon, 01 Jan 2018 00:00:00 GMT</pubDate>
  <media:content url="https://leomrtns.github.io/assets/images/logo_araiguma.png" medium="image" type="image/png" height="58" width="144"/>
</item>
</channel>
</rss>
