Skip to content

Instantly share code, notes, and snippets.

@wchristian
Created December 4, 2010 11:07
Show Gist options
  • Save wchristian/728111 to your computer and use it in GitHub Desktop.
Save wchristian/728111 to your computer and use it in GitHub Desktop.
my $sql = "SELECT count(s.seq_id) AS nb, isha.motifs
FROM sequences s
JOIN (
SELECT sha.seq_id AS shaseq_id,GROUP_CONCAT(i.ipr_code ORDER BY i.ipr_code) AS motifs
FROM seq_has_an sha, ipr i
WHERE i.ipr_id = sha.ipr_id AND i.ipr_code IN ($IPR_list)
GROUP BY shaseq_id
) isha ON s.seq_id = isha.shaseq_id
WHERE s.species_id = $_{species_id}
GROUP BY isha.motifs
ORDER BY isha.motifs;";
my $number_by_ipr_combination = $dbh->selectall_arrayref( $sql, { Slice => {} } );
---------------
my $sql = "SELECT count(s.seq_id) AS nb, isha.motifs
FROM sequences s
JOIN (
SELECT sha.seq_id AS shaseq_id,GROUP_CONCAT(i.ipr_code ORDER BY i.ipr_code) AS motifs
FROM seq_has_an sha, ipr i
WHERE i.ipr_id = sha.ipr_id AND i.ipr_code IN ($IPR_list)
GROUP BY shaseq_id
) isha ON s.seq_id = isha.shaseq_id
WHERE s.species_id = $_{species_id}
GROUP BY isha.motifs
ORDER BY isha.motifs;";
my $number_by_ipr_combination = $dbs->query( $sql )->hashes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment