Last active
January 24, 2017 12:31
-
-
Save royludo/a7f78d150ae73c2dc1669f91b725592a to your computer and use it in GitHub Desktop.
Input generator for the 1st problem of the Bioinfo Contest 2017, to be used for testing solutions. Write a lot of chemical reactions in the appropriate format. Useful parameters and file generated are indicated with comments.
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
import random | |
total = random.randrange(200,400) # all chemicals will be in the range 1:total | |
init_count = random.randrange(40,80) # length of the 1st line | |
reaction_count = random.randrange(200,2000) # number of line of the input | |
l = [] | |
for i in range(0, init_count): | |
l.append(str(random.randrange(1, total))) | |
string = " ".join(l) + "\n" | |
for i in range(0, reaction_count): | |
input_count = random.randrange(1, 50) # input and output length of the line | |
output_count = random.randrange(1, 50) | |
in_l = [] | |
out_l = [] | |
for j in range(0, input_count): | |
in_l.append(str(random.randrange(1, total))) | |
for j in range(0, output_count): | |
out_l.append(str(random.randrange(1, total))) | |
string += "+".join(in_l) + "->" + "+".join(out_l) +"\n" | |
with open("input_gen_rand.txt", "w") as out: # file name and location | |
out.write(string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment