我正在学习生物信息学教程,并将所有内容放在生物信息学文件夹中。在其中,我的python文件位于一个文件夹中,txt文件位于另一个文件夹中。运行时,我会收到标题中的错误。我已经尝试将父文件夹添加到readFile中。它起了短暂的作用,然后停了下来。
视频中的指导员使用相对路径没有问题。
生物信息学
- test\_data
- gc\_content.txdef readFile(filePath):
'''Reading a file and returning a list of lines'''
with open(filePath, 'r') as f:
return [l.strip() for l in f.readlines()]
def GCcontent(seq):
#tmpFreqDict = {"A": 0, "C": 0, "G": 0, "T": 0}
#for nuc in seq:
# tmpFreqDict[nuc] += 1
#return tmpFreqDict["G"], tmpFreqDict["C"]
return round((seq.count('C') + seq.count('G') / len(seq) * 100))
FASTAFile = readFile('test_data/gc_content.txt')
FASTADict = {}
FASTALabel = ""
print(FASTAFile)
# Converting FASTA file into a dictionary
for line in FASTAFile:
if '>' in line:
FASTALabel = line
FASTADict[FASTALabel] = ""
else:
FASTADict[FASTALabel] += line发布于 2020-09-27 02:13:38
用readFile('test_data/gc_content.txt')更改readFile('../test_data/gc_content.txt')
https://stackoverflow.com/questions/64084056
复制相似问题