Hello,
I am encountering an error in a tool I am developing:
galaxy.web.framework.decorators ERROR 2022-03-11 05:38:11,051 [p:4087,w:1,m:0] [uWSGIWorker1Core0] Uncaught exception in exposed API method:
Traceback (most recent call last):
File “lib/galaxy/web/framework/decorators.py”, line 295, in decorator
rval = func(self, trans, *args, **kwargs)
File “lib/galaxy/webapps/galaxy/api/tools.py”, line 123, in build
return tool.to_json(trans, kwd.get(‘inputs’, kwd))
File “lib/galaxy/tools/init.py”, line 2111, in to_json
populate_state(request_context, self.inputs, params.dict, state_inputs, state_errors)
File “lib/galaxy/tools/parameters/init.py”, line 316, in populate_state
state[input.name] = input.get_initial_value(request_context, context)
File “lib/galaxy/tools/parameters/basic.py”, line 921, in get_initial_value
value = [optval for _, optval, selected in options if selected]
File “lib/galaxy/tools/parameters/basic.py”, line 921, in
value = [optval for _, optval, selected in options if selected]
ValueError: too many values to unpack (expected 3)
The relevant portion of xml looks as follows:
<param name="batch" label="Name of the batch variable" type='select' dynamic_options="mmuphin_get_cols(data)" />
<param name="covariates" type="text" format="text" value="study_condition" label="Name(s) of covariates to adjust for in the batch correction model"/>
</inputs>
<outputs>
<data name="output1" format="csv" label="Adjusted abundance table" />
<data name="output2" format="pdf" label="Adjust batch diagnostic" />
</outputs>
<help><![CDATA[
etc. etc. on the xml
The code I invoke in the program looks as follows:
from galaxy import datatypes, model
import sys
import string
import csv
#############################################################
# Progran to read the first row of the metadata
# and populate the fields in the panel
# Written by George Weingart 2022/03/10
#############################################################
def mmuphin_get_cols(data):
if data == “”:
return
fname = data.dataset.file_name
lMetadata_Colnames = list()
f = open(fname)
csv_reader = csv.reader(f)
line_cntr = -1
for line in csv_reader:
line_cntr+=1
if line_cntr > 0:
return lMetadata_Colnames
lMetadata_Colnames = [x for x in line if x]
f.close()
return lMetadata_Colnames
I know the is not advises / deprecated, so maybe someone can provide a better way to do what we need, which is:
We want to populate a field so that it presents a dropbox selection.
The dropbox is populated from the first row of a csv file that the user presents in the
file.
For example:
The first two lines of a sample file are as follows:
“”,“subjectID”,“body_site”,“study_condition”,“disease”,“age_category”,“country”,“non_westernized”,“DNA_extraction_kit”,“number_reads”,“number_bases”,“minimum_read_length”,“median_read_length”,“curator”,“NCBI_accession”,“antibiotics_current_use”,“disease_subtype”,“age”,“gender”,“BMI”,“tnm”,“hdl”,“triglycerides”,“hba1c”,“ldl”,“location”,“ajcc”,“fobt”,“studyID”
“FengQ_2015.metaphlan_bugs_list.stool:SID31004”,“SID31004”,“stool”,“CRC”,“CRC;fatty_liver;hypertension”,“adult”,“AUT”,“no”,“MoBio”,40898340,3649611221,30,93,“Paolo_Manghi;Marisa_Metzger”,“ERR688505;ERR688358”,NA,“carcinoma”,64,“male”,29.35,“t1n0m0”,28,172,5.2,92,NA,NA,NA,“FengQ_2015.metaphlan_bugs_list.stool”
“FengQ_2015.metaphlan_bugs_list.stool:SID31009”,“SID31009”,“stool”,“control”,“fatty_liver;hypertension”,“senior”,“AUT”,“no”,“MoBio”,66107961,6196998053,30,96,“Paolo_Manghi;Marisa_Metzger”,“ERR688506;ERR688359”,NA,NA,68,“male”,32,NA,50,101,NA,157,NA,NA,NA,“FengQ_2015.metaphlan_bugs_list.stool”
We need it to generate a drop down box that looks as follows:
subjectID
body_site
study_condition
disease
age_category
country
non_westernized
DNA_extraction_kit
number_reads
number_bases
minimum_read_length
median_read_length
curator
NCBI_accession
antibiotics_current_use
disease_subtype
age
gender
BMI
tnm
hdl
triglycerides
hba1c
ldl
location
ajcc
fobt
studyID
Can anyone suggest how to do it without the
?
Otherwise, can someone point me at the current problem ?
Thanks!