Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is a good way to implement getting a consensus sequence in Java?
    text
    copied!<p>I have the following problem:</p> <ul> <li>I have 2 Strings of DNA Sequences (consisting of ACGT), which differ in one or two spots.</li> <li>Finding the differences is trivial, so let's just ignore that</li> <li>for each difference, I want to get the <a href="http://en.wikipedia.org/wiki/FASTA_format#Sequence_representation" rel="nofollow">consensus symbol</a> (e.g. M for A or C) that represents both possibilities</li> </ul> <p>I know I could just make a huge <em>if-cascade</em> but I guess that's not only ugly and hard to maintain, but also slow.</p> <p>What is a fast, easy to maintain way to implement that? Some kind of lookup table perhaps, or a matrix for the combinations? Any code samples would be greatly appreciated. I would have used Biojava, but the current version I am already using does not offer that functionality (or I haven't found it yet...).</p> <p><strong>Update</strong>: there seems to be a bit of confusion here. The consensus symbol is a single char, that stands for a single char in both sequences.</p> <p>String1 and String2 are, for example "ACGT" and "ACCT" - they mismatch on position 2. Sooo, I want a consensus string to be ACST, because S stands for "either C or G"</p> <p>I want to make a method like this:</p> <pre><code>char getConsensus(char a, char b) </code></pre> <p><strong>Update 2</strong>: some of the proposed methods work if I only have 2 sequences. I might need to do several iterations of these "consensifications", so the input alphabet could increase from "ACGT" to "ACGTRYKMSWBDHVN" which would make some of the proposed approaches quite unwieldy to write and maintain.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload