Skip to content

Commit

Permalink
added blastn added second path in reload_devlopment
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Abraham - INFlux committed Dec 12, 2024
1 parent 614ac11 commit 7e7b99b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions blast/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,49 @@ async def run_blastp(request: Request):
except subprocess.CalledProcessError as e:
raise HTTPException(status_code=400, detail=f"Command failed: {e.stderr}")


@app.post("/blastn")
async def run_blastn(request: Request):
data = await request.json()

print(f" Received request to run blastn with data: {data}")

query_filename = f"in.fasta"
result_filename = f"out.out"

# Clear or create result file
open(result_filename, 'w').close()

# Create the fasta file from the query string
create_fasta_files_from_seq(data['query'], query_filename)

try:
command = [
"blastn",
'-query', query_filename,
'-db', data['db'],
'-evalue', str(data['evalue']),
'-outfmt', str(data['outfmt']),
'-num_threads', str(data['num_threads']),
'-out', result_filename,
'-max_target_seqs', str(data['max_target_seqs'])
]

result = subprocess.run(
command,
capture_output=True,
check=True,
text=True
)

with open(result_filename, 'r') as file:
result_data = file.read()

return {"result": result_data}

except subprocess.CalledProcessError as e:
raise HTTPException(status_code=400, detail=f"Command failed: {e.stderr}")


if __name__ == "__main__":
import uvicorn
Expand Down
2 changes: 1 addition & 1 deletion blast/reload_development.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo docker stop blast
sudo docker remove blast
sudo docker build --no-cache -t blast_image .
sudo docker run --name blast --volume /home/ala/BA/mydb:/blast/db -p 6001:6001 blast_image
sudo docker run --name blast --volume /home/ala/BA/mydb:/blast/db --volume /mnt/databases:/blast/db/custom -p 6001:6001 blast_image

0 comments on commit 7e7b99b

Please sign in to comment.