File: screedCreateTimeit.py

package info (click to toggle)
python-screed 1.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 820 kB
  • sloc: python: 3,356; makefile: 169; sh: 32; javascript: 16
file content (60 lines) | stat: -rwxr-xr-x 1,530 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# Copyright (c) 2016, The Regents of the University of California.

import sys
import timeit

if __name__ == '__main__':
    if len(sys.argv) != 3:
        print "Usage: %s <filename> <fa/fq>" % sys.argv[0]
        exit(1)

    filename = sys.argv[1]
    fafq = sys.argv[2]

    fqrunStatement = """
createscreed.create_db(filename, fastq.FieldTypes, iterfunc)
theFile.close()
"""

    fqsetupStatement = """
import os, sys
thisdir = sys.path[0]
libdir = os.path.abspath(os.path.join(thisdir, '..', 'screed'))
sys.path.insert(0, libdir)
import createscreed
import fastq
FASTQFIELDTYPES = ('name', 'annotations', 'sequence', 'quality')
filename = '%s'
theFile = open(filename, 'rb')
iterfunc = fastq.fastq_iter(theFile)
""" % filename

    farunStatement = """
createscreed.create_db(filename, fasta.FieldTypes, iterfunc)
theFile.close()
"""

    fasetupStatement = """
import os, sys
thisdir = sys.path[0]
libdir = os.path.abspath(os.path.join(thisdir, '..', 'screed'))
sys.path.insert(0, libdir)
import createscreed
import fasta
FASTAFIELDTYPES = ('name', 'description', 'sequence')
filename = '%s'
theFile = open(filename, 'rb')
iterfunc = fasta.fasta_iter(theFile)
""" % filename

    t = None
    if fafq == 'fasta':
        t = timeit.Timer(farunStatement, fasetupStatement)
    elif fafq == 'fastq':
        t = timeit.Timer(fqrunStatement, fqsetupStatement)
    else:
        raise ValueError("Invalid db type specified: %s" % fafq)

    print "[SCREED CREATE]%s:" % filename
    print t.repeat(2, 1)