Skip to content

Instantly share code, notes, and snippets.

@jctoledo
jctoledo / terrible_idea.py
Last active June 10, 2020 00:30
terrible summer
import sys
import time
import random
def is_prime(n):
if (n <= 1) :
return False
if (n <= 3) :
return True
@jctoledo
jctoledo / gist:d08752760c6bc1a9e2b2
Created July 11, 2014 15:59
Void queries - subset
<?php
function getGraphs()
{
global $options;
$sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {[] a ?o}}";
$r = query($sparql);
foreach($r AS $g) {
$graphs[] = $g->g->value;
}
import os
def split(filehandler, delimiter=',', row_limit=10000,
output_name_template='output_%s.csv', output_path='.', keep_headers=True):
"""
Splits a CSV file into multiple pieces.
A quick bastardization of the Python CSV library.
Arguments:
@jctoledo
jctoledo / gist:9792228
Created March 26, 2014 20:15
find the info about a cycle given its hash
select *
where{
?mcb <http://bio2rdf.org/narf_vocabulary:derived_from> <http://bio2rdf.org/pdb:3MEI>.
?mcb <http://bio2rdf.org/narf_vocabulary:has_member> ?c.
?c <http://bio2rdf.org/narf_vocabulary:has_attribute> ?att.
?att <http://bio2rdf.org/narf_vocabulary:has_md5hash> ?val.
FILTER regex(?val,"445c69d2714e43b727182b7496657eb1")
}
@jctoledo
jctoledo / gist:9788419
Created March 26, 2014 17:17
get cycle profile counts and counts of structures
select STR(?ahash) AS ?s STR(?size) as ?cycle_size COUNT(?a) AS ?profile_count COUNT(distinct ?pdb_record) AS ?pdb_count
from <http://bio2rdf.org/rna_cycles_pdb>
where{
?mcb a <http://bio2rdf.org/narf_vocabulary:mcb>.
?mcb <http://bio2rdf.org/narf_vocabulary:derived_from> ?pdb_record.
?mcb <http://bio2rdf.org/narf_vocabulary:has_member> ?a.
?a a <http://bio2rdf.org/narf_vocabulary:cycle>.
?a <http://bio2rdf.org/narf_vocabulary:has_attribute> ?cs.
?cs a <http://bio2rdf.org/narf_vocabulary:cycle_size>.
?cs <http://bio2rdf.org/narf_vocabulary:has_value> ?size.
@jctoledo
jctoledo / gist:9775522
Created March 26, 2014 01:53
get a list of all cycle uris and the size of their respective fist degree neighbourhood
select distinct ?a count(?b)
from <http://bio2rdf.org/rna_cycles_pdb>
where{
?a a <http://bio2rdf.org/narf_vocabulary:cycle>.
?fdn a <http://bio2rdf.org/narf_vocabulary:first_degree_cycle_neighbour_set>.
?a <http://bio2rdf.org/narf_vocabulary:has_attribute> ?fdn.
?fdn <http://bio2rdf.org/narf_vocabulary:has_member> ?b.
}
@jctoledo
jctoledo / gist:9763950
Created March 25, 2014 15:16
range of minimum cycle sizes that belong to ligand neighbourhoods
select distinct STR(?size) as ?s
from <http://bio2rdf.org/rna_cycles_pdb>
where{
?a a <http://bio2rdf.org/pdb_vocabulary:Experiment>.
?mcb <http://bio2rdf.org/narf_vocabulary:derived_from> ?a.
?a <http://bio2rdf.org/pdb_vocabulary:hasPart> ?cse.
?cse a <http://bio2rdf.org/pdb_vocabulary:ChemicalSubstanceExtraction>.
?cse <http://bio2rdf.org/pdb_vocabulary:hasProduct> ?polymer.
?polymer a <http://bio2rdf.org/pdb_vocabulary:Polymer>.
?residue <http://bio2rdf.org/pdb_vocabulary:isPartOf> ?polymer.
@jctoledo
jctoledo / gist:9763755
Created March 25, 2014 15:08
get the counts of cycles that belong to ligand neighbourhoods
select count (distinct ?cyc)
from <http://bio2rdf.org/rna_cycles_pdb>
where{
?a a <http://bio2rdf.org/pdb_vocabulary:Experiment>.
?mcb <http://bio2rdf.org/narf_vocabulary:derived_from> ?a.
?a <http://bio2rdf.org/pdb_vocabulary:hasPart> ?cse.
?cse a <http://bio2rdf.org/pdb_vocabulary:ChemicalSubstanceExtraction>.
?cse <http://bio2rdf.org/pdb_vocabulary:hasProduct> ?polymer.
?polymer a <http://bio2rdf.org/pdb_vocabulary:Polymer>.
?residue <http://bio2rdf.org/pdb_vocabulary:isPartOf> ?polymer.
@jctoledo
jctoledo / gist:9762925
Created March 25, 2014 14:24
get the count of minimum cycles
select count (distinct ?cyc)
from <http://bio2rdf.org/rna_cycles_pdb>
where{
?a a <http://bio2rdf.org/pdb_vocabulary:Experiment>.
?mcb <http://bio2rdf.org/narf_vocabulary:derived_from> ?a.
?mcb <http://bio2rdf.org/narf_vocabulary:has_member> ?cyc.
}
@jctoledo
jctoledo / gist:9762862
Created March 25, 2014 14:23
get the range of numbers of base pairs
select ?a count (distinct ?bp) as ?c
from <http://bio2rdf.org/rna_cycles_pdb>
where{
?a a <http://bio2rdf.org/pdb_vocabulary:Experiment>.
?mcb <http://bio2rdf.org/narf_vocabulary:derived_from> ?a.
?a <http://bio2rdf.org/pdb_vocabulary:hasPart> ?cse.
?cse a <http://bio2rdf.org/pdb_vocabulary:ChemicalSubstanceExtraction>.
?cse <http://bio2rdf.org/pdb_vocabulary:hasProduct> ?polymer.
?polymer a <http://bio2rdf.org/pdb_vocabulary:Polymer>.
?residue <http://bio2rdf.org/pdb_vocabulary:isPartOf> ?polymer.