Skip to content
Snippets Groups Projects
Commit d64a4760 authored by Hottlet Valentin's avatar Hottlet Valentin
Browse files

Merge branch 'add-craft' into tests-docker

parents deee000d 4dd17b7d
Branches
No related tags found
1 merge request!8Tests docker
......@@ -73,28 +73,28 @@ def align(seq1, seq2):
def generate_page(data, output_path):
html = """
<html>
<html class="no-style">
<head>
<style>
body { font-family: monospace; padding: 20px; }
.diff { background-color: #ffcccc; }
.number {
display: inline-block;
font-size: 0.8em;
color: #444444;
margin-left: 5px;
}
.number2 {
display: inline-block;
font-size: 0.8em;
color: #444444;
margin-right: 5px;
}
h2 { margin-top: 40px; }
</style>
<link style="text/css" rel="stylesheet" href="/Style/css/bioinfo.css" />
<link style="text/css" rel="stylesheet" href="/Style/css/page_theme.css" />
<link style="text/css" rel="stylesheet" href="/pampa/css/pampa.css" />
<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>
</head>
<body>
<div>
"""
html += """
<script>
function downloadMarkerImage(elementId) {
const element = document.getElementById(elementId);
html2canvas(element).then(canvas => {
const link = document.createElement('a');
link.download = elementId + '.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
}
</script>"""
for marker_name, marker_data in data.items():
sequences = {k: v[0] for k, v in marker_data.items() if k != "diff"}
......@@ -104,24 +104,27 @@ def generate_page(data, output_path):
else:
diff_positions = []
html += f"<h2>Marker: {marker_name}</h2>\n"
html += f"<button class='download-button' onclick=\"downloadMarkerImage('marker-{marker_name}')\">Télécharger l’image du marker</button>\n"
html += f"<div id='marker-{marker_name}' class='marker-block'>\n"
html += f"<h2 class='marker'>Marker: {marker_name}</h2>\n"
count = 1
legend = ""
for name, seq in sequences.items():
for name, mass in sequences.items():
highlighted_seq = ""
for i, aa in enumerate(name):
if i in diff_positions:
highlighted_seq += f"<span class='diff'>{aa}</span>"
else:
highlighted_seq += aa
html += f"<div class='sequence-line'>{highlighted_seq}<span class='number'>{count}</span></div>\n"
legend += f"<div class='legend'><span class='number2'>{count}</span>Species: {', '.join(species[name])}</div>\n"
html += f"<div class='sequence-line'><p>{highlighted_seq}<span class='mass'>mass : {mass}</span><span class='number'>{count}</span></p></div>\n"
legend += f"<div class='legend'><p><span class='number2'>{count}</span>Species: {', '.join(species[name])}</p></div>\n"
count += 1
html += "<br>"
html += legend
html += "</div>"
html += "<br>"
html += "</body></html>"
with open(output_path, "w") as f:
html += "</div></body></html>"
with open(output_path + "/alignment.php", "w") as f:
f.write(html)
if __name__ == '__main__':
......
......@@ -207,7 +207,7 @@ def table_maker(peptide_out, peptide_or, output_file, method):
<div id="status" style="margin-top: 10px; color: #666;"></div>
'''
with open(output_file, 'w') as f:
with open(output_file + "/table.php", 'w') as f:
f.write(html)
......
......@@ -63,16 +63,15 @@ def write_main_page(run_id, taxo_used, or_data, method, job_name=None):
html += open(f"{common.HTML_PATH}/menu_central.txt", "r").read()
html += '''</div></div><div id="main"><div id="center">'''
table_dir = common.RESULT_DIR + run_id + "/table.php"
align_dir = common.RESULT_DIR + run_id + "/alignment.php"
resultdir = common.RESULT_DIR + run_id
command = f"/usr/bin/python {common.PAMPA_DIR}table_maker.py -g {or_data} -r {taxo_used} -o {table_dir} -m {method}"
command = f"/usr/bin/python {common.PAMPA_DIR}table_maker.py -g {or_data} -r {taxo_used} -o {resultdir} -m {method}"
os.chdir(format(os.getcwd()) + "/pampa/")
os.system(command)
command = f"/usr/bin/python {common.PAMPA_DIR}alignment_maker.py -r {taxo_used} -o {align_dir}"
command = f"/usr/bin/python {common.PAMPA_DIR}alignment_maker.py -r {taxo_used} -o {resultdir}"
os.system(command)
if os.path.exists(table_dir):
if os.path.exists(resultdir +"/table.php"):
html += f'<h2>Results for job {run_id}{f" ({job_name})" if job_name else ""}</h2>'
# Show warnings if they exist
......@@ -94,6 +93,7 @@ def write_main_page(run_id, taxo_used, or_data, method, job_name=None):
html += '''</table></div><br>'''
html+= '''
<div class="table_container" style="display:block">
<p>editable preview of the results file. <b>Use the bouton bellow to download edited result.</b></p>
<ul>
<li>Cell modification : Double-click on a cell to modify it. You can then enter new values.</li>
......@@ -113,7 +113,10 @@ def write_main_page(run_id, taxo_used, or_data, method, job_name=None):
<p>Once the changes are made, you can download the table by clicking the "Export Table as TSV" button. The file will be downloaded in TSV format.</p>
<p>If you want to undo your changes, you can reload the page to reset any modifications made.</p>'''
html += '<iframe id="results" src="table.php" style="border: none; width: 100%; height: 575px;"></iframe>'
html += '<iframe id="results" src="table.php" style="border: none; width: 100%; height: 575px;"></iframe></div>'
html += '''<div class="alignment_container" style="display:block">'''
html += '<iframe id="results" src="alignment.php" style="border: none; width: 100%; height: 500px;"></iframe></div>'
# Download section
html += '''
......
......@@ -236,17 +236,30 @@ def extract_request(form):
fOut.write(f"PTM={req['limit_PTM']} ")
fOut.write("\n")
minimum = None
digestion = None
if "minimum_peaks" in form:
if form["minimum_peaks"].value != "" and form["minimum_peaks"].value != "5":
minimum = form["minimum_peaks"].value
else:
minimum = None
if minimum:
if "digestion" in form:
if form["digestion"].value != "" and form["digestion"].value != "trypsin":
digestion = form["digestion"].value
if not minimum and not digestion:
pass
else:
with open(f'{common.CONFIG_FILE}', 'r') as f:
data = json.load(f)
if minimum:
data['min_number_of_peaks'] = minimum
log.write(f"Minimum number of peaks set to {minimum}\n")
if digestion:
data['digestion'] = digestion
log.write(f"Digestion set to {digestion}\n")
json.dump(data, open(f'{resdir}/config.json', 'w'))
log.write(f"Digestion set to {minimum}\n")
req['config_file'] = resdir + '/config.json'
log.write("Recap downloads :\n")
......
......@@ -232,3 +232,42 @@ input[type="button"] {
#run {
background-color: #8FBEE7;
}
span.diff {
background-color: #ffcccc;
}
span.number {
display: inline-block;
font-size: 0.8em;
color: #444444;
margin-left: 5px;
}
span.mass {
margin-left: 10px;
}
span.number2 {
display: inline-block;
font-size: 0.8em;
color: #444444;
margin-right: 5px;
}
h2.marker {
font-size: 16px;
margin-bottom: 20px;
}
html.no-style {
all: unset;
}
div.legend p{
font-size:12px;
}
div.sequence-line {
font-size:14px;
}
......@@ -56,16 +56,6 @@
</table>
<br>
<b>Minimum peaks configuration</b>
<table class="vide pampa_choice">
<tr>
<td>
<input type="number" name="minimum_peaks" step="1" min="1" max="100" value="5" required>
</td>
</tr>
</table>
<br>
<b>Mass error tolerance</b>
<table class="vide pampa_choice">
<tr>
......@@ -299,6 +289,47 @@
</div>
</div>
<div class="formulaire">
<h2>Configuration <span style="font-weight: normal">(optional) :</span></h2>
<table class="vide">
<tr>
<td class="label">
<B>Choose</B> your digestion enzyme.
</td>
</tr>
<tr>
<td>
<select name="digestion">
<option value="arg-c">arg-c</option>
<option value="asp-n">asp-n</option>
<option value="chymotrypsin high specificity">chymotrypsin high specificity</option>
<option value="chymotrypsin low specificity">chymotrypsin low specificity</option>
<option value="glutamyl endopeptidase">glutamyl endopeptidase</option>
<option value="pepsin ph1.3">pepsin ph1.3</option>
<option value="pepsin ph2.0">pepsin ph2.0</option>
<option value="proline endopeptidase">proline endopeptidase</option>
<option value="trypsin" selected>trypsin (Default)</option>
<option value="trypsin_exception">trypsin_exception</option>
</select>
</td>
</tr>
</table>
<br>
<table>
<tr>
<td class="label">
<b>Minimum peaks configuration</b>
</td>
</tr>
<tr>
<td>
<input type="number" name="minimum_peaks" step="1" min="1" max="100" value="5" required>
</td>
</tr>
</table>
<br>
</div>
<div class="center">
<input type="button" id="example_1" name="example_1" value="Example">
<input type="submit" id="reset" name="reset" value="Reset" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment