한 번에 4 줄의 fastq 파일을 읽으려고합니다. 파일에는 여러 줄이 있습니다. 나는 내 코드에 넣어하지만,이 얻을 :한 번에 4 줄 읽음
Traceback (most recent call last):
File "fastq.py", line 11, in
line1 = fastq_file.readline()
AttributeError: 'str' object has no attribute 'readline'
이 내 코드입니다 :
import Tkinter, tkFileDialog #asks user to select a file
root = Tkinter.Tk()
root.withdraw()
fastq_file = tkFileDialog.askopenfilename()
if fastq_file.endswith('.fastq'): #check the file extension
minq = raw_input("What is your minimum Q value? It must be a numerical value.") #receives the minimum Q value
while True:
line1 = fastq_file.readline()
if not line1:break
line2 = fastq_file.readline(2)
line3 = fastq_file.readline(3)
line4 = fastq_file.readline(4)
txt = open(practice.text)
txt.write(line1) #puts the lines into the file
txt.write("\n")
txt.write(line2)
txt.write("\n")
txt.write(line3)
txt.write("\n")
txt.write(line4)
txt.write("\n")
print "Your task is complete!"
else:
print "The file format is not compatible with the FastQ reader program. Please check the file and try again."
내가 그 쓰기 다음 문자열로 각 라인을 할당 할 수 있도록 나는 그것을 해결하는 것입니다 방법 텍스트 파일의 문자열?
'fastq_file'을 어떻게 정의합니까? Lemme 전체 코드를 참조하십시오. – rnbcoder
'fastq_file'은 여러분이 생각하는 것과 다릅니다. 파일 이름을 가지고있는 것처럼 보였으므로 아직 열지 않으므로 'fastq_file'은 단지 문자열입니다. 그러나 'fastq_file'이 정의 된 곳을 보지 않고는 알 수 없습니다. –
또한 어디서나 멀티 스레딩을 언급하지는 않습니다. 해당 질문에 실제로 적용되지 않는 경우 태그를 해제하십시오. –