.find
문자열을 사용하면 불일치를 찾을 수 있습니다. 불일치는 공백 ('')으로 표시되므로 blat 출력의 가운데 줄에서 찾으십시오. 나는 개인적으로 뻔뻔 스러움을 모른다. 그래서 출력이 항상 삼중 선으로 오는 지 확신 할 수는 없지만, 다음과 같은 함수는 일치하지 않는 위치의 튜플로 표현 된 각 위치가 일치하지 않는 위치 목록을 반환한다. 상단 시퀀스 및 하단 시퀀스의 동일 시퀀스가 포함됩니다. 우리는 (정상 순서에 따라 인덱스) (28, 29)을 배치하거나 (아래 순서에 따라 인덱스) 41629419 및 41629420를 배치 말하는
[(28, 41629419), (29, 41629420)]
생산
blat_src = """00000001 taaaagatgaagtttctatcatccaaaaaatgggctacagaaacc 00000045
<<<<<<<< ||||||||||||||||||||||||||| |||||||||||||||| <<<<<<<<
41629392 taaaagatgaagtttctatcatccaaagtatgggctacagaaacc 41629348"""
def find_mismatch(blat):
#break the blat input into lines
lines = blat.split("\n")
#give some firendly names to the different lines
seq_a = lines[0]
seq_b = lines[2]
#We're not interested in the '<' and '>' so we strip them out with a slice
matchstr = lines[1][9:-9]
#Get the integer values of the starts of each sequence segment
pos_a = int(seq_a[:8])
pos_b = int(seq_b[:8])
results = []
#find the index of first space character, mmpos = mismatch position
mmpos = matchstr.find(" ")
#if a space exists (-1 if none found)
while mmpos != -1:
#the position of the mismatch is the start position of the
#sequence plus the index within the segment
results.append((posa+mmpos, posb+mmpos))
#search the rest of the string (from mmpos+1 onwards)
mmpos = matchstr.find(" ", mmpos+1)
return results
print find_mismatch(blat_src)
은 일치한다.
위 또는 아래 시퀀스에서 위치를 원합니까? 양자 모두? – sirlark
하단 시퀀스에서 원합니다. – user3783999