This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to use Blastp one sequence vs fasta file and get most similar sequence?

Hello,

I have a protein sequence with format

record = SeqRecord(Seq(sequence), id=Protein_id, description=Protein_id, name=Protein_id)

And a .fasta file with different proteins and sequences (Bacteria.fasta)

I want to apply blastp record vs all the sequences in fasta and retrieve the most similiar sequence? (It is a local blastp against this local database)

How can I do this in python?

Best Regards and Thank you.

python protein fasta blastp

Why do you want to do it in python?

Write the sequence you have in memory to a file (unless you read it from a file, in which case just use that file) and run blastp on the command line, with makeblastdb if required.

Thank you and sorry but could you detail more? I understand i build a local database makeblastdb -in {bacteria_clusters} -dbtype prot -out Bacteria_db then how can I run blastp with my file vs Bacteria_db and get the most similiar

Please read the blast manual. You're already halfway there, I'm confident you can figure this out yourself.

1 answer

okay here is the solution. Thank you for your help Ram .

blastp -outfmt 7 \
-db database \
 -query file \
  > table.tsv

Use -out filename instead of using >.

Please accept your own answer to provide closure to the post.

Log in to answer this question.