chip-job-save-result 1.24 KB
Newer Older
1
#!/usr/bin/env python
2
3
import chipathlon.db
import argparse
4
5
import yaml
import os
6

7
parser = argparse.ArgumentParser(description="Insert a bed file into the database.")
8
9
10
parser.add_argument("-u", "--username", dest="username", help="Database username (if required).")
parser.add_argument("-p", "--password", dest="password", help="Database password (if required).")
parser.add_argument("-d", "--host", dest="host", default="localhost", help="Database host. (default: %(default)s)")
11
parser.add_argument("-f", "--file", dest="file", required=True, help="Path to result file.")
12
parser.add_argument("-m", "--meta", dest="meta", required=True, help="Path to meta yaml file.")
13
args = parser.parse_args()
14

15
if os.path.isfile(args.file) and os.path.isfile(args.meta) and os.path.getsize(args.file) > 0:
16
17
18
    mdb = chipathlon.db.MongoDB(args.host, args.username, args.password)
    with open(args.meta, "r") as rh:
        meta = yaml.load(rh)
19
20
    valid = False
    msg = ""
21

22
23
24
25
26
27
28
    valid, msg, data = mdb.save_result(
        args.file,
        meta["control_sample_accessions"],
        meta["signal_sample_accessions"],
        meta["result_type"],
        meta
    )
29
30

    print msg
31

32
33
else:
    print "Either input file %s or meta file %s does not exist." % (args.file, args.meta)