Skip to content

Commit

Permalink
Merge pull request #147 from Lucandia/master
Browse files Browse the repository at this point in the history
Fix for Minor Issues with PDB <--> OxDNA Conversion
  • Loading branch information
ErikPoppleton authored Jan 22, 2025
2 parents 0c1ae9b + be15cff commit 1accb1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 4 additions & 1 deletion analysis/src/oxDNA_analysis_tools/PDB_oxDNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ def end_system():
end_system()
continue

# Catch the case where there was no TER or END identifier
# Catch the case where there was no TER identifier
if len(strand) > 0:
end_strand()

# Catch the case where there was no END identifier
if len(sys) > 0:
end_system()

return configs, systems
Expand Down
12 changes: 9 additions & 3 deletions analysis/src/oxDNA_analysis_tools/oxDNA_PDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def oxDNA_PDB(conf:Configuration, system:System, out_basename:str, protein_pdb_f
atom_counter = 1

# Iterate over strands in the oxDNA file
for strand in system.strands:
for i, strand in enumerate(system.strands):
strand_pdb = []
nucleotides_in_strand = strand.monomers
sequence = [n.btype for n in nucleotides_in_strand]
Expand Down Expand Up @@ -381,11 +381,13 @@ def oxDNA_PDB(conf:Configuration, system:System, out_basename:str, protein_pdb_f
# Either open a new file or increment chain ID
# Chain ID can be any alphanumeric character. Convention is A-Z, a-z, 0-9
if one_file_per_strand:
print("END", file=out) # Add the END identifier
out.close()
log("Wrote strand {}'s data to {}".format (strand.id, out_name))
chain_id = 'A'
if strand != system.strands[-1]:
out_name = out_basename + "_{}.pdb".format(strand.id, )
if i < len(system) - 1:
next_strand = system.strands[i + 1]
out_name = out_basename + "_{}.pdb".format(next_strand.id, )
out = open(out_name, "w")
else:
chain_id = chr(ord(chain_id)+1)
Expand All @@ -396,6 +398,10 @@ def oxDNA_PDB(conf:Configuration, system:System, out_basename:str, protein_pdb_f
elif chain_id == chr(ord('0')+1):
log("More than 62 chains identified, looping chain identifier...", level='warning')
chain_id = 'A'

# Add the END identifier at the end of the file
if not one_file_per_strand:
print("END", file=out)
print()

log("Wrote data to '{}'".format(out_name))
Expand Down

0 comments on commit 1accb1a

Please sign in to comment.