def indexPage(form): tl = twolocus.TwoLocus('/csbiodata/public/www.csbio.unc.edu/htdocs/sgreens/pairwise_origins/') panel = markup.page() helper.link_css_and_js(panel) panel.div(style="padding:20px 20px;") user, permissionLevel, date, time, elapsed = cgAdmin.getCompgenCookie(form) editFlag = (form.getvalue("edit") == "True") if permissionLevel >= 80: panel.add(WikiApp.editTag("%s" % this_file, not editFlag)) panel.add(WikiApp.getWikiContent("%s" % this_file, editInPlace=(permissionLevel >= 80) and editFlag, returnPage="./?run=%s" % this_file)) panel.br() panel.form(_class="form-horizontal", action="", method="POST", enctype="multipart/form-data") panel.div(_class="control-group") panel.h3('Background Samples') has_bg_strains = helper.strain_set_selector(panel, tl, 'background') panel.h3('Foreground Samples') has_fg_strains = helper.strain_set_selector(panel, tl, 'foreground') panel.script("""$(".chosen").chosen()""", type="text/javascript") panel.script('''$("form").submit(function () {return %s() && %s();});''' % (has_bg_strains, has_fg_strains), type="text/javascript") helper.select_all_buttons(panel) panel.br() panel.input(type="hidden", name="target", value="%s.visualization" % this_file) panel.input(type="submit", name="submit", value="Submit") panel.div.close() # control group panel.form.close() panel.div.close() return panel
def indexPage(form): tl = twolocus.TwoLocus('/csbiodata/public/www.csbio.unc.edu/htdocs/sgreens/pairwise_origins/') panel = markup.page() helper.link_css_and_js(panel) panel.div(style="padding:20px 20px;") user, permissionLevel, date, time, elapsed = cgAdmin.getCompgenCookie(form) editFlag = (form.getvalue("edit") == "True") if permissionLevel >= 80: panel.add(WikiApp.editTag("%s" % this_file, not editFlag)) panel.add(WikiApp.getWikiContent("%s" % this_file, editInPlace=(permissionLevel >= 80) and editFlag, returnPage="./?run=%s" % this_file)) panel.br() panel.form(_class="form-horizontal", action="", method="POST", enctype="multipart/form-data") panel.div(_class="control-group") panel.h3('Set of Samples') has_strains = helper.strain_set_selector(panel, tl) for pos_num in ('1', '2'): panel.h3('Position ' + pos_num) helper.open_control(panel, 'Chromosome') panel.select(_class="medium", name="chrom" + pos_num) for chrom_num in xrange(1, 19): panel.option(chrom_num) panel.option('X', value='X') panel.select.close() helper.close_control(panel) helper.open_control(panel, 'Position') panel.add('''<input class="input-medium" name="pos%s" required pattern="\d+[\d,]*\.?\d*[mMkK]*">''' % pos_num) panel.add("""<p class="help-block">3000000 = 3,000,000 = 3m = 3M = 3000k = 3KK</p>""") helper.close_control(panel) panel.script(type="text/javascript") panel.add("""$(".chosen").chosen()""") panel.script.close() helper.select_all_buttons(panel) panel.br() panel.input(type="hidden", name="target", value="%s.countMatrix" % this_file) panel.input(type="submit", name="submit", value="Submit") panel.div.close() # control group panel.form.close() panel.div.close() chromo_sizes = {} for string, integer in twolocus.CHROMO_TO_INT.iteritems(): chromo_sizes[string] = tl.sizes[integer-1] panel.script(''' var chromoSizes = %s; ''' % json.dumps(chromo_sizes), type="text/javascript") panel.script(''' function parsePosition(string) { string = string.replace(',','').toLowerCase(); var pos = parseFloat(string); var units = ''; var char for (var i = 0; i < string.length; i++) { char = string[i]; if (char == 'm' || char == 'k') { pos = parseFloat(string.substring(0, i)); units = string.substring(i); break; } } for (i = 0; i < units.length; i++) { char = units[i]; if (char == 'k') { pos *= 1000; } if (char == 'm') { pos *= 1000000; } } return Math.floor(pos); } function isValidIndex(chromosome, position) { return (chromosome in chromoSizes) && (0 <= position) && (position <= chromoSizes[chromosome]); } $("form").submit(function(event) { var chrom, pos; isValidInput = true; for (var i = 1; i <= 2; i++) { chrom = document.getElementsByName('chrom' + i)[0].value; pos = parsePosition(document.getElementsByName('pos' + i)[0].value); if (!isValidIndex(chrom, pos)) { alert("Position " + i + " exceeds chromosome length"); isValidInput = false; } } return %s(event) && isValidInput; }); ''' % has_strains, type="text/javascript") return panel