Skip to content
Snippets Groups Projects
Commit 47a82eb5 authored by Rohmer Coralie's avatar Rohmer Coralie
Browse files

Choice nbr cores & add meta consensus in total out

parent 8ed197cf
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,9 @@ def usage():
" IUPAC consensus sequence in the diploid case\n",
" optional:",
" -c <int>",
" default: 24",
" number of cores",
" -n <string>",
" default: date and time of execution",
" name of the experiment",
......@@ -53,6 +56,10 @@ def usage():
" run_config <string> <string> ...",
" Launches the pipeline from configuration file(s)",
" required: path to the configuration file(s).",
" optional: ",
" -c <int>",
" default: 24",
" number of cores",
" rulegraph",
" Displays a graph of the snakemake rules"
,sep="\n")
......@@ -104,21 +111,32 @@ def summary():
result = subprocess.Popen("ls experiments",shell=True,stdout=subprocess.PIPE)
exp_names=result.communicate()[0].decode("utf-8")
exp_names=re.sub('\n', r' ', exp_names)
result = subprocess.run("./src/total_data_format.py -m -n " + exp_names,shell=True)
result = subprocess.run("./src/total_data_format.py -n " + exp_names,shell=True)
else:
print("No experiment has been launched yet")
def run_config():
cores=""
try:
index_c=sys.argv.index("-c")
cores=sys.argv[index_c+1]
del sys.argv[index_c+1]
del sys.argv[index_c]
except:
pass
try:
path_config = sys.argv[2]
except:
print("ERROR: The configuration file(s) is missing.")
print("Usage: msa_limit.py run_config <path config file>.")
sys.exit()
cores=""
i=2
end_files = 0
while ( not end_files ):
result = subprocess.run(["./src/snakemake_launcher.sh",path_config])
result = subprocess.run(["./src/snakemake_launcher.sh",path_config,cores])
i+=1
try:
path_config = sys.argv[i]
......@@ -239,9 +257,13 @@ else:
lines.append("O: [" + nb_region + "]")
except:
pass
cores=""
try:
cores = sys.argv[sys.argv.index("-c")+1]
except:
pass
print('\n'.join(lines))
#fichier = open(os.path.join("configuration_files",exp_name + ".yaml"), "w")
#fichier.write('\n'.join(lines))
#fichier.close()
#result = subprocess.run(["./src/snakemake_launcher.sh",os.path.join("configuration_files",exp_name + ".yaml")])
fichier = open(os.path.join("configuration_files",exp_name + ".yaml"), "w")
fichier.write('\n'.join(lines))
fichier.close()
result = subprocess.run(["./src/snakemake_launcher.sh",os.path.join("configuration_files",exp_name + ".yaml"),cores])
......@@ -8,6 +8,10 @@ CURRENT_PATH=`pwd`
conda activate $CURRENT_PATH/.conda_snakemake
CONFIG_EXPERIMENT=$1
echo "Launche Snakemake with $1"
snakemake --configfile $1 -c24 --use-conda --rerun-incomplete
if [[ $2 == "" ]]; then
CORES="24"
else
CORES=$2
fi
echo "Launche Snakemake with $CONFIG_EXPERIMENT"
snakemake --configfile $CONFIG_EXPERIMENT -c$CORES --use-conda --rerun-incomplete
......@@ -7,6 +7,7 @@ ATTRIBUTES_TO_DISPLAY_THRESHOLD_INDEPENDANT=["time","memory"]
PREFIX="region_"
RESULT_FOLDER="results"
NAME_DATA_FILE="data_align_t"
NAME_META_CONSENSUS="consensus_consensus_"
#Script use
def use():
print("\nScript:\ttotal_data_formating.py",
......@@ -38,6 +39,13 @@ else:
next_name = sys.argv[sys.argv.index("-n")+i]
except:
end_names = 1
META_CONSENSUS=True
try:
a = [sys.argv[sys.argv.index("-m")]]
except:
META_CONSENSUS=False
files={}
i=0
result = subprocess.run("if [ ! -d results_mean ]; then mkdir results_mean;fi",shell=True)
......@@ -56,6 +64,9 @@ for i in range(len(exp_names)):
for root, dirs, current_files in os.walk(os.path.join(EXP,exp_names[i],dir,RESULT_FOLDER)):
for filename in current_files:
if re.search(NAME_DATA_FILE,filename):
search_meta_consensus=re.search(NAME_META_CONSENSUS,filename)
if ((search_meta_consensus and META_CONSENSUS) or (not search_meta_consensus and not META_CONSENSUS)):
threshold=filename.split(".")[0].split("_t")[1]
if (threshold not in files):
files[threshold]={}
......@@ -123,18 +134,22 @@ for threshold in files :
# Write to output files
#-----------------------------------------------------------------------------
for threshold in files :
add_name_file_output=""
attributes_to_display=ATTRIBUTES_TO_DISPLAY
if (not META_CONSENSUS):
if (threshold==last_threshold):
attributes_to_display+=ATTRIBUTES_TO_DISPLAY_THRESHOLD_INDEPENDANT
else:
add_name_file_output=NAME_META_CONSENSUS
for attribute in attributes_to_display:
#Header for files
if attribute in ATTRIBUTES_TO_DISPLAY_THRESHOLD_INDEPENDANT:
pass
output_mean=open("results_mean/data_mean_"+ attribute + ".csv","w")
output_all=open("results_all_regions/data_all_region_"+ attribute + ".csv","w")
output_mean=open("results_mean/data_" + add_name_file_output + "mean_"+ attribute + ".csv","w")
output_all=open("results_all_regions/data_" + add_name_file_output + "all_region_"+ attribute + ".csv","w")
else:
output_mean=open("results_mean/data_mean_"+ attribute + "_" + threshold + ".csv","w")
output_all=open("results_all_regions/data_all_region_"+ attribute + "_" + threshold + ".csv","w")
output_mean=open("results_mean/data_" + add_name_file_output + "mean_"+ attribute + "_" + threshold + ".csv","w")
output_all=open("results_all_regions/data_" + add_name_file_output + "all_region_"+ attribute + "_" + threshold + ".csv","w")
output_mean.write(",,")
output_all.write(",,")
for exp_name in data["order"]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment