Skip to content

Commit

Permalink
Script for appending PDBs to UNF improved
Browse files Browse the repository at this point in the history
  • Loading branch information
davous267 committed Oct 28, 2021
1 parent 1900baa commit af7857c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion other_scripts/unf_add_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ def parse_args(argv):

def modify_unf(unfFile, pdbFile, molName, molPos, molRot):
file = open(unfFile, "r")
parsedData = json.loads(file.read())
fileContent = file.read()
jsonPartEndIdx = fileContent.find("#INCLUDED_FILE ")
if jsonPartEndIdx > -1:
jsonPart = fileContent[0:jsonPartEndIdx]
else:
jsonPart = fileContent
parsedData = json.loads(jsonPart)

idCounter = parsedData["idCounter"]
# Back slashes are replaced because they are escaped in JSON
Expand Down Expand Up @@ -53,6 +59,8 @@ def modify_unf(unfFile, pdbFile, molName, molPos, molRot):

with open(OUTPUT_FILE_NAME, "w") as outfile:
json.dump(parsedData, outfile)
if jsonPartEndIdx > -1:
outfile.write(fileContent[jsonPartEndIdx:])

# After the JSON-based operations are finished, let's
# append the PDB content to the end of the UNF file
Expand Down

0 comments on commit af7857c

Please sign in to comment.