Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Minor Issues with PDB <--> OxDNA Conversion #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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