Skip to content

Instantly share code, notes, and snippets.

@mdshw5
Last active December 16, 2015 01:53
Show Gist options
  • Save mdshw5/fcf00f56feb4802b53bc to your computer and use it in GitHub Desktop.
Save mdshw5/fcf00f56feb4802b53bc to your computer and use it in GitHub Desktop.
biostars 169723
from pyfaidx import Fasta
file_1 = {}
with open('file1.txt', 'r') as ids:
for line in ids:
key, value = line.strip().split('\t')
file_1[key] = value
file_2 = Fasta('file2.fa', key_function=lambda key: file_1[key])
with open('file3.fa', 'w') as renamed:
for entry in file_2:
print(entry.name, file=renamed)
for line in entry:
print(line, file=renamed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment