[Biopython-dev] Parsing "element" out of PDB file
Peter
biopython at maubp.freeserve.co.uk
Wed Jun 23 09:11:06 UTC 2010
On Tue, Jun 22, 2010 at 8:25 PM, João Rodrigues <anaryin at gmail.com> wrote:
> Hello all,
>
> I've been using some non-standard pdb files outputted by some programs and
> they miss the chemical element column in each ATOM line. I was looking at
> the PDBParser code and element is dealt with like this:
>
> if element is None:
> import warnings
> from PDBExceptions import PDBConstructionWarning
> warnings.warn("Atom object (name=%s) without element" % name,
> PDBConstructionWarning)
> element = "?"
> print name, "--> ?"
> elif len(element)>2 or element != element.upper() or element !=
> element.strip():
> raise ValueError(element)
> self.element=element
>
>
> In my case, the element line is not "None" but just an empty string - ' ' -
> which fails these tests and is then passed on.
That makes sense, since element=line[76:78].strip() will give an empty
string. A change as you suggest makes sense, but I think just using
"if element:" would be nicer.
Peter
More information about the Biopython-dev
mailing list