root/galaxy-central/eggs/GeneTrack-2.0.0_beta_1_dev_48da9e998f0caf01c5be731e926f4b0481f658f0-py2.6.egg/genetrack/scripts/hdf_loader.py

リビジョン 3, 1.9 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2Genetrack file transformer.
3
4The program may be invoked in multiple ways. As a standalone script::
5
6    python hdf_loader.py
7
8As a python module::
9
10    python -m genetrack.scripts.hdf_loader
11
12Or in other python scripts::
13
14>>>
15>>> from genetrack.scripts import hdf_loader
16>>> hdf_loader.transform(inpname)
17>>>
18
19Run the script with no parameters to see the options that it takes.
20
21**Observed runtime**: insertion rate of 6 million lines per minute
22
23"""
24import os, sys, csv
25from genetrack import logger, conf, util, hdflib
26
27
28def transform(inpname, workdir=None, update=False):
29    """
30    Creates a transform from a genetrack input file
31    """
32    index = hdflib.PositionalData(fname=inpname, workdir=workdir, update=update)       
33    return index
34
35if __name__ == '__main__':
36    import optparse
37
38    usage = "usage: %prog -i inputfile"
39
40    parser = optparse.OptionParser(usage=usage)
41
42    # setting the input file name
43    parser.add_option(
44        '-i', '--input', action="store",
45        dest="inpname", type='str', default=None,
46        help="the input file name (required)"
47    )
48
49    # setting the output file name
50    parser.add_option(
51        '-w', '--workdir', action="store",
52        dest="workdir", type='str', default=None,
53        help="work directory (optional)"
54    )
55
56    # verbosity can be 0,1 and 2 (increasing verbosity)
57    parser.add_option(
58        '-v', '--verbosity', action="store",
59        dest="verbosity", type="int", default=1,
60        help="sets the verbosity (0, 1) (default=1)",
61    )
62
63    parser.add_option("-u", "--update",
64        action="store_true", dest="update", default=False,
65        help="recreates the index even if it exists")
66
67    options, args = parser.parse_args()
68
69    # set verbosity
70    logger.disable( options.verbosity )
71
72    # missing input file name
73    if not options.inpname:
74        parser.print_help()
75    else:
76        transform(inpname=options.inpname, workdir=options.workdir, update=options.update)
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。