누군가이 특정 줄 구문을 설명 할 수 있습니까? (길지는 않습니다. 줄이 3 줄입니다.) 사전에 대한 정의를 만들고 파일에서 포함합니다. fastang 시퀀스 nameHandle를 사용하여 :
줄을 내가 이해하지 못하는 것은 #유전학 및 패스트라 시퀀스 구문에 대한 Python 사전
def getfasta(file): #creating the definition
nameHandle=open('fastas.txt,'r') #(this is for opening the file that we're gonna use)
fastas={} #I know it means my dictionnary name
for line in nameHandle: #I know what it means
if line [0]=='>': #(it's beacause each first line in a fasta seq starts with >)
header=line[1:] #(Starting this line I can't understand a thing)
fastas[header]=''
else:
fastas[header]+=line[:-1]
nameHandle.close() #closing the package
return(fastas) #gives us the dictionary with the keys and all of content
코드에서 들여 쓰기가 조금 엉망입니다 당신은 더 쉽게 읽을 수 있도록 그것을 수정해야합니다. – DarksteelPenguin
이 모든 작업이 fasta 시퀀스의 이름을 추출하는 것처럼 보입니다. 그러나 나는 그것이 정확하다고 완전히 확신하지 못합니다. 'line [: - 1]'은 마지막 문자가없는 파일의 줄입니다. 어딘가에 'split'이 있어야 할 것처럼 느껴집니다. –
코드를 조금 더 분명하게 만들려고 시도했습니다. –