Skip to content

Instantly share code, notes, and snippets.

View lpand's full-sized avatar

Luca Pandini lpand

View GitHub Profile
@lpand
lpand / graph_config_test.js
Created September 28, 2013 22:07
graph configuration
var nodes = [
{ name: 0, value: 0 },
{ name: 1, value: 1 },
{ name: 2, value: 2 },
{ name: 3, value: 3 }
]
var edges = [
{ source: nodes[0], target: nodes[1] },
@lpand
lpand / force_layout_tick.js
Last active December 24, 2015 05:39
Keeps the bubbles inside the force bounds and draws text if so configured
config.force.tick = function() {
graphChart.links.attr({
x1: function(d) { return d.source.x },
y1: function(d) { return d.source.y },
x2: function(d) { return d.target.x },
y2: function(d) { return d.target.y } })
graphChart.bubbles
.selectAll('circle')
.attr({
@lpand
lpand / martexplorer.js
Created September 30, 2013 16:06
This is the martexplorer main.js hardcoded!
(function($) {
/*
* Author: jhsu
*
* This file + required modules contains all the JavaScript to run MartExplorer.
*
* The workflow starts from the biomart.martexplorer.init function, and ends with _stepCallback function.
*
* The _stepCallback function has an array (bound by closure) that maps to each of the four steps.
function resizeHandler () {
if (this._svg && !this._svg.empty()) {
this._svg.attr({
width: $(window).width()
height: $(window).height()
})
}
}
function resize (listener, interval) {

Weighted Network

We're going to gather gene pairs from single query results searching for genes sharing the same annotation term.

G1 A1

G2 A1 -> G1 G2 A1

G2 A3

image

Exercise 2

Implement a recursive procedure (function/class, you choose) that answers to the eight-queens puzzle problem.

The eight-queens puzzle asks how to place eight queens on a chessboard so that no queen is in check from any other (i.e., no two queens are in the same row, column, or diagonal).

Spoiler: one possible solution

One possible solution is shown in figure 2.8. One way to solve the puzzle is to work across the board, placing a queen in each column. Once we have placed k - 1 queens, we must place the kth queen in a position where it does not check any of the queens already on the board. We can formulate this approach recursively: Assume that we have already generated the sequence of all possible ways to place k - 1 queens in the first k - 1 columns of the board. For each of these ways, generate an extended set of positions by placing a queen in each row of the kth column. Now filter these, keeping only th

@lpand
lpand / enrichment_data.json
Last active August 29, 2015 13:56
Enrichment front-end app data format
{
"Gene Ontology (GO)": {
"header": {
"type": "annotation",
"columns": ["id", "status", "..."],
"display_names": ["name", "status", "..."]
},
"nodes": [
{ "id": "", "status": "", "start": "", "type": "term" },
{ "id": "", "foo": "", "bar": "", "type": "gene" },
"use strict";
angular.module("martVisualEnrichment.services", [])
.factory("results",
["$document", "$q", "enrichmentResultsId",
function resultsFactory ($doc, $q, containerId) {
// I'm using a promise such that if we get data with ajax the API won't
// change.
var deffed = $q.defer(),
;(function (angular) {
"use strict";
var app = angular.module("martVisualEnrichment.directives");
/**
*
* This implementation is highly inspired by https://github.com/angular-ui/bootstrap/blob/master/src/tabs/tabs.js
*