Skip to content

Instantly share code, notes, and snippets.

View rvprasad's full-sized avatar

Venkatesh-Prasad Ranganath rvprasad

View GitHub Profile
@rvprasad
rvprasad / test_pool_map.py
Last active October 21, 2017 01:17
Illustrates performance degradation when large data chunks are used with multiprocesing module in Python.
# Python -- v3.6
import begin
import multiprocessing
import time
def worker(varying_data, aux_data):
t = 0
for j in range(1, 10000):
@rvprasad
rvprasad / testClosuresAndClasses.groovy
Last active October 21, 2017 02:06
Illustrates when Java's method resolution is not honored in Groovy.
class A {
protected foo() {
this.bar("Site foo1")
def x = {
println("This: ${this.class}")
this.bar("Site foo2")
}
x()
}
@rvprasad
rvprasad / mapper-par.py
Last active November 3, 2017 23:57
Maps each alignment (in BAM) to reference gene sequence data (in GFF) and its description (in Description file).
# python2.7
#
# Before using the script, execute the following.
# PYTHONPATH=~/.pip easy_install --install-dir=~/.pip intervaltree
# PYTHONPATH=~/.pip easy_install --install-dir=~/.pip plac
#
# To run the script, use the following command
# PYTHONPATH=~/.pip python2.7 mapper-par.py <desc> <gff> <bam> <output>
# <# cores>
@rvprasad
rvprasad / build.gradle
Last active March 12, 2018 00:39
(Ghera) Automating multi-app functional testing against different versions of Android
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
@rvprasad
rvprasad / 3NumSorter.groovy
Last active April 11, 2018 18:59
Sorts three numbers by encoding the sorting problem as a SAT problem
/*
* Copyright (c) 2018, Venkatesh-Prasad Ranganath
*
* Licensed under BSD 3-clause License
*
* Author: Venkatesh-Prasad Ranganath
*/
// Sorts three numbers using SAT solving
// Script uses z3 solver (https://github.com/Z3Prover/z3)
@rvprasad
rvprasad / simpleSudokuSolver.groovy
Last active April 14, 2018 17:41
Solves a simplified version of sudoku (w/ only row and column constraints) using z3 SAT solver
/*
* Copyright (c) 2018, Venkatesh-Prasad Ranganath
*
* Licensed under BSD 3-clause License
*
* Author: Venkatesh-Prasad Ranganath
*/
// Solves a simplified version of sudoku (w/ only row and column constraints)
// using SAT solving
@rvprasad
rvprasad / bfsSolver.groovy
Created April 15, 2018 08:09
Identifies a BFS traversal order of nodes of a given directed graph using z3 solver
/*
* Copyright (c) 2018, Venkatesh-Prasad Ranganath
*
* Licensed under BSD 3-clause License
*
* Author: Venkatesh-Prasad Ranganath
*/
import groovy.transform.Field
@rvprasad
rvprasad / bfsSolver2.groovy
Created April 15, 2018 22:50
Identifies a queue-based BFS traversal order of nodes of a given directed graph using z3 solver
/*
* Copyright (c) 2018, Venkatesh-Prasad Ranganath
*
* Licensed under BSD 3-clause License
*
* Author: Venkatesh-Prasad Ranganath
*/
import groovy.transform.Field
@rvprasad
rvprasad / dfsSolver.groovy
Last active April 16, 2018 03:14
Identifies a DFS traversal order of nodes of a given directed graph using z3 solver
/*
* Copyright (c) 2018, Venkatesh-Prasad Ranganath
*
* Licensed under BSD 3-clause License
*
* Author: Venkatesh-Prasad Ranganath
*/
import groovy.transform.Field
@rvprasad
rvprasad / anonymizeNames.py
Last active May 5, 2018 20:41
Anonymizes the names (in names.txt) without disturbing the order and frequency of alphabet and number positions
from random import randrange, sample, shuffle
alphas = list('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
nums = list('1234567890')
shuffle(alphas)
shuffle(nums)
def scramble(s, seen):
while True:
ret = ''.join([(nums[int(x)] if x in nums else