Skip to content
Snippets Groups Projects
Commit 1ddb554e authored by Manavalan Gajapathy's avatar Manavalan Gajapathy
Browse files

bugfix: changes mosdepth's javascript path

parent aef2903b
No related branches found
No related tags found
1 merge request!2QC under one umbrella (well mostly) under QuaC
......@@ -19,9 +19,12 @@ def main():
for chrom, data in it.groupby(gen, itemgetter(0)):
if chrom.startswith("GL"):
continue
if "Un" in chrom: continue
if "random" in chrom or "HLA" in chrom: continue
if chrom.endswith("alt"): continue
if "Un" in chrom:
continue
if "random" in chrom or "HLA" in chrom:
continue
if chrom.endswith("alt"):
continue
chroms[chrom] = True
xs, ys = [], []
v50 = 0
......@@ -45,16 +48,19 @@ def main():
xs = xs[::2]
ys = ys[::2]
traces[chrom].append({
'x': [round(x, 3) for x in xs],
'y': [round(y, 3) for y in ys],
'mode': 'lines',
'name': sample + (" (%.1f)" % float(v50))
})
traces[chrom].append(
{
"x": [round(x, 3) for x in xs],
"y": [round(y, 3) for y in ys],
"mode": "lines",
"name": sample + (" (%.1f)" % float(v50)),
}
)
# reasoning for js path change - https://github.com/brentp/mosdepth/issues/137
tmpl = """<html>
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://cdn.plot.ly/plotly-1.44.0.min.js"></script>
<style>
div {
width: 800px;
......@@ -88,13 +94,23 @@ def main():
tmpl = string.Template(tmpl)
try:
with open(args.output, "w") as html:
divs = "\n".join("<{div}>{chrom}</{div}><div id='plot-div-{chrom}'></div><hr/>".format(
chrom=c, div="h2" if c == "total" else "b") for c in chroms)
html.write(tmpl.substitute(showlegend="true" if len(
sys.argv[1:]) < 20 else "false", plot_divs=divs))
divs = "\n".join(
"<{div}>{chrom}</{div}><div id='plot-div-{chrom}'></div><hr/>".format(
chrom=c, div="h2" if c == "total" else "b"
)
for c in chroms
)
html.write(
tmpl.substitute(
showlegend="true" if len(sys.argv[1:]) < 20 else "false", plot_divs=divs
)
)
for chrom in chroms:
html.write(string.Template(chr_tmpl).substitute(
chrom=chrom, data=json.dumps(traces[chrom])))
html.write(
string.Template(chr_tmpl).substitute(
chrom=chrom, data=json.dumps(traces[chrom])
)
)
html.write(footer)
except FileNotFoundError:
sys.exit("ERROR: failed creating output file, does the path exist?")
......@@ -102,14 +118,15 @@ def main():
def get_args():
parser = ArgumentParser(description="Creates html plots from mosdepth results.")
parser.add_argument("-o", "--output",
default="dist.html",
help="path and name of output file. Directories must exist.")
parser.add_argument("input",
nargs='+',
help="the dist file(s) to use for plotting")
parser.add_argument(
"-o",
"--output",
default="dist.html",
help="path and name of output file. Directories must exist.",
)
parser.add_argument("input", nargs="+", help="the dist file(s) to use for plotting")
return parser.parse_args()
if __name__ == '__main__':
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment