Commit 31565450 authored by LANORE Vincent's avatar LANORE Vincent
Browse files

Added bin specification in generate_pairs command line (not yet implemented)

parent 2c31730e
......@@ -33,13 +33,15 @@ Usage:
generate_pairs.py [options...] -o <output-prefix> <profiles-file>
Positional arguments:
profiles-file the file to read profile from
profiles-file the file to read profile from
Options:
-h, --help show this help message and exit
-o, --output-file <filename>
output prefix; files will be names <prefix>_1.tsv,
<prefix>_2.tsv and so on"""
-h, --help show this help message and exit
-o, --output-prefix <filename>
output prefix; files will be names <prefix>_1.tsv,
<prefix>_2.tsv and so on
-b, --bins <spec> bin specification in the form of a list of intervals
[default: [0,0.4],[0.4,0.6],[0.6,2]]"""
from diffsel_script_utils import *
......@@ -50,8 +52,38 @@ from docopt import docopt
args = docopt(__doc__)
profiles_file = args["<profiles-file>"]
MESSAGE("Profile file is " + param(profiles_file))
out = args["--output-file"]
MESSAGE("Output file is " + param(out))
out = args["--output-prefix"]
MESSAGE("Output prefix is " + param(out))
binspec = args["--bins"][0]
MESSAGE("Bin specification is " + param(binspec))
#===================================================================================================
STEP("Parsing bin specification")
try:
binspec = binspec.split("],[")
binspec[0] = binspec[0][1:] # removing [ and ] at the beginning and end
binspec[len(binspec)-1] = binspec[len(binspec)-1][:-1]
binspec = list(map(lambda i: list(map(float, i.split(","))), binspec))
if False in list(map(lambda i: len(i) == 2, binspec)):
FAILURE("Some interval was not of length 2.")
else:
SUCCESS("All intervals are of length 2.")
if False in list(map(lambda i: i[0] < i[1], binspec)):
FAILURE("Some interval was improperly constructed (lower bound above upper bound).")
else:
SUCCESS("All intervals seem to be properly constructed.")
for i in range(len(binspec) - 1):
if binspec[i][1] > binspec[i+1][0]:
FAILURE("Bins do not seem to be disjoint and/or are not in ascending order.")
SUCCESS("Bins are disjoint and in ascending order.")
MESSAGE("Found " + data(len(binspec)) + " bins")
list(map(lambda i: SUBMESSAGE("from " + data(i[0]) + " to " + data(i[1])), binspec))
except:
FAILURE("Bin specification was improperly formatted!")
#===================================================================================================
STEP("Reading profiles from file")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment