Skip to content

Instantly share code, notes, and snippets.

View dbolser's full-sized avatar
💭
Reversing the polarity

Dan Bolser dbolser

💭
Reversing the polarity
View GitHub Profile
<?php
/**
* @file
* Apache Solr external index module - example module for using external data.
*/
/**
* implements hook_apachesolr_query_alter().
*/
function apachesolr_external_index_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
@dbolser
dbolser / gist:dc76ac3de2f56e7472f5
Last active August 29, 2015 14:01
Convert intron-style GFF to exon-style GFF with Perl
#! perl
use strict;
use warnings;
die "pass an intron-style GFF for me to calcualte exons over\n"
unless @ARGV;
## Tracking variables
my $prev_type = 'dumped';
for module in \
ensembl \
ensembl-compara \
ensembl-funcgen \
ensembl-rest \
ensembl-tools \
ensembl-variation
do
if [ ! -d "$module" ]; then
echo "Checking out $module ($branch)"
DROP TABLE IF EXISTS test_et;
CREATE TABLE test_et (
exon_id int unsigned NOT NULL,
transcript_id int unsigned NOT NULL,
rank int NOT NULL,
##
PRIMARY KEY (exon_id, transcript_id, rank)#,
#KEY exon (exon_id),
#KEY transcript ( transcript_id)
);
> SELECT COUNT(*), COUNT(DISTINCT exon_id), COUNT(DISTINCT transcript_id) FROM exon_transcript;
+----------+-------------------------+-------------------------------+
| COUNT(*) | COUNT(DISTINCT exon_id) | COUNT(DISTINCT transcript_id) |
+----------+-------------------------+-------------------------------+
| 248445 | 248445 | 248445 |
+----------+-------------------------+-------------------------------+
1 row in set (0.00 sec)
> SELECT COUNT(*), SUM(exon_id is null), COUNT(DISTINCT exon_id), COUNT(DISTINCT transcript_id) FROM exon_transcript;
ensrw@mysql-eg-staging-2.ebi.ac.uk:4275 (oryza_sativa_core_22_75_7)
> SELECT COUNT(*) FROM exon_transcript;
+----------+
| COUNT(*) |
+----------+
| 248445 |
+----------+
1 row in set (0.00 sec)
SELECT
s.name
FROM
seq_region s
INNER JOIN
seq_region_attrib USING (seq_region_id)
INNER JOIN
coord_system c USING (coord_system_id)
LEFT JOIN
assembly ON seq_region_id = asm_seq_region_id
SERVER1=mysql-devel-2
SERVER2=mysql-staging-1-ensrw
A="SELECT xref.* "
B="SELECT object_xref.* "
C="SELECT ontology_xref.* "
BASE="
FROM
ontology_xref
CURRENT:
solanum_lycopersicum_core_21_74_240
+----------+------+-------+---------------------+----------------+----------------+----------------------+
| COUNT(*) | XREF | OBJS | ensembl_object_type | external_db_id | external_db_id | db_name |
+----------+------+-------+---------------------+----------------+----------------+----------------------+
| 44538 | 1470 | 15954 | Translation | 1000 | 1200 | Interpro |
| 6082 | 710 | 1266 | Translation | 1000 | 2000 | Uniprot/SPTREMBL |
| 2286 | 426 | 333 | Translation | 1000 | 2200 | Uniprot/SWISSPROT |
| 37342 | 2956 | 6694 | Translation | 1000 | 50720 | Ensembl Plants |
+----------+------+-------+---------------------+----------------+----------------+----------------------+
#!perl
use strict;
use warnings;
=pod
Script to grab the peptide sequence of a given ID from the DB
=cut