{"action":"opened","issue":{"url":"https://api.github.com/repos/biopython/biopython/issues/1884","repository_url":"https://api.github.com/repos/biopython/biopython","labels_url":"https://api.github.com/repos/biopython/biopython/issues/1884/labels{/name}","comments_url":"https://api.github.com/repos/biopython/biopython/issues/1884/comments","events_url":"https://api.github.com/repos/biopython/biopython/issues/1884/events","html_url":"https://github.com/biopython/biopython/issues/1884","id":394709330,"node_id":"MDU6SXNzdWUzOTQ3MDkzMzA=","number":1884,"title":"Bio.PDB.MMCIFParser.MMCIFParser exception","user":{"login":"Minys233","id":23317405,"node_id":"MDQ6VXNlcjIzMzE3NDA1","avatar_url":"https://avatars0.githubusercontent.com/u/23317405?v=4","gravatar_id":"","url":"https://api.github.com/users/Minys233","html_url":"https://github.com/Minys233","followers_url":"https://api.github.com/users/Minys233/followers","following_url":"https://api.github.com/users/Minys233/following{/other_user}","gists_url":"https://api.github.com/users/Minys233/gists{/gist_id}","starred_url":"https://api.github.com/users/Minys233/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Minys233/subscriptions","organizations_url":"https://api.github.com/users/Minys233/orgs","repos_url":"https://api.github.com/users/Minys233/repos","events_url":"https://api.github.com/users/Minys233/events{/privacy}","received_events_url":"https://api.github.com/users/Minys233/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-28T20:01:55Z","updated_at":"2018-12-28T20:01:55Z","closed_at":null,"author_association":"NONE","body":"### Setup\r\n\r\nI am reporting a problem with Biopython version, Python version, and operating\r\nsystem as follows:\r\n\r\n```python\r\nimport sys; print(sys.version)\r\nimport platform; print(platform.python_implementation()); print(platform.platform())\r\nimport Bio; print(Bio.__version__)\r\n\r\n3.6.7 | packaged by conda-forge | (default, Nov 20 2018, 18:20:05) \r\n[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)]\r\nCPython\r\nDarwin-18.2.0-x86_64-i386-64bit\r\n1.73\r\n```\r\n\r\n(*Please copy and run the above in your Python, and copy-and-paste the output*)\r\n\r\n### Expected behaviour\r\n\r\n`Bio.PDB.MMCIFParser.MMCIFParser.get_structure()` parses structure `3HR6` normally.\r\n\r\n### Actual behaviour\r\n\r\nIt will try to parse a string which representing a float number in a char to char manner, thus throw exception: `ValueError: could not convert string to float: '-'`.\r\n\r\n### Steps to reproduce\r\n\r\nFirst, download the mmCIF structure of `3HR6` from RCSB PDB: https://www.rcsb.org/structure/3HR6\r\nThen write the following script and run\r\n```python\r\nfrom Bio.PDB.MMCIFParser import MMCIFParser\r\nmodel = MMCIFParser().get_structure(\"\", \"path/to/3HR6/mmCIF\")\r\n```\r\nThen you got this exception:\r\n```python\r\nTraceback (most recent call last):\r\n  File \"/Users/minys/Downloads/test/test.py\", line 2, in <module>\r\n    model = MMCIFParser().get_structure(\"\", \"test/3hr6.cif\")\r\n  File \"/Users/minys/anaconda3/envs/pymol/lib/python3.6/site-packages/Bio/PDB/MMCIFParser.py\", line 64, in get_structure\r\n    self._build_structure(structure_id)\r\n  File \"/Users/minys/anaconda3/envs/pymol/lib/python3.6/site-packages/Bio/PDB/MMCIFParser.py\", line 202, in _build_structure\r\n    mapped_anisou = [float(_) for _ in u ]\r\n  File \"/Users/minys/anaconda3/envs/pymol/lib/python3.6/site-packages/Bio/PDB/MMCIFParser.py\", line 202, in <listcomp>\r\n    mapped_anisou = [float(_) for _ in u ]\r\nValueError: could not convert string to float: '-'\r\n```\r\nThis exception result from the following code from `Bio/PDB/MMCIFParser.py`:\r\n\r\n```python\r\nif aniso_flag == 1 and i < len(aniso_u11):\r\n    u = (aniso_u11[i], aniso_u12[i], aniso_u13[i],\r\n         aniso_u22[i], aniso_u23[i], aniso_u33[i])\r\n    mapped_anisou = [float(_) for _ in u]\r\n    anisou_array = numpy.array(mapped_anisou, 'f')\r\n    structure_builder.set_anisou(anisou_array)\r\n```\r\nVariables like `aniso_u11` is the raw string comes from `_atom_site_anisotrop.U[1][1]` item of mmCIF file. Then, the code tries to iterating over every character of six strings like '0.1234', '-0.2345' or '-0.0012'. Finally, `ValueError` exception are thrown. The documentation says that this step is to set anisotropic B factor for certain atom through structure_builder.\r\n\r\nBecause I'm not a biologist and honestly, I'm not quite clear what does this mean and why this circumstance will happen. But it is quite strange and will throw exception.\r\n\r\n[Data Item Description of _atom_site_anisotrop](http://mmcif.wwpdb.org/dictionaries/mmcif_mdb.dic/Categories/atom_site_anisotrop.html)\r\n"}}
{"actor":{"display_login":"Minys233"}}