Skip to content

Instantly share code, notes, and snippets.

View endrebak's full-sized avatar
🧬
Trying to write a genomic library in Rust

endrebak.ada endrebak

🧬
Trying to write a genomic library in Rust
View GitHub Profile
@borkdude
borkdude / specfn.clj
Last active January 7, 2022 13:34
Use a spec for defining function arguments and get validation automatically
(ns specfn.core
(:require [clojure.spec :as s]
[clojure.spec.test :as t]))
(defn- spec-symbols [s]
(->> s
(drop 1)
(partition-all 2)
(map first)
(map name)
# Example for https://www.biostars.org/p/193145
import pybedtools
import pysam
# Use an example BAM file included with pybedtools
fn = pybedtools.example_filename('x.bam')
bam = pysam.Samfile(fn, 'r')
# Filter reads using pysam. Since all aspects of the SAM-format read
@verma
verma / Datascript101-Chapter2.clj
Created May 6, 2016 17:07
Datascript101 - Chapter 2
(ns dt.core
(:require [datascript.core :as d]))
;; schema so nice
(def schema {:maker/email {:db/unique :db.unique/identity}
:car/model {:db/unique :db.unique/identity}
:car/maker {:db/type :db.type/ref}
:car/colors {:db/cardinality :db.cardinality/many}})
%%file _chi2.c
#include <Python.h>
#include <numpy/arrayobject.h>
#include "chi2.h"
static char module_docstring[] =
"This module provides an interface for calculating chi-squared using C.";
static char chi2_docstring[] =
"Calculate the chi-squared of some data given a model.";
@PoisonAlien
PoisonAlien / readBam.C
Last active November 9, 2023 21:21
reading bam files in C using htslib
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <htslib/sam.h>
int main(int argc, char *argv[]){
samFile *fp_in = hts_open(argv[1],"r"); //open bam file
bam_hdr_t *bamHdr = sam_hdr_read(fp_in); //read header
bam1_t *aln = bam_init1(); //initialize an alignment
@Chort409
Chort409 / gist:eb46f4d95261d9af51e9
Created November 26, 2014 03:33
Sql like join in clojure
(ns sql-like-join
(:require [clojure.set :refer [difference
intersection
union]]))
(defn inner-join
[left-keys right-keys]
(intersection (set left-keys) (set right-keys)))
(defn outer-join
@nicoddemus
nicoddemus / README.md
Last active April 15, 2022 19:23
Example on how to structure a package and testing modules

Arrange files like this:

apple/
  __init__.py
  apple.py
tests/
  test_everything.py
@Integralist
Integralist / Let Destructuring.md
Last active February 13, 2023 19:35
Clojure destructuring using `let` (which allows local storage inside of a function, we would say a local "variable" but that would be misleading because all data is immutable in Clojure)

In Clojure you can apply destructuring within either a let binding list; function parameter list or even a macro.

A simple example would be:

(def coords [5 7]) ; define a symbol "coords" that points to a vector [5 7]
(let [[x y] coords] (println "x:" x "y:" y))
; => x: 5 y: 7
@rxaviers
rxaviers / gist:7360908
Last active May 8, 2024 23:25
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: