Skip to content

Commit

Permalink
gb/mb conversion corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
SooLee committed Sep 12, 2017
1 parent 68fd6ac commit dfbfcd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 7 additions & 4 deletions Benchmark/Benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# AWS-related information including recommended_instance_type, ebs_size, EBS_optimized, etc.


GB_IN_BYTES = 1073741824
MB_IN_BYTES = 1048576

class BenchmarkResult(object):

def __init__(self, size, mem, cpu):
Expand Down Expand Up @@ -40,7 +43,7 @@ def md5(input_json):
assert 'input_size_in_bytes' in input_json
assert 'input_file' in input_json.get('input_size_in_bytes')

r = BenchmarkResult(size=input_json.get('input_size_in_bytes').get('input_file') / 1048576 + 3,
r = BenchmarkResult(size=input_json.get('input_size_in_bytes').get('input_file') / GB_IN_BYTES + 3,
mem=4,
cpu=1)

Expand All @@ -56,7 +59,7 @@ def fastqc_0_11_4_1(input_json):
if 'threads' in input_json.get('parameters'):
nthreads = input_json.get('parameters').get('threads')

r = BenchmarkResult(size=input_json.get('input_size_in_bytes').get('input_fastq') / 1048576 * 2 + 3,
r = BenchmarkResult(size=input_json.get('input_size_in_bytes').get('input_fastq') / GB_IN_BYTES * 2 + 3,
mem=300 * nthreads,
cpu=nthreads)

Expand Down Expand Up @@ -85,10 +88,10 @@ def bwa_mem(input_json):
total_output_size = output_bam_size
additional_size_in_gb = 4.5

total_size = (total_input_size + total_intermediate_size + total_output_size) / 1048576 + additional_size_in_gb
total_size = (total_input_size + total_intermediate_size + total_output_size) / GB_IN_BYTES + additional_size_in_gb

# mem
mem = input_sizes.get('bwa_index') * 4 / 1024
mem = input_sizes.get('bwa_index') * 4 / MB_IN_BYTES

r = BenchmarkResult(size=total_size, mem=mem, cpu=nthreads)

Expand Down
10 changes: 5 additions & 5 deletions tests/tests_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ def test_get_optimal_instance_type2(self):

class TestBenchmark(unittest.TestCase):
def test_benchmark1(self):
res = B.benchmark('md5', {'input_size_in_bytes': {'input_file': 20000}})
res = B.benchmark('md5', {'input_size_in_bytes': {'input_file': 200000000}})
assert 'aws' in res
assert 'recommended_instance_type' in res['aws']
assert res['aws']['recommended_instance_type'] == 't2.nano'
print(res)

def test_benchmark2(self):
res = B.benchmark('fastqc-0-11-4-1', {'input_size_in_bytes': {'input_fastq': 20000},
res = B.benchmark('fastqc-0-11-4-1', {'input_size_in_bytes': {'input_fastq': 20000000000},
'parameters': {'threads': 2}})
assert 'aws' in res
assert 'recommended_instance_type' in res['aws']
assert res['aws']['recommended_instance_type'] == 't2.medium'
print(res)

def test_benchmark3(self):
input_json = {'input_size_in_bytes': {'fastq1': 93520,
'fastq2': 97604,
'bwa_index': 3364568},
input_json = {'input_size_in_bytes': {'fastq1': 93520000,
'fastq2': 97604000,
'bwa_index': 3364568000},
'parameters': {'nThreads': 4}}
res = B.benchmark('bwa-mem', input_json)
assert 'aws' in res
Expand Down

0 comments on commit dfbfcd7

Please sign in to comment.