Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There's one difficulty with your explanation. </p> <p>What you start with is a directed graph where each edge represents a connection X=>Y where X is a donor and Y an acceptor. The table <code>atoms</code> is the SQL representation of that graph. </p> <p>What you seem to want is something that is <em>undirected</em>. So that a link X-Y means that X and Y are linked via a water molecule (or some other species of course) but that X and Y could both be donors or acceptors. For this reason your last table has an ambiguity (that you note) so that some links could occur either way around. It seems to me that means that the column headings <code>donor_id</code> and <code>acceptor_id</code> on your final column don't have any meaning that you have explained. This may be my confusion of course.</p> <p>If all you want is a table with all 6 links in it, each as one row, but don't worry too much about keeping track of the donor/acceptor thing then this works for me in sqlite3:</p> <pre><code> create temporary view hoh_view as select donor_id as id, atoms.id as hoh_id from contacts, atoms where acceptor_id=atoms.id and atoms.amino='HOH' union select acceptor_id as id, atoms.id as hoh_id from contacts, atoms where donor_id=atoms.id and atoms.amino='HOH'; select a.id, b.id from hoh_view as a, hoh_view as b where a.id &gt; b.id and a.hoh_id=b.hoh_id; </code></pre> <p>Where I have used a temporary view to make things clearer. You can put this all into one big query if you like by replacing each reference to <code>hoh_view</code> by the first query. It feels a bit nasty to me and there may be a way of tidying it up.</p> <p>If you do want to keep track of donor/acceptor relationships you need to explain how you decide what to do when both amino acids are acceptors or donors (i.e. the last two rows in your example).</p> <p>If that doesn't do what you want, then maybe I can fix it up so it does.</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