I am writing a benchling uploader script in python to upload data from a csv file in a JSON formatted schema to the benchling API platform. My function to create the JSON schema in the script looks like the following:
def create_antismash_schema(dataframe):
"""Create a json object for antismash output"""
return {
"assayResults": [
{
"fields": {
"entity": {"value": j['SBI ID']},
"sequence_id": {"value": j['sequence_id']},
"category": {"value": j['Category']},
"product": {"value": j['Product']},
"start": {"value": j['start']},
"end": {"value": j['end']},
"nucleotide_length": {"value": j['nucl_length']}
},
"schemaId": "assaysch_Z6B7TlWG",
"projectId": 'src_tIUAcxDH'
} for i, j in dataframe.iterrows()
]
}
Now the data I have in benchling for the fields matches the keys in the schema and the values match the headers in the csv file I'm pulling the data from.
benchling results schema looks like:
csv file:
The error I am getting when I try to upload is the following:
Uploading Antismash data to Benchling...
0%| | 0/159 [00:00<?, ?it/s]{
"assayResults": null,
"errors": [
{
"fields": {
"nucleotide_length": "Value must be an integer"
},
"global": []
},
{
"fields": {
"nucleotide_length": "Value must be an integer"
},
"global": []
},
{
"fields": {
"nucleotide_length": "Value must be an integer"
},
"global": []
}
]
}
0%| | 0/159 [00:00<?, ?it/s]
Failed to upload summary.
HTTP status code: 400
The field is set to be an integer in benchling and all the values I'm pulling from in the csv file for the nucl_length column are integer values so not sure why this error is beig thrown. Any guidance here appreciated, thanks.