Skip to content

Instantly share code, notes, and snippets.

@betatim
Forked from ctb/README.md
Last active April 6, 2017 08:41
Show Gist options
  • Save betatim/24886949ded51b90a3ca066c2a7f0439 to your computer and use it in GitHub Desktop.
Save betatim/24886949ded51b90a3ca066c2a7f0439 to your computer and use it in GitHub Desktop.
benchmarking RAM allocation against file load time
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /usr/bin/env python
from __future__ import print_function, unicode_literals
import json
import os
import sys
import threading
import textwrap
import khmer
from khmer import khmer_args
from khmer.khmer_args import (build_counting_args, report_on_config, info,
add_threading_args, calculate_graphsize,
sanitize_help)
from khmer.kfile import check_file_writable
from khmer.kfile import check_input_files
from khmer.kfile import check_space_for_graph
from khmer.khmer_logger import (configure_logging, log_info, log_error,
log_warn)
import time
def get_parser():
parser = build_counting_args("Build a k-mer countgraph from the given"
" sequences.",
citations=['counting', 'SeqAn'])
add_threading_args(parser)
parser.add_argument('input_sequence_filename', nargs='+',
help="The names of one or more FAST[AQ] input "
"sequence files.")
parser.add_argument('-b', '--no-bigcount', dest='bigcount', default=True,
action='store_false', help="The default behaviour is "
"to count past 255 using bigcount. This flag turns "
"bigcount off, limiting counts to 255.")
parser.add_argument('--summary-info', '-s', type=str, default=None,
metavar="FORMAT", choices=[str('json'), str('tsv')],
help="What format should the machine readable run "
"summary be in? (`json` or `tsv`, disabled by"
" default)")
parser.add_argument('-f', '--force', default=False, action='store_true',
help='Overwrite output file if it exists')
parser.add_argument('-q', '--quiet', dest='quiet', default=False,
action='store_true')
return parser
def main():
args = sanitize_help(get_parser()).parse_args()
configure_logging(args.quiet)
report_on_config(args)
filenames = args.input_sequence_filename
log_info('making countgraph')
start = time.time()
countgraph = khmer_args.create_countgraph(args)
countgraph.set_use_bigcount(False)
filename = None
total_num_reads = 0
for index, filename in enumerate(filenames):
log_info('consuming input {input}', input=filename)
rparser = khmer.ReadParser(filename)
countgraph.consume_seqfile_with_reads_parser(rparser)
total_num_reads += rparser.num_reads
log_info('DONE.')
end = time.time()
print(sum(countgraph.hashsizes()), end - start)
if __name__ == '__main__':
main()
# vim: set filetype=python tabstop=4 softtabstop=4 shiftwidth=4 expandtab:
# vim: set textwidth=79:
4999802 0.4022336006164551
9999936 0.48936963081359863
29999776 0.5291144847869873
49999814 0.5460047721862793
69999944 0.539546012878418
99999894 0.53822922706604
299999702 0.5722751617431641
499999864 0.5797789096832275
699999898 0.5983734130859375
999999738 0.6348459720611572
1499999852 0.6900534629821777
1999999730 0.8068392276763916
2499999828 0.9725027084350586
2999999808 1.1501619815826416
3499999818 1.3291537761688232
3999999642 1.4660162925720215
4999802 0.3771378993988037
9999936 0.49471521377563477
29999776 0.525113582611084
49999814 0.5299384593963623
69999944 0.5365993976593018
99999894 0.5531153678894043
299999702 0.5583016872406006
499999864 0.5734982490539551
699999898 0.5956308841705322
999999738 0.629561185836792
1499999852 0.6850724220275879
1999999730 0.8040111064910889
2499999828 0.9678001403808594
2999999808 1.1466901302337646
3499999818 1.322319746017456
3999999642 1.4637532234191895
4999802 0.0018587112426757812
9999936 0.0028929710388183594
29999776 0.00555109977722168
49999814 0.007618427276611328
69999944 0.009627342224121094
99999894 0.0139312744140625
299999702 0.04141545295715332
499999864 0.0646371841430664
699999898 0.08468151092529297
999999738 0.11422371864318848
1499999852 0.16438937187194824
1999999730 0.27019166946411133
2499999828 0.40791988372802734
2999999808 0.5306522846221924
3499999818 0.6612265110015869
3999999642 0.7718324661254883
4999802 0.37587928771972656
9999936 0.49825572967529297
29999776 0.5420515537261963
49999814 0.5313012599945068
69999944 0.5375802516937256
99999894 0.5366525650024414
299999702 0.5557835102081299
499999864 0.5917420387268066
699999898 0.5949039459228516
999999738 0.6410195827484131
1499999852 0.6821684837341309
1999999730 0.8242173194885254
2499999828 0.9777994155883789
2999999808 1.1413724422454834
3499999818 1.3187227249145508
3999999642 1.4773304462432861
4999802 0.3691437244415283
9999936 0.5023326873779297
29999776 0.5218846797943115
49999814 0.5303599834442139
69999944 0.5355379581451416
99999894 0.5363118648529053
299999702 0.5636279582977295
499999864 0.5696682929992676
699999898 0.598691463470459
999999738 0.6327526569366455
1499999852 0.6800453662872314
1999999730 0.7989273071289062
2499999828 0.9779486656188965
2999999808 1.1559679508209229
3499999818 1.3215265274047852
3999999642 1.4892635345458984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment