Commit 42c896b7 authored by mirandaa's avatar mirandaa

init

parents
'''
Created on 08.11.2018
@author: mirandaa
'''
if __name__ == '__main__': #A8DYP0
with open('Accessionnumbers.txt', 'r') as accessionnumbers_file:
accessionnumbers = accessionnumbers_file.readlines()
accessionnumbers = [e.strip() for e in accessionnumbers]
print(accessionnumbers)
with open('uniprot-proteome_drosophila_20181030.fasta', 'r') as fasta_file:
fasta = fasta_file.read()
parts = fasta.split('>')
partsDict = {}
for part in parts:
part1 = part.split('\n')[0]
part2 = '\n'.join(part.split('\n')[1:])
part2 = part2.replace('\n', '')
partsDict[part1] = part2
cleaner_dict = {}
for k in partsDict:
if k=='': continue
acccessionNumber = k.split('|')[1]
cleaner_dict[acccessionNumber] = partsDict[k]
result = []
for acs in accessionnumbers:
result.append('>'+acs)
result.append(cleaner_dict[acs])
with open('result.fasta','w') as f:
for item in result:
f.write("%s\n" % item)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment