# HG changeset patch # User fubar # Date 1691388395 0 # Node ID e2d2b080bae3be1dcd4ffea33724693eb0f6ebf5 # Parent 51a0c2e0fbdf4e0f40c98580c447d354c8424f01 Now refuses to create html for >5k rows. 10k rows will always crash firefox so seems wise to be restrictive. Advises to redo job and select png output... diff -r 51a0c2e0fbdf -r e2d2b080bae3 plotly_tabular_tool/iris.xls --- a/plotly_tabular_tool/iris.xls Fri Aug 04 02:00:28 2023 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ - sepal_length sepal_width petal_length petal_width species species_id -0 5.1 3.5 1.4 0.2 setosa 1 -1 4.9 3.0 1.4 0.2 setosa 1 -2 4.7 3.2 1.3 0.2 setosa 1 -3 4.6 3.1 1.5 0.2 setosa 1 -4 5.0 3.6 1.4 0.2 setosa 1 -5 5.4 3.9 1.7 0.4 setosa 1 -6 4.6 3.4 1.4 0.3 setosa 1 -7 5.0 3.4 1.5 0.2 setosa 1 -8 4.4 2.9 1.4 0.2 setosa 1 -9 4.9 3.1 1.5 0.1 setosa 1 -10 5.4 3.7 1.5 0.2 setosa 1 -11 4.8 3.4 1.6 0.2 setosa 1 -12 4.8 3.0 1.4 0.1 setosa 1 -13 4.3 3.0 1.1 0.1 setosa 1 -14 5.8 4.0 1.2 0.2 setosa 1 -15 5.7 4.4 1.5 0.4 setosa 1 -16 5.4 3.9 1.3 0.4 setosa 1 -17 5.1 3.5 1.4 0.3 setosa 1 -18 5.7 3.8 1.7 0.3 setosa 1 -19 5.1 3.8 1.5 0.3 setosa 1 -20 5.4 3.4 1.7 0.2 setosa 1 -21 5.1 3.7 1.5 0.4 setosa 1 -22 4.6 3.6 1.0 0.2 setosa 1 -23 5.1 3.3 1.7 0.5 setosa 1 -24 4.8 3.4 1.9 0.2 setosa 1 -25 5.0 3.0 1.6 0.2 setosa 1 -26 5.0 3.4 1.6 0.4 setosa 1 -27 5.2 3.5 1.5 0.2 setosa 1 -28 5.2 3.4 1.4 0.2 setosa 1 -29 4.7 3.2 1.6 0.2 setosa 1 -30 4.8 3.1 1.6 0.2 setosa 1 -31 5.4 3.4 1.5 0.4 setosa 1 -32 5.2 4.1 1.5 0.1 setosa 1 -33 5.5 4.2 1.4 0.2 setosa 1 -34 4.9 3.1 1.5 0.1 setosa 1 -35 5.0 3.2 1.2 0.2 setosa 1 -36 5.5 3.5 1.3 0.2 setosa 1 -37 4.9 3.1 1.5 0.1 setosa 1 -38 4.4 3.0 1.3 0.2 setosa 1 -39 5.1 3.4 1.5 0.2 setosa 1 -40 5.0 3.5 1.3 0.3 setosa 1 -41 4.5 2.3 1.3 0.3 setosa 1 -42 4.4 3.2 1.3 0.2 setosa 1 -43 5.0 3.5 1.6 0.6 setosa 1 -44 5.1 3.8 1.9 0.4 setosa 1 -45 4.8 3.0 1.4 0.3 setosa 1 -46 5.1 3.8 1.6 0.2 setosa 1 -47 4.6 3.2 1.4 0.2 setosa 1 -48 5.3 3.7 1.5 0.2 setosa 1 -49 5.0 3.3 1.4 0.2 setosa 1 -50 7.0 3.2 4.7 1.4 versicolor 2 -51 6.4 3.2 4.5 1.5 versicolor 2 -52 6.9 3.1 4.9 1.5 versicolor 2 -53 5.5 2.3 4.0 1.3 versicolor 2 -54 6.5 2.8 4.6 1.5 versicolor 2 -55 5.7 2.8 4.5 1.3 versicolor 2 -56 6.3 3.3 4.7 1.6 versicolor 2 -57 4.9 2.4 3.3 1.0 versicolor 2 -58 6.6 2.9 4.6 1.3 versicolor 2 -59 5.2 2.7 3.9 1.4 versicolor 2 -60 5.0 2.0 3.5 1.0 versicolor 2 -61 5.9 3.0 4.2 1.5 versicolor 2 -62 6.0 2.2 4.0 1.0 versicolor 2 -63 6.1 2.9 4.7 1.4 versicolor 2 -64 5.6 2.9 3.6 1.3 versicolor 2 -65 6.7 3.1 4.4 1.4 versicolor 2 -66 5.6 3.0 4.5 1.5 versicolor 2 -67 5.8 2.7 4.1 1.0 versicolor 2 -68 6.2 2.2 4.5 1.5 versicolor 2 -69 5.6 2.5 3.9 1.1 versicolor 2 -70 5.9 3.2 4.8 1.8 versicolor 2 -71 6.1 2.8 4.0 1.3 versicolor 2 -72 6.3 2.5 4.9 1.5 versicolor 2 -73 6.1 2.8 4.7 1.2 versicolor 2 -74 6.4 2.9 4.3 1.3 versicolor 2 -75 6.6 3.0 4.4 1.4 versicolor 2 -76 6.8 2.8 4.8 1.4 versicolor 2 -77 6.7 3.0 5.0 1.7 versicolor 2 -78 6.0 2.9 4.5 1.5 versicolor 2 -79 5.7 2.6 3.5 1.0 versicolor 2 -80 5.5 2.4 3.8 1.1 versicolor 2 -81 5.5 2.4 3.7 1.0 versicolor 2 -82 5.8 2.7 3.9 1.2 versicolor 2 -83 6.0 2.7 5.1 1.6 versicolor 2 -84 5.4 3.0 4.5 1.5 versicolor 2 -85 6.0 3.4 4.5 1.6 versicolor 2 -86 6.7 3.1 4.7 1.5 versicolor 2 -87 6.3 2.3 4.4 1.3 versicolor 2 -88 5.6 3.0 4.1 1.3 versicolor 2 -89 5.5 2.5 4.0 1.3 versicolor 2 -90 5.5 2.6 4.4 1.2 versicolor 2 -91 6.1 3.0 4.6 1.4 versicolor 2 -92 5.8 2.6 4.0 1.2 versicolor 2 -93 5.0 2.3 3.3 1.0 versicolor 2 -94 5.6 2.7 4.2 1.3 versicolor 2 -95 5.7 3.0 4.2 1.2 versicolor 2 -96 5.7 2.9 4.2 1.3 versicolor 2 -97 6.2 2.9 4.3 1.3 versicolor 2 -98 5.1 2.5 3.0 1.1 versicolor 2 -99 5.7 2.8 4.1 1.3 versicolor 2 -100 6.3 3.3 6.0 2.5 virginica 3 -101 5.8 2.7 5.1 1.9 virginica 3 -102 7.1 3.0 5.9 2.1 virginica 3 -103 6.3 2.9 5.6 1.8 virginica 3 -104 6.5 3.0 5.8 2.2 virginica 3 -105 7.6 3.0 6.6 2.1 virginica 3 -106 4.9 2.5 4.5 1.7 virginica 3 -107 7.3 2.9 6.3 1.8 virginica 3 -108 6.7 2.5 5.8 1.8 virginica 3 -109 7.2 3.6 6.1 2.5 virginica 3 -110 6.5 3.2 5.1 2.0 virginica 3 -111 6.4 2.7 5.3 1.9 virginica 3 -112 6.8 3.0 5.5 2.1 virginica 3 -113 5.7 2.5 5.0 2.0 virginica 3 -114 5.8 2.8 5.1 2.4 virginica 3 -115 6.4 3.2 5.3 2.3 virginica 3 -116 6.5 3.0 5.5 1.8 virginica 3 -117 7.7 3.8 6.7 2.2 virginica 3 -118 7.7 2.6 6.9 2.3 virginica 3 -119 6.0 2.2 5.0 1.5 virginica 3 -120 6.9 3.2 5.7 2.3 virginica 3 -121 5.6 2.8 4.9 2.0 virginica 3 -122 7.7 2.8 6.7 2.0 virginica 3 -123 6.3 2.7 4.9 1.8 virginica 3 -124 6.7 3.3 5.7 2.1 virginica 3 -125 7.2 3.2 6.0 1.8 virginica 3 -126 6.2 2.8 4.8 1.8 virginica 3 -127 6.1 3.0 4.9 1.8 virginica 3 -128 6.4 2.8 5.6 2.1 virginica 3 -129 7.2 3.0 5.8 1.6 virginica 3 -130 7.4 2.8 6.1 1.9 virginica 3 -131 7.9 3.8 6.4 2.0 virginica 3 -132 6.4 2.8 5.6 2.2 virginica 3 -133 6.3 2.8 5.1 1.5 virginica 3 -134 6.1 2.6 5.6 1.4 virginica 3 -135 7.7 3.0 6.1 2.3 virginica 3 -136 6.3 3.4 5.6 2.4 virginica 3 -137 6.4 3.1 5.5 1.8 virginica 3 -138 6.0 3.0 4.8 1.8 virginica 3 -139 6.9 3.1 5.4 2.1 virginica 3 -140 6.7 3.1 5.6 2.4 virginica 3 -141 6.9 3.1 5.1 2.3 virginica 3 -142 5.8 2.7 5.1 1.9 virginica 3 -143 6.8 3.2 5.9 2.3 virginica 3 -144 6.7 3.3 5.7 2.5 virginica 3 -145 6.7 3.0 5.2 2.3 virginica 3 -146 6.3 2.5 5.0 1.9 virginica 3 -147 6.5 3.0 5.2 2.0 virginica 3 -148 6.2 3.4 5.4 2.3 virginica 3 -149 5.9 3.0 5.1 1.8 virginica 3 diff -r 51a0c2e0fbdf -r e2d2b080bae3 plotly_tabular_tool/iris_interactive_10k.html --- a/plotly_tabular_tool/iris_interactive_10k.html Fri Aug 04 02:00:28 2023 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -
-
diff -r 51a0c2e0fbdf -r e2d2b080bae3 plotly_tabular_tool/plotly_tabular_iris_sample.png Binary file plotly_tabular_tool/plotly_tabular_iris_sample.png has changed diff -r 51a0c2e0fbdf -r e2d2b080bae3 plotly_tabular_tool/plotlytabular.xml --- a/plotly_tabular_tool/plotlytabular.xml Fri Aug 04 02:00:28 2023 +0000 +++ b/plotly_tabular_tool/plotlytabular.xml Mon Aug 07 06:06:35 2023 +0000 @@ -1,6 +1,6 @@ - + Plotly plot generator for Galaxy tabular data. pandas @@ -42,6 +42,7 @@ import pandas as pd # Ross Lazarus July 2023 # based on various plotly tutorials +MAXHTMLROWS = 5000 # empirically, browsers die at 10k so stop here for safety and give png parser = argparse.ArgumentParser() a = parser.add_argument a('--input_tab',default='') @@ -63,21 +64,35 @@ df = pd.read_csv(args.input_tab, sep='\t') MAXLEN=35 NCOLS = df.columns.size +NROWS = len(df.index) defaultcols = ['col%d' % (x+1) for x in range(NCOLS)] testcols = df.columns +if args.image_type in ['short_html', 'long_html']: # refuse to create browser crashing gob stopper html + if NROWS > MAXHTMLROWS: + sys.stderr.write('#### CRITICAL: As advised on the tool form, 5k+ rows (you supplied %d) in html breaks browsers, so redo the job and change to png format output.' % NROWS) + sys.exit(6) if len(args.header.strip()) > 0: newcols = args.header.split(',') if len(newcols) == NCOLS: - df.columns = newcols + if (args.xcol in newcols) and (args.ycol in newcols): + df.columns = newcols + else: + sys.stderr.write('#### xcol and ycol not found in supplied header parameter' % (args.xcol, args.ycol, args.header)) + sys.exit(4) else: - sys.stderr.write('#### Supplied header %s has %d comma delimited header names - does not match the input tabular file %d columns - using col1,...coln' % (args.header, len(newcols), NCOLS)) - df.columns = defaultcols + sys.stderr.write('#### Supplied header %s has %d comma delimited header names - does not match the input tabular file %d columns' % (args.header, len(newcols), NCOLS)) + sys.exit(5) else: # no header supplied - check for a real one that matches the x and y axis column names colsok = (args.xcol in testcols) and (args.ycol in testcols) # if they match, probably ok...should use more code and logic.. - if not colsok: - sys.stderr.write('replacing first row of data derived header %s with %s' % (testcols, defaultcols)) - df.columns = defaultcols -#df['col11'] = [-math.log(x) for x in df['col11']] # convert so large values reflect statistical surprise + if colsok: + df.columns = testcols # use actual header + else: + colsok = (args.xcol in defaultcols) and (args.ycol in defaultcols) + if colsok: + sys.stderr.write('replacing first row of data derived header %s with %s' % (testcols, defaultcols)) + df.columns = defaultcols + else: + sys.stderr.write('#### xcol %s and ycol %s do not match anything in the file header, supplied header parameter or automatic default column names' % (args.xcol, args.ycol)) if isHover and isColour: fig = px.scatter(df, x=args.xcol, y=args.ycol, color=args.colourcol, hover_name=args.hovercol) elif isHover: @@ -112,17 +127,18 @@ shutil.copyfile('plotly.png', args.htmlout) + #end raw]]> - + - + @@ -227,6 +243,7 @@ import pandas as pd # Ross Lazarus July 2023 # based on various plotly tutorials + MAXHTMLROWS = 5000 # empirically, browsers die at 10k so stop here for safety and give png parser = argparse.ArgumentParser() a = parser.add_argument a('--input_tab',default='') @@ -248,21 +265,35 @@ df = pd.read_csv(args.input_tab, sep='\t') MAXLEN=35 NCOLS = df.columns.size + NROWS = len(df.index) defaultcols = ['col%d' % (x+1) for x in range(NCOLS)] testcols = df.columns + if args.image_type in ['short_html', 'long_html']: # refuse to create browser crashing gob stopper html + if NROWS > MAXHTMLROWS: + sys.stderr.write('#### CRITICAL: As advised on the tool form, 5k+ rows (you supplied %d) in html breaks browsers, so redo the job and change to png format output.' % NROWS) + sys.exit(6) if len(args.header.strip()) > 0: newcols = args.header.split(',') if len(newcols) == NCOLS: - df.columns = newcols + if (args.xcol in newcols) and (args.ycol in newcols): + df.columns = newcols + else: + sys.stderr.write('#### xcol and ycol not found in supplied header parameter' % (args.xcol, args.ycol, args.header)) + sys.exit(4) else: - sys.stderr.write('#### Supplied header %s has %d comma delimited header names - does not match the input tabular file %d columns - using col1,...coln' % (args.header, len(newcols), NCOLS)) - df.columns = defaultcols + sys.stderr.write('#### Supplied header %s has %d comma delimited header names - does not match the input tabular file %d columns' % (args.header, len(newcols), NCOLS)) + sys.exit(5) else: # no header supplied - check for a real one that matches the x and y axis column names colsok = (args.xcol in testcols) and (args.ycol in testcols) # if they match, probably ok...should use more code and logic.. - if not colsok: - sys.stderr.write('replacing first row of data derived header %s with %s' % (testcols, defaultcols)) - df.columns = defaultcols - #df['col11'] = [-math.log(x) for x in df['col11']] # convert so large values reflect statistical surprise + if colsok: + df.columns = testcols # use actual header + else: + colsok = (args.xcol in defaultcols) and (args.ycol in defaultcols) + if colsok: + sys.stderr.write('replacing first row of data derived header %s with %s' % (testcols, defaultcols)) + df.columns = defaultcols + else: + sys.stderr.write('#### xcol %s and ycol %s do not match anything in the file header, supplied header parameter or automatic default column names' % (args.xcol, args.ycol)) if isHover and isColour: fig = px.scatter(df, x=args.xcol, y=args.ycol, color=args.colourcol, hover_name=args.hovercol) elif isHover: diff -r 51a0c2e0fbdf -r e2d2b080bae3 plotly_tabular_tool/plotlytabular_toolform_sample.png Binary file plotly_tabular_tool/plotlytabular_toolform_sample.png has changed diff -r 51a0c2e0fbdf -r e2d2b080bae3 plotly_tabular_tool/test-data/htmlout_sample --- a/plotly_tabular_tool/test-data/htmlout_sample Fri Aug 04 02:00:28 2023 +0000 +++ b/plotly_tabular_tool/test-data/htmlout_sample Mon Aug 07 06:06:35 2023 +0000 @@ -1,2 +1,2 @@
-
\ No newline at end of file +
\ No newline at end of file diff -r 51a0c2e0fbdf -r e2d2b080bae3 plotly_tabular_tool/test_run.html --- a/plotly_tabular_tool/test_run.html Fri Aug 04 02:00:28 2023 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ - - - -
-
- - \ No newline at end of file