【发布时间】:2019-03-22 22:00:26
【问题描述】:
首先,我想澄清一下我是编程的超级初学者。 我有 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()
【问题讨论】:
-
你好@KGee,我猜你的代码在这里复制粘贴时出现了一些问题,缩进似乎很错误。您还可以添加,输出应该是什么,当前的输出是什么?由于我们没有您的文件,我们将无法在本地进行测试。祝你有美好的一天。
标签: python biopython blast jquery-ui-selectmenu