如何在python / biopython中对本地数据库进行本地查询?

问题描述 投票:0回答:1

首先,我想说清楚我是编程的超级初学者。我有2个zip文件(每个包含一个数据库)和4个fasta文件(三个包含每个蛋白质序列,一个包含核苷酸序列)。

我想创建一个程序,用户可以从菜单中选择分别针对其数据库运行氨基酸或核苷酸文件。下面提到的代码是我能做的最好的代码。不幸的是,它根本没有运行。如果你可以指导我如何处理它,我将非常有义务?

import sys 
import zipfile

def main():
def menu():

print("*****MAIN MENU*****")`

print()

choice = input("""
                  A: For nucleotide "DNA" quest 
                  B: For amino acid "Protein" quest 
                  Q: For Exit the program
                  Please enter your choice: """)

if choice == "A" or choice =="a":
    Dnaquery()

elif choice == "B" or choice =="b":
    Proteinquery()

elif choice=="Q" or choice=="q":
    sys.exit
else:
    print("You must only select either A,B,or Q.")
    print("Please try again")
    menu()

    def Dnaquery(): #for nucletide query
       with zipfile.ZipFile("Dna.zip","r") as zip_ref:
          zip_ref.extractall("C:\Users\Gpapa\Desktop\Zipfiles\DnaDatabase>")

       from Bio.Blast import NCBIWWW
       fasta_string = open("Dna.fasta").read()
       result_handle = NCBIWWW.qblast("blastn", "nt", fasta_string)

   def Proteinquery(): #for protein query
   with zipfile.ZipFile("Protein.zip","r") as zip_ref:
             zip_ref.extractall("C:\Users\Gpapa\Desktop\Zipfiles\ProteinDatabase>")
    def menu2 ()
    print("************Select Protein 2 blast **************")

    print()

     choice = input("""
                  1: For Protein Query 1
                  2: For Protein Query 2
                  3: For Protein Query 3
                  Please enter your choice: """)

     if choice == 1:
      from Bio.Blast import NCBIWWW
      fasta_string = open("protein1.fasta").read()
       result_handle = NCBIWWW.qblast("blastp", "prot", fasta_string)

     elif choice == 2:
     from Bio.Blast import NCBIWWW
      fasta_string = open("protein2.fasta").read()
      result_handle = NCBIWWW.qblast("blastp", "prot", fasta_string)
      elif choice==3:
      from Bio.Blast import NCBIWWW
      fasta_string = open("protein3.fasta").read()
      result_handle = NCBIWWW.qblast("blastp", "prot", fasta_string)
      else:
       print("You must only select either 1,2,or 3")
       print("Please try again")
    menu2()

    main()
python biopython blast jquery-ui-selectmenu
1个回答
0
投票

看起来你正在破坏NCBI,而不是当地的BLAST。我建议你从这里开始本地BLAST:

https://blast.ncbi.nlm.nih.gov/Blast.cgi?CMD=Web&PAGE_TYPE=BlastDocs&DOC_TYPE=Download

© www.soinside.com 2019 - 2024. All rights reserved.