1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#!/usr/bin/python3
import argparse
import os
def main(inputPath, outputPath):
is_header = False
with open(inputPath, "r") as input_file, open(outputPath, "w") as output_file:
for line in input_file:
line = line.strip()
comma = ""
if line.startswith(">"):
header = line[1:]
header_tokens = header.split(" ")
is_header = True
elif len(line) > 0:
if header_tokens[-1] == "Name":
if is_header:
output_file.write("configurationName = ")
is_header = False
output_file.write("\"" + line + "\";\n")
elif header_tokens[-1] == "prior":
if is_header and header_tokens[0] == "AT":
output_file.write("priors = {{")
is_header = False
else:
comma = ","
output_file.write(comma+"\n {" + line + "}")
elif header_tokens[-1] == "likelihood":
if is_header and header_tokens[0] == "A":
output_file.write("\n}};\n")
output_file.write("probabilityMatrices = {{\n{")
is_header = False
elif is_header and header_tokens[0] != "A":
output_file.write("\n},\n{")
is_header = False
else:
comma = ","
output_file.write(comma+"\n {" + line + "}")
output_file.write("\n}}};\n")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--input",
type=str,
required=True,
help="Path to SimpleBayesianConsensusCaller configuration file."
)
parser.add_argument(
"--output",
type=str,
required=True,
help="Path to .hpp file to be created."
)
args = parser.parse_args()
main(inputPath=args.input, outputPath=args.output)
|