-
-
Save brentp/213f214dd5677dd447150e62e2e360f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hts | |
import strutils | |
import times | |
import os | |
const everything = int(8191) | |
proc timeit(path:string, fasta:string, threads:int, except_fields:varargs[SamField]) = | |
var | |
cram: Bam | |
open(cram, path, fai=fasta, threads=threads) | |
var exclude:int | |
var names = newSeq[string]() | |
for e in except_fields: | |
exclude = exclude or e.int | |
var name = $e | |
names.add(name[4..name.high]) | |
if names.len == 0: names = @["nothing"] | |
if exclude != 0: | |
if cram.set_option(FormatOption.CRAM_OPT_REQUIRED_FIELDS, everything - exclude) != 0: | |
quit "couldn't set option:" | |
var t = epochTime() | |
var n = 0 | |
for aln in cram: | |
n += 1 | |
echo join(names, "|"), "\t", threads, "\t", epochTime() - t, "\t", n | |
var | |
path = commandLineParams()[0] | |
fasta = commandLineParams()[1] | |
echo "exclude\tthreads\ttime\treads" | |
for threads in @[0, 1, 2, 4]: | |
timeit(path, fasta, threads) | |
timeit(path, fasta, threads, SAM_SEQ) | |
timeit(path, fasta, threads, SAM_QUAL) | |
timeit(path, fasta, threads, SAM_QNAME, SAM_RNAME) | |
timeit(path, fasta, threads, SAM_RNAME, SAM_AUX, SAM_RGAUX, SAM_RNEXT, SAM_PNEXT, SAM_TLEN) | |
timeit(path, fasta, threads, SAM_QNAME, SAM_SEQ, SAM_QUAL) | |
timeit(path, fasta, threads, SAM_QNAME, SAM_SEQ, SAM_QUAL, SAM_AUX, SAM_RGAUX) | |
timeit(path, fasta, threads, SAM_QNAME, SAM_SEQ, SAM_QUAL, SAM_AUX, SAM_RGAUX, SAM_RNEXT, SAM_PNEXT, SAM_TLEN) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt | |
import seaborn as sns | |
import pandas as pd | |
import sys | |
colors = sns.color_palette() | |
df = pd.read_table(sys.argv[1]) | |
df.exclude = [x.replace("|", "\n") for x in df.exclude] | |
ax = sns.barplot(x="exclude", y="time", hue="threads", data=df) | |
ax.set_xlabel("Exclude Fields") | |
ax.set_ylabel("Time (Seconds)") | |
for t, sd in df.groupby('threads'): | |
baseline = sd.time[sd.exclude == "nothing"] | |
#ax.axhline(y=float(baseline)/3.0, color=colors[t]) | |
#ax.text(0.7, 0.8, "horizontal lines show height of 3X speed improvement over baseline") | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment