Opened 5 years ago

Closed 5 years ago

#3505 closed defect (fixed)

UnicodeDecodeError reading ZINC .pdbqt file

Reported by: chimerax-bug-report@… Owned by: Conrad Huang
Priority: normal Milestone:
Component: Surface/Binding Analysis Version:
Keywords: Cc: Eric Pettersen
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

The following bug report has been submitted:
Platform:        Windows-10-10.0.18362
ChimeraX Version: 1.0 (2020-06-04 23:15:07 UTC)
Description
(Describe the actions that caused this problem to occur here)

Log:
UCSF ChimeraX version: 1.0 (2020-06-04)  
© 2016-2020 Regents of the University of California. All rights reserved.  
How to cite UCSF ChimeraX  

> open C:/Dani/Drogaspalermo/cribado/87-1/10712022370/1_ZINC03873936.mol2

Summary of feedback from opening
C:/Dani/Drogaspalermo/cribado/87-1/10712022370/1_ZINC03873936.mol2  
---  
warning | line 150: ignore unexpected line 'Score: 0'  
  
Opened 1_ZINC03873936.mol2 containing 1 structures (68 atoms, 72 bonds)  

> open C:/Dani/LiSiCa1/5f.mol2

Traceback (most recent call last):  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\open_command\dialog.py", line 150, in _qt_safe  
if data_format is None else " format " +
StringArg.unparse(data_format.nicknames[0])))  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\core\commands\run.py", line 31, in run  
results = command.run(text, log=log)  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\core\commands\cli.py", line 2805, in run  
result = ci.function(session, **kw_args)  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\open_command\cmd.py", line 101, in cmd_open  
Command(session, registry=registry).run(provider_cmd_text, log=log)  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\core\commands\cli.py", line 2805, in run  
result = ci.function(session, **kw_args)  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\open_command\cmd.py", line 152, in provider_open  
name or model_name_from_path(fi.file_name)), provider_kw)  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\open_command\cmd.py", line 382, in collated_open  
return func(*func_args, **func_kw)  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\viewdockx\\__init__.py", line 56, in open  
return opener(session, data, file_name, True, True)  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\viewdockx\io.py", line 5, in open_mol2  
p = Mol2Parser(session, stream, file_name, auto_style, atomic)  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\viewdockx\io.py", line 78, in __init__  
while self._read_section():  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\viewdockx\io.py", line 96, in _read_section  
self._get_line() # Consume section line  
File "C:\Program Files\ChimeraX 1.0\bin\lib\site-
packages\chimerax\viewdockx\io.py", line 123, in _get_line  
line = self.stream.readline()  
File "C:\Program Files\ChimeraX 1.0\bin\lib\encodings\cp1252.py", line 23, in
decode  
return codecs.charmap_decode(input,self.errors,decoding_table)[0]  
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 3942:
character maps to <undefined>  
  
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 3942:
character maps to  
  
File "C:\Program Files\ChimeraX 1.0\bin\lib\encodings\cp1252.py", line 23, in
decode  
return codecs.charmap_decode(input,self.errors,decoding_table)[0]  
  
See log for complete Python traceback.  
  




OpenGL version: 3.3.0 - Build 23.20.16.4973
OpenGL renderer: Intel(R) HD Graphics 620
OpenGL vendor: Intel
Manufacturer: Dell Inc.
Model: Inspiron 5567
OS: Microsoft Windows 10 Home Single Language (Build 18363)
Memory: 8,483,733,504
MaxProcessMemory: 137,438,953,344
CPU: 4 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz"
PyQt version: 5.12.3
Compiled Qt version: 5.12.4
Runtime Qt version: 5.12.8

Change History (2)

comment:1 by Eric Pettersen, 5 years ago

Cc: Eric Pettersen added
Component: UnassignedSurface/Binding Analysis
Owner: set to Conrad Huang
Platform: all
Project: ChimeraX
Status: newassigned
Summary: ChimeraX bug report submissionUnicodeDecodeError reading ZINC .pdbqt file

comment:2 by Eric Pettersen, 5 years ago

Resolution: fixed
Status: assignedclosed

Switched ViewdockX code from using open() directly to chimerax.io.open_input() with the 'encoding="utf-8"' keyword. Conrad, you may or may not want to review the changes. The commit is aaf47935829a657c57fa1bf6866873a45b3cbb53 and the diffs are:

diff --git a/src/bundles/viewdockx/src/io.py b/src/bundles/viewdockx/src/io.py
index 7b080b559..ffd86532a 100644
--- a/src/bundles/viewdockx/src/io.py
+++ b/src/bundles/viewdockx/src/io.py
@@ -1,7 +1,8 @@

# vim: set expandtab shiftwidth=4 softtabstop=4:


def open_mol2(session, path, file_name, auto_style, atomic):

  • with open(path) as stream:

+ from chimerax.io import open_input
+ with open_input(path, encoding='utf-8') as stream:

p = Mol2Parser(session, stream, file_name, auto_style, atomic)

structures = p.structures
status = "Opened %s containing %d structures (%d atoms, %d bonds)" % (

diff --git a/src/bundles/viewdockx/src/pdbqt.py b/src/bundles/viewdockx/src/pdbqt.py
index bfdbc27e7..09597cd86 100755
--- a/src/bundles/viewdockx/src/pdbqt.py
+++ b/src/bundles/viewdockx/src/pdbqt.py
@@ -2,7 +2,8 @@

def open_pdbqt(session, path, file_name, auto_style, atomic):

structures, _status = session.open_command.open_data(path, format="pdb", log_errors=False)

  • with open(path) as f:

+ from chimerax.io import open_input
+ with open_input(path, encoding='utf-8') as f:

_extract_metadata(session, f, structures)

status = "Opened %s containing %d structures (%d atoms, %d bonds)" % (

file_name, len(structures),

Note: See TracTickets for help on using tickets.