Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import json
import sys
entries = []
dic = {
'Protein number': None,
'PDB code': None,
'BMRB code': None,
'Protein name': None,
'Deposition date': None,
'PDB title': None,
'PDB authors': None,
'Last author': None,
'Reference': None,
'Reference title': None,
'Software listed': None,
'Spectrometer': None
}
with open(sys.argv[1], 'r') as fp:
protein = False
for line in fp.readlines():
line = line.rstrip()
if line.startswith('Protein number'):
protein = True
counter = line.split()[-1]
entry = dic.copy()
entry['Protein number'] = counter
continue
elif protein:
if len(line) == 0:
protein = False
entries.append(entry)
continue
else:
wrds = line.split()
first = wrds[0]
two = ' '.join(wrds[:2])
if first in entry:
entry[first] = ' '.join(wrds[1:])
continue
if two in entry:
entry[two] = ' '.join(wrds[2:])
continue
#print(json.dumps(entries, indent=2))
#nesgcount = 0
for entry in entries:
pdbtitle = entry['PDB title']
pdbtitle = pdbtitle.upper()
if 'NORTHEAST' in pdbtitle and 'TARGET' in pdbtitle:
#nesgcount += 1
#print(pdbtitle)
targetsplit = pdbtitle.split('TARGET ')
nesg = targetsplit[-1]
#print(nesg)
entry['NESG id'] = nesg
else: entry['NESG id'] = None
#print(nesgcount)
print(json.dumps(entries,indent=2))