-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simon van Heeringen
committed
Mar 10, 2014
1 parent
61d55c2
commit e371116
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python | ||
# Create test set for use with pita | ||
import os | ||
import sys | ||
import yaml | ||
import argparse | ||
import random | ||
|
||
p = argparse.ArgumentParser() | ||
p.add_argument("-c", | ||
dest= "configfile", | ||
help="Input configuration file" | ||
) | ||
p.add_argument("-n", | ||
dest= "numchroms", | ||
type=int, | ||
help="Number of chromosomes / regions per file", | ||
) | ||
p.add_argument("-o", | ||
dest= "output", | ||
help="Output base name" | ||
) | ||
|
||
args = p.parse_args() | ||
configfile = args.configfile | ||
numchroms = args.numchroms | ||
outname = args.output | ||
|
||
if not (configfile and numchroms and outname): | ||
p.print_help() | ||
sys.exit() | ||
|
||
# Parse YAML config file | ||
f = open(configfile, "r") | ||
config = yaml.load(f) | ||
|
||
# Output data directoy | ||
if not os.path.exists(outname): | ||
os.mkdir(outname) | ||
else: | ||
print("Output path {0} already exists!".format(outname)) | ||
sys.exit(1) | ||
|
||
# Get chromosomes from BED file | ||
chroms = config["chromosomes"] | ||
random.shuffle(chroms) | ||
|
||
for i in range(0, len(chroms), numchroms): | ||
config['chromosomes'] = chroms[i: i + numchroms] | ||
with open("{0}/{0}_part_{1}.yaml".format(outname, (i / numchroms) + 1), "w") as f: | ||
f.write(yaml.dump(config)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters