Logo
Toggle Menu
  • home
  • blog
  • about
    • about this site
    • contact
    • privacy policy
  • cinema 4d
    • plugins
    • creating c4d plugins
    • plugin cookbook
    • software
  • models
    • nodes
    • plants 1
    • other models - 1
    • other models - 2
  • osl
    • writing osl shaders
    • osl shaders for download

Creating a new plugin: 14

And there's a problem...

There I was, getting to the point of adding final tweaks to the plugin when I found a problem. Take a look at this render (it's a model of a transferase protein that has featured in images in previous sections, file 4HG6 in the protein data bank):

Model showing erroneous long 'bond'.

What is that long bond doing there? That's not a true covalent bond, they are much shorter than that as you can see from all the other bonds. So why has that appeared?

It turns out, as you may not be surprised to read, that this is a problem with the PDB file, not the plugin. For various reasons, sometimes the PDB file does not contain ATOM records for all the residues present in a chain. The residues are known to exist in the chain but they aren't present in the ATOM records in the file. In this case, 4HG6 is a protein with two chains, A and B, and in chain B there are some missing residues - from residue 532 to 543 inclusive. The long bond that we see is actually a peptide bond showing residue 531 linking directly to residue 544.

Clearly, this isn't right. How do we deal with it? The first thing to note is that many of these missing sequences occur at the beginning and/or end of a chain. In fact, 4HG6 has five missing sequences, one each at the beginning and end of both chains. The missing residues at the beginning and end we can do nothing about. Most (all?) visualisation apps just ignore them because there are no coordinates given until the first residue in the ATOM records of the file, even if that isn't the first residue in the chain. The ones that cause problems are the ones in the middle of a chain, as seen above.

The usual way to display these is to show a dotted line instead of a solid one. We can do that readily enough, but first there is a more fundamental question: how do we know if there are any missing residues in the file? Ideally, we'd read the ATOM records and look for a discontinuity in the residue sequence number. In the case of 4HG6, that would work. These are the relevant lines in the file:

4GH6 file with missing residues.

You can see that residue 531 ends, and where you'd expect 532 to begin, it jumps to 544. Unfortunately, we can't rely on the PDB file showing ATOM records in residue sequence order, so this won't work for all files.

REMARK records

There is another way to detect missing sequences. Every PDB file will contain many records that were, I suspect, originally intended for miscellaneous comments and information, but now may also contain essential data. The record header for such records is 'REMARK' and each REMARK may - this is optional - also have a remark number which specifies a certain type of data. For example, 'REMARK 1' contains details about scientific publications related to the protein/structure in the file. This isn't of use to us but REMARK 465 - if present - gives a list of all the missing residues which don't have coordinate data in the ATOM records. This is what we want.

Here is part of the REMARK 465 section from 4HG6:

Part of REMARK 465 section from 4HG6.

This tells us that there are missing residues in chain B from 532 to 543 inclusive. Which is exactly what we need to know. When reading the PDB file, we can extract the REMARK 465 lines and store them in a separate array - we only need the residue number and the chain identifier. Then, when constructing the peptide bonds between residues, we can still create the 'bond' between residue 531 and 544, but display it differently - in this case, I've chosen a series of dashes and coloured the spline red. The result looks like this (atoms hidden, only bonds shown for clarity):

Missing residues as dashed line placeholder.:

The red dashed line is a placeholder for the residues for which there are no coordinate data.

This all sounds as if it was really simple but it took a lot of thinking and experimenting to create an algorithm which would handle all cases of missing residues and either ignore them (the line can't be drawn if the missing residues are at the start or end of a chain because we have no way to know where the other end of the spline would be located) or draw the placeholder.

There might be other ways to display missing residues. I've seen several ways to do it: one app puts a star at the start and end of a missing sequence, and that does have the advantage that a single star at the beginning or end of a chain demonstrates missing residues there. Another app uses a wireframe 'basket' display to show the area where some missing residues might be located, and that also has advantages. For the moment I'm happy with the line display but maybe other modes could be added later.

That was a tricky feature to implement, and makes me wonder how many other quirks there are in PDB files which might come out of the woodwork. Which brings me on to...

CIF files

These are the current, modern equivalent of the legacy PDB file. They don't have the disadvantages seen with the older format, and are intended to be more machine-readable - which, of course, means less human-readable. I've come to the conclusion that I'm going to have to support the CIF file format, not least because all new structures added to the protein data bank are required to be in this format. I'm hopeful - very hopeful - that the data structures I've built up to hold the required data to display the structure in Cinema 4D will remain the same. The big difference is going to be parsing the new file format. But that is quite an enjoyable process and I've done it with a variety of file formats in other plugins. So this is next on the list.

Page last updated July 22nd 2026

Blog articles

Creating a new plugin: 14 (July 22nd 2026)

Creating a new plugin: 13 (July 13th 2026)

Creating a new plugin: 12 (July 8th 2026)

Creating a new plugin: 11 (June 29th 2026)

Creating a new plugin: 10 (June 12th 2026)

Creating a new plugin: 9 (June 7th 2026)

Creating a new plugin: 8 (June 4th 2026)

Creating a new plugin: 7 (May 31st 2026)

Creating a new plugin: 6 (May 28th 2026)

Creating a new plugin: 5 (May 26th 2026)

Creating a new plugin: 4 (May 23rd 2026)

Creating a new plugin: 3 (May 22nd 2026)

Creating a new plugin: 2 (May 20th 2026)

Creating a new plugin: 1 (May 17th 2026)

The 'Space' plugins (May 7th 2026)

Creating PBR materials (March 24th 2026)

Data Storage - Then and Now (March 6th 2026)

Old Poser assets (March 2nd 2026)

More Noise, please (January 18th 2026)

Using GIT in VS 2022 (December 26th 2025)

Handling missing plugins (December 12th 2025)

Plugin compatibility with R2026 (November 24th 2025)

Affinity is now free! (November 3rd 2025)

World Creator 2025.1 (October 10th 2025)

So that was Cinema R2026? (September 19th 2025)

How to browse 3D assets (August 24th 2025)

Using Unity assets in Cinema 4D (August 15th 2025)

Plant Factory->Cinema 4D->World Creator (August 12th 2025)

Viewing glTF files (August 9th 2025)

Tessellation part 2 (August 5th 2025)

Shader writing with OSL - 3 (July 11th 2025)

Tessellation (June 23rd 2025)

Creating plants for C4D (June 15th 2025)

Adobe alternatives (May 28th 2025)

Using Graswald assets in C4D (May 7th 2025)

Which Mac for plugin development? (May 3rd 2025)

Why do plugin writers do it? (April 11th 2025)

Updating StarScape (February 26th 2025)

Using Cinema 4D shaders in Redshift (January 31st 2025)

PHP and MySQL (December 19th 2024)

Shader writing with OSL - 2 (November 11th 2024)

Shader writing with OSL (October 29th 2024)

StarScape (September 25th 2024)

Converting plugins from C4D 2024 to 2025 (September 16th 2024)

Cinema 4D 2025 and macOS plugins (September 15th 2025)

© 2021-2025 Microbion. All Rights Reserved.