Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created February 12, 2015 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/4fd275912024f8506102 to your computer and use it in GitHub Desktop.
Save zeffii/4fd275912024f8506102 to your computer and use it in GitHub Desktop.
last_lines.py
if tag == "ENDMDL" or tag=="END" or tag == "MODEL" and (tmpPDBmodelID in tmpPDBmodelImportOrder):
# We add a new MODEL entry to the global pdbIDmodelsDictionary[pdbID],
# based on the current MODEL ID, and we assign the tmpPDBmodelDictionary to this entry.
if not (tag == 'END'):
(pdbIDmodelsDictionary[pdbID])[tmpPDBmodelID] = tmpPDBmodelDictionary
else:
# ugly test: run through the file again and
# look at the last 2 lines.
# if the current tag is END and the last 2 lines are
# TER, END. or 'MASTER and END' then the format is all ATOMs and no MODEL.
with open(filePath,"r") as sfile:
lines = [l[:3] for l in sfile if l.strip()][-2:]
lines = '|'.join(lines)
if lines in {'TER|END', 'MAS|END'}:
(pdbIDmodelsDictionary[pdbID])[tmpPDBmodelID] = tmpPDBmodelDictionary
''' f test '''
f = (pdbIDmodelsDictionary[pdbID])[tmpPDBmodelID]
print('tmpPDBmodelID', tmpPDBmodelID, ':', len(f))
# So now pdbIDmodelsDictionary[pdbID] is a Dictionary: model-dict; the second dict is [atomName]-BBInfo
tmpPDBmodelDictionary = {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment