Hi, Very new to coding, I have a script that accepts an abi/ab1 gene sequence trace file https://biopython.org/DIST/docs/api/Bio.SeqIO.AbiIO-module.html and text inputs, and returns text outputs. I would like to set this script up on python anywhere so that research groups around the world can use the python script I have written, without having to download it from github and run it on their own machines (us humble biologists are easily confused by code).
Currently I am getting the error "TypeError: 'SpooledTemporaryFile' object is not callable" when I try to setup the app so that users can upload their ab1 file. Why is this occurring? And how do I set this up so that users can upload the ab1 file, call it in the function and get the result back. The script is currently:
app = Flask(name)
app.config["DEBUG"] = True
@app.route("/", methods=["GET", "POST"])
def crispr_decon_page():
if request.method == "POST":
input_file = request.files["input_file"]
input_data = input_file.stream()
output_data = CRISPR_Deconvoluter(input_data)
response = make_response(output_data)
return response
return '''
<html>
<body>
<p>Upload your ab1 file:
<form method="post" action="." enctype="multipart/form-data">
<p><input type="file" name="input_file" /></p>
<p><input type="submit" value="Process the file" /></p>
</form>
</body>
</html>
'''
Where CRISPR_Deconvoluter() is a function I have written in anaconda that works fine when I provide the ab1 file from my computer's files, rather than getting it from the web. Here CRISPR_Deconvoluter() is written in processing and imported into flask__app, where this above code is provided. Please explain in layman's terms, am hopelessly amateur. The error seems to come from within processing at the point within the CRISPR_Deconvoluter() function where I try to read the ab1 file using SeqIO.read(input_data, "abi") - how do I get the input_data to represent the ab1 file in a format that SeqIO can process it? At the moment I think I am missing some steps in the uploading section, such that I am not providing the actual file to SeqIO, but some sort of filepath etc. How to rectify this?
Much appreciated, GR