<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Sampling Random Bioinformatics Puzzles using Adaptive Probability Distributions</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Christian Theil Have</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Emil Vincent Appel</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jette Bork-Jensen</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ole Torp Lassen</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Novo Nordisk Foundation Center for Basic Metabolic Research, Section of Metabolic Genetics, University of Copenhagen</institution>
          ,
          <country country="DK">Denmark</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Roskilde University</institution>
          ,
          <addr-line>Roskilde</addr-line>
          ,
          <country country="DK">Denmark</country>
        </aff>
      </contrib-group>
      <fpage>39</fpage>
      <lpage>45</lpage>
      <abstract>
        <p>We present a probabilistic logic program to generate an educational puzzle that introduces the basic principles of next generation sequencing, gene nding and the translation of genes to proteins following the central dogma in biology. In the puzzle, a secret "protein word" must be found by assembling DNA from fragments (reads), locating a gene in this sequence and translating the gene to a protein. Sampling using this program generates random instance of the puzzle, but it is possible constrain the di culty and to customize the secret protein word. Because of these constraints and the randomness of the generation process, sampling may fail to generate a satisfactory puzzle. To avoid failure we employ a strategy using adaptive probabilities which change in response to previous steps of generative process, thus minimizing the risk of failure.</p>
      </abstract>
      <kwd-group>
        <kwd>PRISM</kwd>
        <kwd>bioinformatics</kwd>
        <kwd>sampling</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Assemble-yourself 3 is a paper-printable \bioinformatics\ puzzle which is
intended to be fun as well as educational { it introduces concepts in genetics and
Next Generation Sequencing (NGS) [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. We have successfully used
assembleyourself in a workshop setting, where groups of participants competed against
each other. They were quite engaged and reported to have a lot of fun while
also learning. The idea of the game is to assemble a DNA sequence from NGS
reads and translate it into amino acids to nd a secret word. The entire game
is printed on paper. This includes the reads (cut out paperstrips) and a board
which serves sca old to assemble the reads and writing down the sequence. Once
the reads have been assembled and a consensus sequence is found, the consensus
sequence is translated to amino acid sequences in both DNA strands. The letters
of the sequence contains a secret word embedded within an open reading frame.
      </p>
      <p>The game is generated by a probabilistic logic program and many aspects of
the game can be con gured prior to generation. For instance, the secret protein
3 https://github.com/cth/assemble-yourself
word can be changed and the minimal read depth | the number of reads covering
any position | can be con gured. In order to ensure satisfaction of constraints
in a computationally e cient way, we introduce a heuristic scheme to adapt
random switch probabilities based previous states of the program.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Description of the game</title>
      <p>In the style of logic programming, we begin with the goal. The goal of the game
is to nd a particular protein word. For a given game instance, a mutated version
of the speci ed protein word | where some letters (amino acids) are randomly
substituted | is generated and reported in the background story, c.f., gure 1.
Recently an interesting protein with the amino acid sequence ILP was found in the bacteria S.
Equencia. It is now to be determined if a homologue exists in the species B. Ionformatica.
To determine this a lab ampli cied a relevant part of the DNA of B. Ionformatica using PCR primers
anking the gene in S. Equencia which are believed to be highly conserved also in B. Ionformatica,
although the sequence of B. Ionformatica is currently not known. The ampli ed DNA was sequenced
using Ullamini LoSeq next generation sequencing tech. The quality of the reads are not perfect {
read errors resulting in random \mutations\ are expected in one out of twenty bases.
As a bioinformatician you are given the task to nd out if B. Ionformatica has a homologue of the
protein ILP and determine how its amino acid sequence di ers in B. Ionformatica. However, the
high performance moon grid engine supercluster is currently down (as it sometimes is) and you have
to do it all by hand. Fortunately, you have printed all the reads. You task is as follows: 1) Perform
de-novo assembly of all the reads, 2) Find open reading frames that may contain a gene, 3) Find
the amino acid sequence of any such gene to determine if it could be a homologue to ILP, 4) Report
your nding and claim eternal fame.</p>
      <p>The amino acids are re ected in a corresponding the DNA sequence of
nucleotide bases forming a gene, where each triplet of DNA bases (called a codon)
correspond to an amino acid. Only part of the DNA sequence is used to encode
the protein word. It is anked by random DNA on both sides, but the o set
of the encoded protein is randomly determined. A given amino acid may be
represented by one of multiple coden triplets, a particular codon may indicate
the start of the gene and another is used to indicate the end of it (see gure
2, and e.g., https://en.wikipedia.org/wiki/Genetic code for details). The DNA
sequence can be read either left-to-right or right-to-left, but in the latter case the
DNA sequence should be complimented, i.e., the bases should be replaced by the
one they pair with in the double-helical DNA molecule (A $ T and G $ C).
Yet another complication is that codon triplets may start in any position.</p>
      <p>Part of the puzzle is to nd possible genes in DNA, translate the nucleotide
bases into an amino sequence to nd the secret protein word. Once found the
game is completed. However, before doing this, the player is faced with solving
the problem of assembling the sequencing from a number of overlapping
subsequences of the sequence (reads). This mimics the situation that arise when using
NGS technologies, where the assembly process is handled by computationally
intensive algorithms. The user however, is tasked with doing this by hand for a
small DNA sequence. A scaled down instance of the game is shown in gure 3.</p>
      <sec id="sec-2-1">
        <title>Second base in codon</title>
        <p>T C A G
TTT Phe F TCT Ser S TAT Tyr Y TGT Cys Y T
TTC Phe F TCC Ser S TAC Tyr Y TGC Cys Y C
T</p>
      </sec>
      <sec id="sec-2-2">
        <title>TTA Leu L TCA Ser S TAA Stop * TGA Stop * A</title>
      </sec>
      <sec id="sec-2-3">
        <title>TTG Leu L TCG Ser S TAG Stop * TGG Trp W G</title>
        <p>T
CTT Leu L CCT Pro P CAT His H CGT Arg R T h
CTC Leu L CCC Pro P CAC His H CGC Arg R C ird
CTA Leu L CCA Pro P CAA Gln Q CGA Arg R A ab
CTG Leu L CCG Pro P CAG Gln Q CGG Arg R G se
ATT Ile I ACT Thr T AAT Asn N AGT Ser S T in
ATC Ile I ACC Thr T AAC Asn N AGC Ser S C co
d
ATA Ile I ACA Thr T AAA Lys K AGA Arg R A on
ATG Met M ACG Thr T AAG Lys K AGG Arg R G
GTT Val V GCT Ala A GAT Asp D GGT Gly G T
GTC Val V GCC Ala A GAC Asp D GGC Gly G C
G</p>
        <p>GTA Val V GCA Ala A GAA Glu E GGA Gly G A
GTG Val V GCG Ala A GAG Glu E GGG Gly G G</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Description of the program</title>
      <p>
        We have written the program to generate puzzles in the PRISM language [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]
| a probabilistic dialect of Prolog | although none of the advanced inference
procedures of PRISM are used. The program executes in sampling mode to
generate a random puzzle. Unlike the execution of a usual Prolog program, select
non-deterministic choice points are replaced with committed random choices
beyond which backtracking do not occur. Since the sampling execution commits
to these random choices, uni cation failures cannot under normal circumstances
be undone by backtracking, and the execution may fail if speci ed constraints are
not satis ed. The output of the program is a LATEXdocument which is compiled
to printable PDF document which constitutes the puzzle. The generation of
the LATEXdocument is not probabilistic, but is implemented as a usual Prolog
program which takes as input the probabilistic choices made in the sampling
part of program.
      </p>
      <p>The part of the puzzle which involves the protein word corresponding amino
acid sequence and its underlying DNA sequence can be generated by a series of
probabilistic choices on where to place the protein word, on generation of the</p>
      <sec id="sec-3-1">
        <title>b) The (empty) game board</title>
      </sec>
      <sec id="sec-3-2">
        <title>Amino acid sequence (forward strand)</title>
        <p>T A T G G A A A T G T T A C C T A A G A
A A A T G G A A T C T A C C T T T A C C
A C C T T T A C C T G G A A A T G G A A</p>
      </sec>
      <sec id="sec-3-3">
        <title>a) Reads to cut out and use place on the game board T A C C T T T A C C T T A C C T T A G A C T A C C T T T A C</title>
        <p>C G T T G A C C T T</p>
      </sec>
      <sec id="sec-3-4">
        <title>c) A solution with reads aligned</title>
      </sec>
      <sec id="sec-3-5">
        <title>Amino acid sequence (forward strand)</title>
      </sec>
      <sec id="sec-3-6">
        <title>I/M P L P stop Y L Y</title>
        <p>L</p>
        <p>R
protein word with probability of point mutations as well as corresponding and
additional point mutations in the underlying DNA sequence.</p>
        <p>
          We must, however, control the number of mutations that are introduced in
the protein word. If no mutations occur, the word will be the same as the the
homologue protein in the background story, whereas if too many mutations
occur, it may be di cult to determine if a discovered protein is correct. Hence, we
constrain the number of mutations in the protein word to a speci ed range. To
address this constraint we use PRISMs soft_msw construct [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ], which provide
a backtrack-able random switch mechanism in contrast to the usual committed
choice construct for creating random switches, msw. Upon backtracking, the
previously selected outcome of the switch is (temporarily) removed and probability
distribution over remaining outcomes is re-normalized before an alternate choice
is attempted.
        </p>
        <p>Note that it is not strictly necessary to rely on backtracking to solve this
particular problem. An alternative failure-free approach would be to randomly
choose the number of mutations from the speci ed range, randomly determine at
which positions these mutations should occur and then introduce these mutations
in the protein word.</p>
        <p>In the generation of reads another global constraint come into play { each
position of the DNA sequence must be covered by a speci ed minimum number
of reads { the depth. At the same time, the total number of reads is constrained
and generally kept to a minimum in order to balance the level fun and di culty
in the puzzle.</p>
        <p>Reads are generated by a recursive predicate in which the termination case
of the predicate speci es the condition that all positions must have the required
minimum depth and the recursive case generates a random read, aligns it to the
DNA sequence and updates a depth vector, d1 : : : dn, for each position 1 : : : n in
the DNA sequence. It is not possible for this predicate to fail, but it may produce
too many reads causing an assertion to fail in the calling predicate.</p>
        <p>Initially we used soft_msw in our implementation, which would backtrack
upon failure, but this approach exhibited poor performance for larger board
sizes with a low cap on the total number of reads due to the potentially
extensive thrashing behaviour associated with backtracking, where partial solutions
leading to failures are repeatedly revisited.</p>
        <p>The predicate responsible for placing reads is shown below,
placeread(Seq, Part1, Part2,ReadSize,Depths)
:length(Seq,L),
LMax is L - ReadSize,
findall(X,between(0,LMax,X),AllLen),
findall(D2,(
between(0,LMax,X),
length(C1,X),
length(C2,ReadSize),
append(C1,C2,C3),
append(C3,_,Depths),</p>
        <p>D2 is min(C2))),
MinDepths),
inverse_depths_probs(MinDepths,Probs),
random_select(AllLen,Probs,L1),
L #= L1+L2,
length(Part2,L2),
append(Part1,Part2,Seq).</p>
        <p>The placeread/4 predicate attempts to construct a list of depths from the
part of the sequence before the read, the part covering the read, and the part after
the read for all combinations of possible read placements. For each of possible
read placement, it then nds the minimum depth of any position covered by the
read. The call to inverse_depth_probs/2 constructs a probability distribution
over the possible read positions from the minimum depths. The probability of
placing a new read of length r starting at position i, is given by,
P (pos = i) =
( 1 ;
n
Phn=w1ri wh
if Pin=1 di = 0:
otherwise:
, where wi =</p>
        <p>Pjn=1r min dj : : : dj+r
min di : : : di+r</p>
        <p>The probabilistic selection of read positions is not implemented using the msw
construct, but instead using the random_select construct, which given a list of
probabilities which serves as an probability distribution over a corresponding list
of outcomes, randomly selects one of the outcomes according to the
probability distribution. Instead of having a xed probability distribution, we adapt the
probabilities in response to previous placements. This ensures that the
probability of placing a new read at a given position is inversely proportional to the
minimum depth of the positions covered by the read. This approach is not as
declarative, since the possible outcomes and the probability distribution can only
be determined during program execution. A disadvantage that comes with this
lack of declarativity, i.e., that random choices occur outside the de ned PRISM
model, is that other forms of inference which rely on a xed model are no longer
possible.</p>
        <p>The approach is very fast (almost instantaneous), but may occasionally fail. It
rarely happens, but when it does, the procedure can just be restarted. It results in
fewer reads and a distribution of depths/reads which appears uniformly random,
except in the ends near the edges of the board which are characterized by lower
depths.
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Discussion</title>
      <p>
        Our game has many similarities to Gigsaw [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], a program to generate PDF
documents that include educational Next Generation Sequencing puzzles. The
Gigsaw program similarly generates paper printable NGS reads, which can be
aligned to or assembled into a given sequence. In di ers from our program in the
sense that it is simulation rather than a game. Our puzzles are more \gami ed\
and have multiple dependent puzzle layers, i.e., also the translation to amino
acids and the quest for the secret word. Consistency between these layers is
what necessitates the constraints discussed in this paper. Depth constraints are
not possible with Gigsaw, which is intended to provide a realistic simulation
where depth depends solely on input parameters such as the sequence length,
the type and length of reads and the number of reads.
      </p>
      <p>
        Using PRISM programs to sample biological sequence data has been done
before, e.g., in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] where they use it to generate test data to evaluate gene nders.
Another application of sampling from constrained PRISM (CHRiSM) programs
is the APOPCALEAPS program [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], which introduced the soft_msw approach.
      </p>
      <p>
        A heuristic approach to generate programs with low probability of failure,
as embodied by adaptive probability distributions is more e cient than the
soft_msw approach in our case. However, the scheme is speci c to our
application and cannot easily be generalized. As a point of future research, it would
be useful to develop generic, but heuristically informed methods for PLP-based
random sampling which are less prone to thrashing than the pure soft_msw
backtracking approach. Perhaps inspiration can be drawn from the methods of
constraint programming [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Another concern that arise with sampling approaches
circumventing failure, is that the probability distribution over outcomes can be
skewed by the approach. This has negative consequences for using the sampling
as a building block for other inference procedures. Failures can, however, be
handled in the context of parameter learning by the failure adjusted maximization
procedure [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] in PRISM [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] and other PLP systems [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Metzker</surname>
          </string-name>
          , Michael L.;
          <article-title>Sequencing technologiesthe next generation</article-title>
          .
          <source>Nature reviews genetics 11.1</source>
          ,
          <issue>31</issue>
          {
          <fpage>46</fpage>
          . (
          <year>2010</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Sato</surname>
          </string-name>
          , Taisuke, Yoshitaka Kameya:
          <article-title>PRISM: a language for symbolic-statistical modeling</article-title>
          .
          <source>IJCAI</source>
          . Vol.
          <volume>97</volume>
          . (
          <year>1997</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Sato</surname>
          </string-name>
          ,
          <string-name>
            <surname>Taisuke</surname>
          </string-name>
          , et al.:
          <source>PRISM Users Manual. Version 2</source>
          .
          <fpage>2</fpage>
          . (
          <year>2012</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Martin</surname>
            ,
            <given-names>D. M. A.</given-names>
          </string-name>
          :
          <article-title>Gigsaw: physical simulation of next generation sequencing for education and outreach</article-title>
          .
          <source>EMBnet. journal</source>
          ,
          <volume>18</volume>
          (
          <issue>1</issue>
          ),
          <volume>28</volume>
          (
          <year>2012</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>Henning</given-names>
            <surname>Christiansen</surname>
          </string-name>
          ,
          <article-title>Christina Mackeprang Dahmcke: A Machine Learning Approach to Test Data Generation: A Case Study in Evaluation of Gene Finders</article-title>
          .
          <source>Lecture Notes in Arti cial Intelligence</source>
          <volume>4571</volume>
          ,
          <fpage>741</fpage>
          {
          <fpage>755</fpage>
          (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>Jon</given-names>
            <surname>Sneyers</surname>
          </string-name>
          and Danny De Schreye:
          <article-title>APOPCALEAPS: Automatic Music Generation with CHRiSM</article-title>
          .
          <source>22nd Benelux Conference on AI (BNAIC'10)</source>
          , Luxembourg (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Dechter</surname>
          </string-name>
          , Rina, and Daniel Frost:
          <article-title>Backtracking algorithms for constraint satisfaction problemsa tutorial survey</article-title>
          .
          <source>Information-and CS Technical Report 56</source>
          (
          <year>1998</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Cussens</surname>
          </string-name>
          , James:
          <article-title>Parameter estimation in stochastic logic programs</article-title>
          .
          <source>Machine Learning 44.3</source>
          (
          <issue>245</issue>
          -
          <fpage>271</fpage>
          ). (
          <year>2001</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Sato</surname>
            , Taisuke,
            <given-names>Yoshitaka</given-names>
          </string-name>
          <string-name>
            <surname>Kameya</surname>
          </string-name>
          , and
          <string-name>
            <surname>Neng-Fa Zhou</surname>
          </string-name>
          :
          <article-title>Generative Modeling with Failure in PRISM</article-title>
          . IJCAI. (
          <year>2005</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <surname>Jianzhong</surname>
          </string-name>
          , et al.
          <article-title>"PEPL: An implementation of FAM for SLPs. ALP Newsletter, focus on Probabilistic Prolog Systems (</article-title>
          <year>2011</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>