Commit 259d9195 authored by SINDT--BARET Yanis's avatar SINDT--BARET Yanis
Browse files

[New] Python module

Allow to lunch multiple session in one program with different genome.
parent c578ae74
import asyncio
import json
async def run(cmd):
proc = await asyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
stdout, stderr = await proc.communicate()
print(f'[{cmd!r} exited with {proc.returncode}]')
if stdout:
print(f'[stdout]\n{stdout.decode()}')
if stderr:
print(f'[stderr]\n{stderr.decode()}')
def create_basic_file(path:str,index:int) -> None:
with open(path, "r") as file:
data_json = json.load(file)
data_json["seed"] = index
old_path_splited = path.split(".")
new_path = f"{old_path_splited[0]}_{index}.{old_path_splited[1]}"
with open(new_path,"w") as result_file:
json.dump(data_json,result_file)
asyncio.run(run(
"""
cd /home/yanissb/CLionProjects/sswm_prototype/build
cmake ..
make
"""
))
if __name__ == '__main__':
nb_hikes = int(input("How many hikes do you want to do ? : ")) #faire un try except
inversion_rate = int(input("Which probability of inversion ? : "))
nb_gen = int(input("How many generation ? : "))
is_neutral_mut = input("Do you allow neutral mutation ? (y/n) : ").lower()
for i in range(nb_hikes) :
create_basic_file("examples/sswm_project/basic.json",i)
asyncio.run(run(
f"""
cd examples/sswm_project
../../build/bin/module_create basic_{i}.json
../../build/bin/sswm result.json {inversion_rate} {nb_gen} {is_neutral_mut} {i}
"""
))
Supports Markdown
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