haddocking / pdb-tools

A dependency-free cross-platform swiss army knife for PDB files.
https://haddocking.github.io/pdb-tools/
Apache License 2.0
390 stars 114 forks source link

CIF to PDB: issue in pdb_fromcif for predicted structures #168

Open venzera opened 2 weeks ago

venzera commented 2 weeks ago

Hi!

When i use pdb_fromcif.py it gets: `Traceback (most recent call last): File "pdb_fromcif.py", line 261, in main() File "pdb_fromcif.py", line 240, in main for lineno, line in enumerate(new_pdb): File "pdb_fromcif.py", line 179, in run charge = fields[labels.get('_atom_site.pdbx_formal_charge')]


TypeError: list indices must be integers or slices, not NoneType`

There is no charge fields in cif files from Chai-1 or AF3 predictions (maybe in all cif files in general, idk). 
It can be solved by simply removing lines 179-184: 

```
charge = fields[labels.get('_atom_site.pdbx_formal_charge')]
try:
    charge = charge
    except ValueError:
    charge = '  '
```

and changing line 187 into 
`atom_line = _a.format(record, serial, atname, altloc, resname, chainid, resnum, icode, x, y, z, occ, bfactor, segid, element)`

I hope it will be useful, since most of the tools still require pdb format. 
Sorry, if it is mentioned before.