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 @@
-
-
-
-