Skip to content

Instantly share code, notes, and snippets.

@jctoledo
jctoledo / gist:9002170
Created February 14, 2014 14:43
cycle size distribution of cycles that are in rna ligand neighbourhoods
select STR(?size) as ?cycle_size COUNT(?a) as ?frequency
from <http://bio2rdf.org/narf:rna_cycles>
where{
?a a <http://bio2rdf.org/narf_vocabulary:cycle>.
?a <http://bio2rdf.org/narf_vocabulary:has_attribute> ?c.
?a <http://bio2rdf.org/narf_vocabulary:has_attribute> ?d.
?d a <http://bio2rdf.org/narf_vocabulary:cycle_size>.
?d <http://bio2rdf.org/narf_vocabulary:has_value> ?size.
?c a <http://bio2rdf.org/narf_vocabulary:cycle_profile_level_2> .
?c <http://bio2rdf.org/narf_vocabulary:has_md5hash> ?ahash .
@jctoledo
jctoledo / gist:9002044
Created February 14, 2014 14:38
get the cycle size distribution of all rna cycles
select STR(?size) as ?cycle_size COUNT(?a) as ?frequency
from <http://bio2rdf.org/narf:rna_cycles>
where{
?a a <http://bio2rdf.org/narf_vocabulary:cycle>.
?a <http://bio2rdf.org/narf_vocabulary:has_attribute> ?c.
?a <http://bio2rdf.org/narf_vocabulary:has_attribute> ?d.
?d a <http://bio2rdf.org/narf_vocabulary:cycle_size>.
?d <http://bio2rdf.org/narf_vocabulary:has_value> ?size.
?c a <http://bio2rdf.org/narf_vocabulary:cycle_profile_level_2> .
?c <http://bio2rdf.org/narf_vocabulary:has_md5hash> ?ahash .
@jctoledo
jctoledo / gist:9001916
Last active August 29, 2015 13:56
query to get the counts of cycles in ligand neighbourhoods
select STR(?ahash) AS ?level2profile COUNT(distinct ?a)
from <http://bio2rdf.org/narf:rna_cycles>
where{
?a a <http://bio2rdf.org/narf_vocabulary:cycle>.
?a <http://bio2rdf.org/narf_vocabulary:has_attribute> ?c.
?c a <http://bio2rdf.org/narf_vocabulary:cycle_profile_level_2> .
?c <http://bio2rdf.org/narf_vocabulary:has_md5hash> ?ahash .
?a <http://bio2rdf.org/narf_vocabulary:has_part> ?ap.
?lh <http://bio2rdf.org/lighood_vocabulary:has_member> ?ap.
}
@jctoledo
jctoledo / gist:8983325
Created February 13, 2014 20:37
get the counts of level 2 profiles in rna structures
select distinct STR(?ahash) AS ?s COUNT(?s)
from <http://bio2rdf.org/narf:rna_cycles>
where{
?a a <http://bio2rdf.org/narf_vocabulary:cycle>.
?a <http://bio2rdf.org/narf_vocabulary:has_attribute> ?c.
?c a <http://bio2rdf.org/narf_vocabulary:cycle_profile_level_2> .
?c <http://bio2rdf.org/narf_vocabulary:has_md5hash> ?ahash .
}
protected String execute(Sequence aSequence, String[] commands)
throws InvalidSequenceException, IOException {
String returnMe = "";
if (aSequence.getLength() == 0) {
throw new InvalidSequenceException(
"The sequence provided to execute RNAFold was empty!");
}
String[] cmdArr = new String[commands.length + 1];
System.arraycopy(new String[] { "RNAfold" }, 0, cmdArr, 0, 1);
<?php
function write_predicate_object_counts($fh, $pred_obj_counts){
GLOBAL $dataset_uri;
GLOBAL $options;
if($pred_obj_counts !== null){
foreach($pred_obj_counts as $pred => $count){
#create a resource for the property partition
$partition_res = "http://bio2rdf.org/dataset_resource:".md5($options['url']).md5($options['url'].$pred.$count."predicate_object_count");
#add the dataset type
<?php
function write_predicate_object_counts($fh, $pred_obj_counts){
GLOBAL $options;
if($pred_obj_counts !== null){
foreach($pred_obj_counts as $pred => $count){
fwrite($fh, Quad("http://bio2rdf.org/dataset_resource:".md5($options['url']), "http://bio2rdf.org/dataset_vocabulary:has_predicate_object_count", "http://bio2rdf.org/dataset_resource:".md5($options['url'].$pred.$count."predicate_object_count")));
fwrite($fh, Quad("http://bio2rdf.org/dataset_resource:".md5($options['url'].$pred.$count."predicate_object_count"), "http://bio2rdf.org/dataset_vocabulary:has_predicate", $pred));
fwrite($fh, QuadLiteral("http://bio2rdf.org/dataset_resource:".md5($options['url'].$pred.$count."predicate_object_count"), "http://bio2rdf.org/dataset_vocabulary:has_count", $count));
}
<?php
function get_void_dataset_uri(){
GLOBAL $cmd_pre;
GLOBAL $cmd_post;
$q = "select ?x where {?w <http://rdfs.org/ns/void#inDataset> ?x.}LIMIT 1";
$cmd = $cmd_pre.$q.$cmd_post;
$out = "";
try{
$out = execute_isql_command($cmd);
}catch(Exception $e){
<?php
function write_type_counts($fh, $type_counts){
GLOBAL $options;
GLOBAL $dataset_uri;
if($type_counts !== null){
foreach($type_counts as $type => $count){
#now create a resource for the class partition
$partition_res = "http://bio2rdf.org/dataset_resource:".md5($options['url']).md5($options['url'].$type.$count."type_count");
fwrite($fh, Quad($partition_res, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://rdfs.org/ns/void#Dataset"));
fwrite($fh, Quad($partition_res, "http://rdfs.org/ns/void#class", $type));
@jctoledo
jctoledo / gist:6622850
Created September 19, 2013 12:40
Find details about a given ligand in a PDB structure using biopython
from Bio.PDB import *
import sys
p = PDBParser(PERMISSIVE=1)
ligand_id = "ADE"
radius = 5.4
pdbl = PDBList()
structure_id = "1Y26"
pdbl.retrieve_pdb_file(structure_id, pdir="/tmp")
filename = "1y26.pdb"
#see for more details: http://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc153