Mercurial > repos > sanbi-uwc > vcf2neo
comparison vcf2neo_wrapper.py @ 0:3e14eda348d3 draft default tip
planemo upload for repository https://github.com/sanbi-sa/tools-sanbi-uwc commit 0245b4efed8ced6d06d76f1249a47d2178285385
author | sanbi-uwc |
---|---|
date | Mon, 19 Jun 2017 00:08:18 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3e14eda348d3 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 from __future__ import print_function | |
4 import argparse | |
5 import os | |
6 import shlex | |
7 import subprocess | |
8 import uuid | |
9 import sys | |
10 | |
11 parser = argparse.ArgumentParser( | |
12 description="Call vcf2neo on VCF inputs from Galaxy") | |
13 | |
14 parser.add_argument('--vcf_dataset_names', nargs='+', | |
15 help='Names of VCF datasets') | |
16 parser.add_argument('--neo4j_db_path', help='Neo4j database directory') | |
17 parser.add_argument('--user', help='Email of Galaxy user running this tool') | |
18 parser.add_argument('--variantset_name', | |
19 help='Name for the VariantSet containing all the variants') | |
20 parser.add_argument('--vcf_files', | |
21 help='VCF format variant file', nargs='+') | |
22 | |
23 args = parser.parse_args() | |
24 | |
25 os.mkdir(args.variantset_name) | |
26 | |
27 print("VCF names:", len(args.vcf_dataset_names), args.vcf_dataset_names, file=sys.stderr) | |
28 print("VCF files:", len(args.vcf_files), args.vcf_files, file=sys.stderr) | |
29 for i, vcf_file in enumerate(args.vcf_files): | |
30 print("XXXX I:", i, vcf_file, file=sys.stderr) | |
31 callset_name = args.vcf_dataset_names[i] | |
32 os.symlink(vcf_file, os.path.join(args.variantset_name, | |
33 callset_name) + '.vcf') | |
34 # Usage: vcf2neo init [OPTIONS] VCF_DIR OWNER [HISTORY_ID] [OUTPUT_DIR] | |
35 # | |
36 # Copy reference database and load VCF to Neo4j Graph database. :param | |
37 # vcf_dir: :param refdb_dir: :param d: :return: | |
38 # | |
39 # Options: | |
40 # -d / -D Run Neo4j docker container. | |
41 # --help Show this message and exit. | |
42 | |
43 history_id = str(uuid.uuid4()) | |
44 cmd_str = ('vcf2neo init -d ' + | |
45 '{input_vcf_dir} {email} {history_id} {neo4j_db_path}'.format( | |
46 input_vcf_dir=args.variantset_name, | |
47 email=args.user, | |
48 history_id=history_id, | |
49 neo4j_db_path=args.neo4j_db_path)) | |
50 cmd = shlex.split(cmd_str) | |
51 subprocess.check_call(cmd) |