Looking Ahead
Let’s add one final complication. Suppose that molecules didn’t have END markers but instead just a COMPND line followed by one or more ATOM lines. How would we read multiple molecules from a single file in that case?
At first glance (Figure 8, A PDB file Without END markers), it doesn’t seem much different from the problem we just solved: read_molecule could extract the molecule’s name from the COMPND line and then read ATOM lines until it got either an empty string signaling the end of the file or another COMPND line signaling the start of the next molecule. But once it has read that COMPND line, the line isn’t available for the next call to read_molecule, so how can we get the name of the second molecule (and all the ones ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access