Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created May 25, 2017 21:59
Show Gist options
  • Select an option

  • Save marcoscastro/2d3d85a033223ad31fddb29832074190 to your computer and use it in GitHub Desktop.

Select an option

Save marcoscastro/2d3d85a033223ad31fddb29832074190 to your computer and use it in GitHub Desktop.
Python - Lendo arquivo fasta
# lendo o arquivo busca.out
nomes = []
with open('busca.out') as arq:
linhas = arq.readlines()
for linha in linhas:
nomes.append(linha.split(' ')[0])
# buscando os nomes no arquivo ensembl34.fa
with open('ensembl34.fa') as arq:
linhas = arq.readlines()
tam_linhas = len(linhas)
# busca por cada nome nas linhas
for nome in nomes:
for i in range(tam_linhas):
achou = linhas[i].find(nome)
if achou != -1: # se achou algo
print('Encontrou %s na linha %d' % (nome, i + 1))
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment