nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
657 stars 168 forks source link

Check for missing `pdbx_PDB_helix_class` in CifParser #990

Closed panda-byte closed 1 year ago

panda-byte commented 1 year ago

Resolves #980. AlphaFold-DB structures in .cif format seem to miss pdbx_PDB_helix_class values, which causes an error. The introduced check prevents this issue. Example: https://alphafold.ebi.ac.uk/files/AF-Q5VSL9-F1-model_v4.cif

How to reproduce:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="build/js/ngl.dev.js"></script>
</head>
<body>
<div id="viewport" style="width:400px; height:400px; "></div>

<script>

    new NGL.Stage("viewport", {backgroundColor: 'grey'}).loadFile(
        'https://alphafold.ebi.ac.uk/files/AF-Q5VSL9-F1-model_v4.cif'
    ).then(structure => {
            structure.addRepresentation("cartoon");
            structure.autoView();
        }
    ).catch(alert);

</script>
</body>
</html>

Before the change, this code snippet should throw an error, because sc.pdbx_PDB_helix_class is undefined. After the proposed change, the error is resolved.

panda-byte commented 1 year ago

Do I need to update the dist directory as well?

ppillot commented 1 year ago

No. This will be generated when we are releasing a new version with the update. Thank-you for your contribution!